vue.esm.browser.js 308 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016
  1. /*!
  2. * Vue.js v2.6.12
  3. * (c) 2014-2020 Evan You
  4. * Released under the MIT License.
  5. */
  6. /* */
  7. const emptyObject = Object.freeze({});
  8. // These helpers produce better VM code in JS engines due to their
  9. // explicitness and function inlining.
  10. function isUndef (v) {
  11. return v === undefined || v === null
  12. }
  13. function isDef (v) {
  14. return v !== undefined && v !== null
  15. }
  16. function isTrue (v) {
  17. return v === true
  18. }
  19. function isFalse (v) {
  20. return v === false
  21. }
  22. /**
  23. * Check if value is primitive.
  24. */
  25. function isPrimitive (value) {
  26. return (
  27. typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean'
  32. )
  33. }
  34. /**
  35. * Quick object check - this is primarily used to tell
  36. * Objects from primitive values when we know the value
  37. * is a JSON-compliant type.
  38. */
  39. function isObject (obj) {
  40. return obj !== null && typeof obj === 'object'
  41. }
  42. /**
  43. * Get the raw type string of a value, e.g., [object Object].
  44. */
  45. const _toString = Object.prototype.toString;
  46. function toRawType (value) {
  47. return _toString.call(value).slice(8, -1)
  48. }
  49. /**
  50. * Strict object type check. Only returns true
  51. * for plain JavaScript objects.
  52. */
  53. function isPlainObject (obj) {
  54. return _toString.call(obj) === '[object Object]'
  55. }
  56. function isRegExp (v) {
  57. return _toString.call(v) === '[object RegExp]'
  58. }
  59. /**
  60. * Check if val is a valid array index.
  61. */
  62. function isValidArrayIndex (val) {
  63. const n = parseFloat(String(val));
  64. return n >= 0 && Math.floor(n) === n && isFinite(val)
  65. }
  66. function isPromise (val) {
  67. return (
  68. isDef(val) &&
  69. typeof val.then === 'function' &&
  70. typeof val.catch === 'function'
  71. )
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString (val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, null, 2)
  81. : String(val)
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber (val) {
  88. const n = parseFloat(val);
  89. return isNaN(n) ? val : n
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap (
  96. str,
  97. expectsLowerCase
  98. ) {
  99. const map = Object.create(null);
  100. const list = str.split(',');
  101. for (let i = 0; i < list.length; i++) {
  102. map[list[i]] = true;
  103. }
  104. return expectsLowerCase
  105. ? val => map[val.toLowerCase()]
  106. : val => map[val]
  107. }
  108. /**
  109. * Check if a tag is a built-in tag.
  110. */
  111. const isBuiltInTag = makeMap('slot,component', true);
  112. /**
  113. * Check if an attribute is a reserved attribute.
  114. */
  115. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  116. /**
  117. * Remove an item from an array.
  118. */
  119. function remove (arr, item) {
  120. if (arr.length) {
  121. const index = arr.indexOf(item);
  122. if (index > -1) {
  123. return arr.splice(index, 1)
  124. }
  125. }
  126. }
  127. /**
  128. * Check whether an object has the property.
  129. */
  130. const hasOwnProperty = Object.prototype.hasOwnProperty;
  131. function hasOwn (obj, key) {
  132. return hasOwnProperty.call(obj, key)
  133. }
  134. /**
  135. * Create a cached version of a pure function.
  136. */
  137. function cached (fn) {
  138. const cache = Object.create(null);
  139. return (function cachedFn (str) {
  140. const hit = cache[str];
  141. return hit || (cache[str] = fn(str))
  142. })
  143. }
  144. /**
  145. * Camelize a hyphen-delimited string.
  146. */
  147. const camelizeRE = /-(\w)/g;
  148. const camelize = cached((str) => {
  149. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
  150. });
  151. /**
  152. * Capitalize a string.
  153. */
  154. const capitalize = cached((str) => {
  155. return str.charAt(0).toUpperCase() + str.slice(1)
  156. });
  157. /**
  158. * Hyphenate a camelCase string.
  159. */
  160. const hyphenateRE = /\B([A-Z])/g;
  161. const hyphenate = cached((str) => {
  162. return str.replace(hyphenateRE, '-$1').toLowerCase()
  163. });
  164. /**
  165. * Simple bind polyfill for environments that do not support it,
  166. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  167. * since native bind is now performant enough in most browsers.
  168. * But removing it would mean breaking code that was able to run in
  169. * PhantomJS 1.x, so this must be kept for backward compatibility.
  170. */
  171. /* istanbul ignore next */
  172. function polyfillBind (fn, ctx) {
  173. function boundFn (a) {
  174. const l = arguments.length;
  175. return l
  176. ? l > 1
  177. ? fn.apply(ctx, arguments)
  178. : fn.call(ctx, a)
  179. : fn.call(ctx)
  180. }
  181. boundFn._length = fn.length;
  182. return boundFn
  183. }
  184. function nativeBind (fn, ctx) {
  185. return fn.bind(ctx)
  186. }
  187. const bind = Function.prototype.bind
  188. ? nativeBind
  189. : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray (list, start) {
  194. start = start || 0;
  195. let i = list.length - start;
  196. const ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend (to, _from) {
  206. for (const key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject (arr) {
  215. const res = {};
  216. for (let i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop (a, b, c) {}
  230. /**
  231. * Always return false.
  232. */
  233. const no = (a, b, c) => false;
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. const identity = (_) => _;
  239. /**
  240. * Generate a string containing static keys from compiler modules.
  241. */
  242. function genStaticKeys (modules) {
  243. return modules.reduce((keys, m) => {
  244. return keys.concat(m.staticKeys || [])
  245. }, []).join(',')
  246. }
  247. /**
  248. * Check if two values are loosely equal - that is,
  249. * if they are plain objects, do they have the same shape?
  250. */
  251. function looseEqual (a, b) {
  252. if (a === b) return true
  253. const isObjectA = isObject(a);
  254. const isObjectB = isObject(b);
  255. if (isObjectA && isObjectB) {
  256. try {
  257. const isArrayA = Array.isArray(a);
  258. const isArrayB = Array.isArray(b);
  259. if (isArrayA && isArrayB) {
  260. return a.length === b.length && a.every((e, i) => {
  261. return looseEqual(e, b[i])
  262. })
  263. } else if (a instanceof Date && b instanceof Date) {
  264. return a.getTime() === b.getTime()
  265. } else if (!isArrayA && !isArrayB) {
  266. const keysA = Object.keys(a);
  267. const keysB = Object.keys(b);
  268. return keysA.length === keysB.length && keysA.every(key => {
  269. return looseEqual(a[key], b[key])
  270. })
  271. } else {
  272. /* istanbul ignore next */
  273. return false
  274. }
  275. } catch (e) {
  276. /* istanbul ignore next */
  277. return false
  278. }
  279. } else if (!isObjectA && !isObjectB) {
  280. return String(a) === String(b)
  281. } else {
  282. return false
  283. }
  284. }
  285. /**
  286. * Return the first index at which a loosely equal value can be
  287. * found in the array (if value is a plain object, the array must
  288. * contain an object of the same shape), or -1 if it is not present.
  289. */
  290. function looseIndexOf (arr, val) {
  291. for (let i = 0; i < arr.length; i++) {
  292. if (looseEqual(arr[i], val)) return i
  293. }
  294. return -1
  295. }
  296. /**
  297. * Ensure a function is called only once.
  298. */
  299. function once (fn) {
  300. let called = false;
  301. return function () {
  302. if (!called) {
  303. called = true;
  304. fn.apply(this, arguments);
  305. }
  306. }
  307. }
  308. const SSR_ATTR = 'data-server-rendered';
  309. const ASSET_TYPES = [
  310. 'component',
  311. 'directive',
  312. 'filter'
  313. ];
  314. const LIFECYCLE_HOOKS = [
  315. 'beforeCreate',
  316. 'created',
  317. 'beforeMount',
  318. 'mounted',
  319. 'beforeUpdate',
  320. 'updated',
  321. 'beforeDestroy',
  322. 'destroyed',
  323. 'activated',
  324. 'deactivated',
  325. 'errorCaptured',
  326. 'serverPrefetch'
  327. ];
  328. /* */
  329. var config = ({
  330. /**
  331. * Option merge strategies (used in core/util/options)
  332. */
  333. // $flow-disable-line
  334. optionMergeStrategies: Object.create(null),
  335. /**
  336. * Whether to suppress warnings.
  337. */
  338. silent: false,
  339. /**
  340. * Show production mode tip message on boot?
  341. */
  342. productionTip: "development" !== 'production',
  343. /**
  344. * Whether to enable devtools
  345. */
  346. devtools: "development" !== 'production',
  347. /**
  348. * Whether to record perf
  349. */
  350. performance: false,
  351. /**
  352. * Error handler for watcher errors
  353. */
  354. errorHandler: null,
  355. /**
  356. * Warn handler for watcher warns
  357. */
  358. warnHandler: null,
  359. /**
  360. * Ignore certain custom elements
  361. */
  362. ignoredElements: [],
  363. /**
  364. * Custom user key aliases for v-on
  365. */
  366. // $flow-disable-line
  367. keyCodes: Object.create(null),
  368. /**
  369. * Check if a tag is reserved so that it cannot be registered as a
  370. * component. This is platform-dependent and may be overwritten.
  371. */
  372. isReservedTag: no,
  373. /**
  374. * Check if an attribute is reserved so that it cannot be used as a component
  375. * prop. This is platform-dependent and may be overwritten.
  376. */
  377. isReservedAttr: no,
  378. /**
  379. * Check if a tag is an unknown element.
  380. * Platform-dependent.
  381. */
  382. isUnknownElement: no,
  383. /**
  384. * Get the namespace of an element
  385. */
  386. getTagNamespace: noop,
  387. /**
  388. * Parse the real tag name for the specific platform.
  389. */
  390. parsePlatformTagName: identity,
  391. /**
  392. * Check if an attribute must be bound using property, e.g. value
  393. * Platform-dependent.
  394. */
  395. mustUseProp: no,
  396. /**
  397. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  398. * This will significantly reduce performance if set to false.
  399. */
  400. async: true,
  401. /**
  402. * Exposed for legacy reasons
  403. */
  404. _lifecycleHooks: LIFECYCLE_HOOKS
  405. });
  406. /* */
  407. /**
  408. * unicode letters used for parsing html tags, component names and property paths.
  409. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  410. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  411. */
  412. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  413. /**
  414. * Check if a string starts with $ or _
  415. */
  416. function isReserved (str) {
  417. const c = (str + '').charCodeAt(0);
  418. return c === 0x24 || c === 0x5F
  419. }
  420. /**
  421. * Define a property.
  422. */
  423. function def (obj, key, val, enumerable) {
  424. Object.defineProperty(obj, key, {
  425. value: val,
  426. enumerable: !!enumerable,
  427. writable: true,
  428. configurable: true
  429. });
  430. }
  431. /**
  432. * Parse simple path.
  433. */
  434. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  435. function parsePath (path) {
  436. if (bailRE.test(path)) {
  437. return
  438. }
  439. const segments = path.split('.');
  440. return function (obj) {
  441. for (let i = 0; i < segments.length; i++) {
  442. if (!obj) return
  443. obj = obj[segments[i]];
  444. }
  445. return obj
  446. }
  447. }
  448. /* */
  449. // can we use __proto__?
  450. const hasProto = '__proto__' in {};
  451. // Browser environment sniffing
  452. const inBrowser = typeof window !== 'undefined';
  453. const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  454. const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  455. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  456. const isIE = UA && /msie|trident/.test(UA);
  457. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  458. const isEdge = UA && UA.indexOf('edge/') > 0;
  459. const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  460. const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  461. const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  462. const isPhantomJS = UA && /phantomjs/.test(UA);
  463. const isFF = UA && UA.match(/firefox\/(\d+)/);
  464. // Firefox has a "watch" function on Object.prototype...
  465. const nativeWatch = ({}).watch;
  466. let supportsPassive = false;
  467. if (inBrowser) {
  468. try {
  469. const opts = {};
  470. Object.defineProperty(opts, 'passive', ({
  471. get () {
  472. /* istanbul ignore next */
  473. supportsPassive = true;
  474. }
  475. })); // https://github.com/facebook/flow/issues/285
  476. window.addEventListener('test-passive', null, opts);
  477. } catch (e) {}
  478. }
  479. // this needs to be lazy-evaled because vue may be required before
  480. // vue-server-renderer can set VUE_ENV
  481. let _isServer;
  482. const isServerRendering = () => {
  483. if (_isServer === undefined) {
  484. /* istanbul ignore if */
  485. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  486. // detect presence of vue-server-renderer and avoid
  487. // Webpack shimming the process
  488. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  489. } else {
  490. _isServer = false;
  491. }
  492. }
  493. return _isServer
  494. };
  495. // detect devtools
  496. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  497. /* istanbul ignore next */
  498. function isNative (Ctor) {
  499. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  500. }
  501. const hasSymbol =
  502. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  503. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  504. let _Set;
  505. /* istanbul ignore if */ // $flow-disable-line
  506. if (typeof Set !== 'undefined' && isNative(Set)) {
  507. // use native Set when available.
  508. _Set = Set;
  509. } else {
  510. // a non-standard Set polyfill that only works with primitive keys.
  511. _Set = class Set {
  512. constructor () {
  513. this.set = Object.create(null);
  514. }
  515. has (key) {
  516. return this.set[key] === true
  517. }
  518. add (key) {
  519. this.set[key] = true;
  520. }
  521. clear () {
  522. this.set = Object.create(null);
  523. }
  524. };
  525. }
  526. /* */
  527. let warn = noop;
  528. let tip = noop;
  529. let generateComponentTrace = (noop); // work around flow check
  530. let formatComponentName = (noop);
  531. {
  532. const hasConsole = typeof console !== 'undefined';
  533. const classifyRE = /(?:^|[-_])(\w)/g;
  534. const classify = str => str
  535. .replace(classifyRE, c => c.toUpperCase())
  536. .replace(/[-_]/g, '');
  537. warn = (msg, vm) => {
  538. const trace = vm ? generateComponentTrace(vm) : '';
  539. if (config.warnHandler) {
  540. config.warnHandler.call(null, msg, vm, trace);
  541. } else if (hasConsole && (!config.silent)) {
  542. console.error(`[Vue warn]: ${msg}${trace}`);
  543. }
  544. };
  545. tip = (msg, vm) => {
  546. if (hasConsole && (!config.silent)) {
  547. console.warn(`[Vue tip]: ${msg}` + (
  548. vm ? generateComponentTrace(vm) : ''
  549. ));
  550. }
  551. };
  552. formatComponentName = (vm, includeFile) => {
  553. if (vm.$root === vm) {
  554. return '<Root>'
  555. }
  556. const options = typeof vm === 'function' && vm.cid != null
  557. ? vm.options
  558. : vm._isVue
  559. ? vm.$options || vm.constructor.options
  560. : vm;
  561. let name = options.name || options._componentTag;
  562. const file = options.__file;
  563. if (!name && file) {
  564. const match = file.match(/([^/\\]+)\.vue$/);
  565. name = match && match[1];
  566. }
  567. return (
  568. (name ? `<${classify(name)}>` : `<Anonymous>`) +
  569. (file && includeFile !== false ? ` at ${file}` : '')
  570. )
  571. };
  572. const repeat = (str, n) => {
  573. let res = '';
  574. while (n) {
  575. if (n % 2 === 1) res += str;
  576. if (n > 1) str += str;
  577. n >>= 1;
  578. }
  579. return res
  580. };
  581. generateComponentTrace = vm => {
  582. if (vm._isVue && vm.$parent) {
  583. const tree = [];
  584. let currentRecursiveSequence = 0;
  585. while (vm) {
  586. if (tree.length > 0) {
  587. const last = tree[tree.length - 1];
  588. if (last.constructor === vm.constructor) {
  589. currentRecursiveSequence++;
  590. vm = vm.$parent;
  591. continue
  592. } else if (currentRecursiveSequence > 0) {
  593. tree[tree.length - 1] = [last, currentRecursiveSequence];
  594. currentRecursiveSequence = 0;
  595. }
  596. }
  597. tree.push(vm);
  598. vm = vm.$parent;
  599. }
  600. return '\n\nfound in\n\n' + tree
  601. .map((vm, i) => `${
  602. i === 0 ? '---> ' : repeat(' ', 5 + i * 2)
  603. }${
  604. Array.isArray(vm)
  605. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  606. : formatComponentName(vm)
  607. }`)
  608. .join('\n')
  609. } else {
  610. return `\n\n(found in ${formatComponentName(vm)})`
  611. }
  612. };
  613. }
  614. /* */
  615. let uid = 0;
  616. /**
  617. * A dep is an observable that can have multiple
  618. * directives subscribing to it.
  619. */
  620. class Dep {
  621. constructor () {
  622. this.id = uid++;
  623. this.subs = [];
  624. }
  625. addSub (sub) {
  626. this.subs.push(sub);
  627. }
  628. removeSub (sub) {
  629. remove(this.subs, sub);
  630. }
  631. depend () {
  632. if (Dep.target) {
  633. Dep.target.addDep(this);
  634. }
  635. }
  636. notify () {
  637. // stabilize the subscriber list first
  638. const subs = this.subs.slice();
  639. if (!config.async) {
  640. // subs aren't sorted in scheduler if not running async
  641. // we need to sort them now to make sure they fire in correct
  642. // order
  643. subs.sort((a, b) => a.id - b.id);
  644. }
  645. for (let i = 0, l = subs.length; i < l; i++) {
  646. subs[i].update();
  647. }
  648. }
  649. }
  650. // The current target watcher being evaluated.
  651. // This is globally unique because only one watcher
  652. // can be evaluated at a time.
  653. Dep.target = null;
  654. const targetStack = [];
  655. function pushTarget (target) {
  656. targetStack.push(target);
  657. Dep.target = target;
  658. }
  659. function popTarget () {
  660. targetStack.pop();
  661. Dep.target = targetStack[targetStack.length - 1];
  662. }
  663. /* */
  664. class VNode {
  665. // rendered in this component's scope
  666. // component instance
  667. // component placeholder node
  668. // strictly internal
  669. // contains raw HTML? (server only)
  670. // hoisted static node
  671. // necessary for enter transition check
  672. // empty comment placeholder?
  673. // is a cloned node?
  674. // is a v-once node?
  675. // async component factory function
  676. // real context vm for functional nodes
  677. // for SSR caching
  678. // used to store functional render context for devtools
  679. // functional scope id support
  680. constructor (
  681. tag,
  682. data,
  683. children,
  684. text,
  685. elm,
  686. context,
  687. componentOptions,
  688. asyncFactory
  689. ) {
  690. this.tag = tag;
  691. this.data = data;
  692. this.children = children;
  693. this.text = text;
  694. this.elm = elm;
  695. this.ns = undefined;
  696. this.context = context;
  697. this.fnContext = undefined;
  698. this.fnOptions = undefined;
  699. this.fnScopeId = undefined;
  700. this.key = data && data.key;
  701. this.componentOptions = componentOptions;
  702. this.componentInstance = undefined;
  703. this.parent = undefined;
  704. this.raw = false;
  705. this.isStatic = false;
  706. this.isRootInsert = true;
  707. this.isComment = false;
  708. this.isCloned = false;
  709. this.isOnce = false;
  710. this.asyncFactory = asyncFactory;
  711. this.asyncMeta = undefined;
  712. this.isAsyncPlaceholder = false;
  713. }
  714. // DEPRECATED: alias for componentInstance for backwards compat.
  715. /* istanbul ignore next */
  716. get child () {
  717. return this.componentInstance
  718. }
  719. }
  720. const createEmptyVNode = (text = '') => {
  721. const node = new VNode();
  722. node.text = text;
  723. node.isComment = true;
  724. return node
  725. };
  726. function createTextVNode (val) {
  727. return new VNode(undefined, undefined, undefined, String(val))
  728. }
  729. // optimized shallow clone
  730. // used for static nodes and slot nodes because they may be reused across
  731. // multiple renders, cloning them avoids errors when DOM manipulations rely
  732. // on their elm reference.
  733. function cloneVNode (vnode) {
  734. const cloned = new VNode(
  735. vnode.tag,
  736. vnode.data,
  737. // #7975
  738. // clone children array to avoid mutating original in case of cloning
  739. // a child.
  740. vnode.children && vnode.children.slice(),
  741. vnode.text,
  742. vnode.elm,
  743. vnode.context,
  744. vnode.componentOptions,
  745. vnode.asyncFactory
  746. );
  747. cloned.ns = vnode.ns;
  748. cloned.isStatic = vnode.isStatic;
  749. cloned.key = vnode.key;
  750. cloned.isComment = vnode.isComment;
  751. cloned.fnContext = vnode.fnContext;
  752. cloned.fnOptions = vnode.fnOptions;
  753. cloned.fnScopeId = vnode.fnScopeId;
  754. cloned.asyncMeta = vnode.asyncMeta;
  755. cloned.isCloned = true;
  756. return cloned
  757. }
  758. /*
  759. * not type checking this file because flow doesn't play well with
  760. * dynamically accessing methods on Array prototype
  761. */
  762. const arrayProto = Array.prototype;
  763. const arrayMethods = Object.create(arrayProto);
  764. const methodsToPatch = [
  765. 'push',
  766. 'pop',
  767. 'shift',
  768. 'unshift',
  769. 'splice',
  770. 'sort',
  771. 'reverse'
  772. ];
  773. /**
  774. * Intercept mutating methods and emit events
  775. */
  776. methodsToPatch.forEach(function (method) {
  777. // cache original method
  778. const original = arrayProto[method];
  779. def(arrayMethods, method, function mutator (...args) {
  780. const result = original.apply(this, args);
  781. const ob = this.__ob__;
  782. let inserted;
  783. switch (method) {
  784. case 'push':
  785. case 'unshift':
  786. inserted = args;
  787. break
  788. case 'splice':
  789. inserted = args.slice(2);
  790. break
  791. }
  792. if (inserted) ob.observeArray(inserted);
  793. // notify change
  794. ob.dep.notify();
  795. return result
  796. });
  797. });
  798. /* */
  799. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  800. /**
  801. * In some cases we may want to disable observation inside a component's
  802. * update computation.
  803. */
  804. let shouldObserve = true;
  805. function toggleObserving (value) {
  806. shouldObserve = value;
  807. }
  808. /**
  809. * Observer class that is attached to each observed
  810. * object. Once attached, the observer converts the target
  811. * object's property keys into getter/setters that
  812. * collect dependencies and dispatch updates.
  813. */
  814. class Observer {
  815. // number of vms that have this object as root $data
  816. constructor (value) {
  817. this.value = value;
  818. this.dep = new Dep();
  819. this.vmCount = 0;
  820. def(value, '__ob__', this);
  821. if (Array.isArray(value)) {
  822. if (hasProto) {
  823. protoAugment(value, arrayMethods);
  824. } else {
  825. copyAugment(value, arrayMethods, arrayKeys);
  826. }
  827. this.observeArray(value);
  828. } else {
  829. this.walk(value);
  830. }
  831. }
  832. /**
  833. * Walk through all properties and convert them into
  834. * getter/setters. This method should only be called when
  835. * value type is Object.
  836. */
  837. walk (obj) {
  838. const keys = Object.keys(obj);
  839. for (let i = 0; i < keys.length; i++) {
  840. defineReactive$$1(obj, keys[i]);
  841. }
  842. }
  843. /**
  844. * Observe a list of Array items.
  845. */
  846. observeArray (items) {
  847. for (let i = 0, l = items.length; i < l; i++) {
  848. observe(items[i]);
  849. }
  850. }
  851. }
  852. // helpers
  853. /**
  854. * Augment a target Object or Array by intercepting
  855. * the prototype chain using __proto__
  856. */
  857. function protoAugment (target, src) {
  858. /* eslint-disable no-proto */
  859. target.__proto__ = src;
  860. /* eslint-enable no-proto */
  861. }
  862. /**
  863. * Augment a target Object or Array by defining
  864. * hidden properties.
  865. */
  866. /* istanbul ignore next */
  867. function copyAugment (target, src, keys) {
  868. for (let i = 0, l = keys.length; i < l; i++) {
  869. const key = keys[i];
  870. def(target, key, src[key]);
  871. }
  872. }
  873. /**
  874. * Attempt to create an observer instance for a value,
  875. * returns the new observer if successfully observed,
  876. * or the existing observer if the value already has one.
  877. */
  878. function observe (value, asRootData) {
  879. if (!isObject(value) || value instanceof VNode) {
  880. return
  881. }
  882. let ob;
  883. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  884. ob = value.__ob__;
  885. } else if (
  886. shouldObserve &&
  887. !isServerRendering() &&
  888. (Array.isArray(value) || isPlainObject(value)) &&
  889. Object.isExtensible(value) &&
  890. !value._isVue
  891. ) {
  892. ob = new Observer(value);
  893. }
  894. if (asRootData && ob) {
  895. ob.vmCount++;
  896. }
  897. return ob
  898. }
  899. /**
  900. * Define a reactive property on an Object.
  901. */
  902. function defineReactive$$1 (
  903. obj,
  904. key,
  905. val,
  906. customSetter,
  907. shallow
  908. ) {
  909. const dep = new Dep();
  910. const property = Object.getOwnPropertyDescriptor(obj, key);
  911. if (property && property.configurable === false) {
  912. return
  913. }
  914. // cater for pre-defined getter/setters
  915. const getter = property && property.get;
  916. const setter = property && property.set;
  917. if ((!getter || setter) && arguments.length === 2) {
  918. val = obj[key];
  919. }
  920. let childOb = !shallow && observe(val);
  921. Object.defineProperty(obj, key, {
  922. enumerable: true,
  923. configurable: true,
  924. get: function reactiveGetter () {
  925. const value = getter ? getter.call(obj) : val;
  926. if (Dep.target) {
  927. dep.depend();
  928. if (childOb) {
  929. childOb.dep.depend();
  930. if (Array.isArray(value)) {
  931. dependArray(value);
  932. }
  933. }
  934. }
  935. return value
  936. },
  937. set: function reactiveSetter (newVal) {
  938. const value = getter ? getter.call(obj) : val;
  939. /* eslint-disable no-self-compare */
  940. if (newVal === value || (newVal !== newVal && value !== value)) {
  941. return
  942. }
  943. /* eslint-enable no-self-compare */
  944. if (customSetter) {
  945. customSetter();
  946. }
  947. // #7981: for accessor properties without setter
  948. if (getter && !setter) return
  949. if (setter) {
  950. setter.call(obj, newVal);
  951. } else {
  952. val = newVal;
  953. }
  954. childOb = !shallow && observe(newVal);
  955. dep.notify();
  956. }
  957. });
  958. }
  959. /**
  960. * Set a property on an object. Adds the new property and
  961. * triggers change notification if the property doesn't
  962. * already exist.
  963. */
  964. function set (target, key, val) {
  965. if (isUndef(target) || isPrimitive(target)
  966. ) {
  967. warn(`Cannot set reactive property on undefined, null, or primitive value: ${(target)}`);
  968. }
  969. if (Array.isArray(target) && isValidArrayIndex(key)) {
  970. target.length = Math.max(target.length, key);
  971. target.splice(key, 1, val);
  972. return val
  973. }
  974. if (key in target && !(key in Object.prototype)) {
  975. target[key] = val;
  976. return val
  977. }
  978. const ob = (target).__ob__;
  979. if (target._isVue || (ob && ob.vmCount)) {
  980. warn(
  981. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  982. 'at runtime - declare it upfront in the data option.'
  983. );
  984. return val
  985. }
  986. if (!ob) {
  987. target[key] = val;
  988. return val
  989. }
  990. defineReactive$$1(ob.value, key, val);
  991. ob.dep.notify();
  992. return val
  993. }
  994. /**
  995. * Delete a property and trigger change if necessary.
  996. */
  997. function del (target, key) {
  998. if (isUndef(target) || isPrimitive(target)
  999. ) {
  1000. warn(`Cannot delete reactive property on undefined, null, or primitive value: ${(target)}`);
  1001. }
  1002. if (Array.isArray(target) && isValidArrayIndex(key)) {
  1003. target.splice(key, 1);
  1004. return
  1005. }
  1006. const ob = (target).__ob__;
  1007. if (target._isVue || (ob && ob.vmCount)) {
  1008. warn(
  1009. 'Avoid deleting properties on a Vue instance or its root $data ' +
  1010. '- just set it to null.'
  1011. );
  1012. return
  1013. }
  1014. if (!hasOwn(target, key)) {
  1015. return
  1016. }
  1017. delete target[key];
  1018. if (!ob) {
  1019. return
  1020. }
  1021. ob.dep.notify();
  1022. }
  1023. /**
  1024. * Collect dependencies on array elements when the array is touched, since
  1025. * we cannot intercept array element access like property getters.
  1026. */
  1027. function dependArray (value) {
  1028. for (let e, i = 0, l = value.length; i < l; i++) {
  1029. e = value[i];
  1030. e && e.__ob__ && e.__ob__.dep.depend();
  1031. if (Array.isArray(e)) {
  1032. dependArray(e);
  1033. }
  1034. }
  1035. }
  1036. /* */
  1037. /**
  1038. * Option overwriting strategies are functions that handle
  1039. * how to merge a parent option value and a child option
  1040. * value into the final value.
  1041. */
  1042. const strats = config.optionMergeStrategies;
  1043. /**
  1044. * Options with restrictions
  1045. */
  1046. {
  1047. strats.el = strats.propsData = function (parent, child, vm, key) {
  1048. if (!vm) {
  1049. warn(
  1050. `option "${key}" can only be used during instance ` +
  1051. 'creation with the `new` keyword.'
  1052. );
  1053. }
  1054. return defaultStrat(parent, child)
  1055. };
  1056. }
  1057. /**
  1058. * Helper that recursively merges two data objects together.
  1059. */
  1060. function mergeData (to, from) {
  1061. if (!from) return to
  1062. let key, toVal, fromVal;
  1063. const keys = hasSymbol
  1064. ? Reflect.ownKeys(from)
  1065. : Object.keys(from);
  1066. for (let i = 0; i < keys.length; i++) {
  1067. key = keys[i];
  1068. // in case the object is already observed...
  1069. if (key === '__ob__') continue
  1070. toVal = to[key];
  1071. fromVal = from[key];
  1072. if (!hasOwn(to, key)) {
  1073. set(to, key, fromVal);
  1074. } else if (
  1075. toVal !== fromVal &&
  1076. isPlainObject(toVal) &&
  1077. isPlainObject(fromVal)
  1078. ) {
  1079. mergeData(toVal, fromVal);
  1080. }
  1081. }
  1082. return to
  1083. }
  1084. /**
  1085. * Data
  1086. */
  1087. function mergeDataOrFn (
  1088. parentVal,
  1089. childVal,
  1090. vm
  1091. ) {
  1092. if (!vm) {
  1093. // in a Vue.extend merge, both should be functions
  1094. if (!childVal) {
  1095. return parentVal
  1096. }
  1097. if (!parentVal) {
  1098. return childVal
  1099. }
  1100. // when parentVal & childVal are both present,
  1101. // we need to return a function that returns the
  1102. // merged result of both functions... no need to
  1103. // check if parentVal is a function here because
  1104. // it has to be a function to pass previous merges.
  1105. return function mergedDataFn () {
  1106. return mergeData(
  1107. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1108. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1109. )
  1110. }
  1111. } else {
  1112. return function mergedInstanceDataFn () {
  1113. // instance merge
  1114. const instanceData = typeof childVal === 'function'
  1115. ? childVal.call(vm, vm)
  1116. : childVal;
  1117. const defaultData = typeof parentVal === 'function'
  1118. ? parentVal.call(vm, vm)
  1119. : parentVal;
  1120. if (instanceData) {
  1121. return mergeData(instanceData, defaultData)
  1122. } else {
  1123. return defaultData
  1124. }
  1125. }
  1126. }
  1127. }
  1128. strats.data = function (
  1129. parentVal,
  1130. childVal,
  1131. vm
  1132. ) {
  1133. if (!vm) {
  1134. if (childVal && typeof childVal !== 'function') {
  1135. warn(
  1136. 'The "data" option should be a function ' +
  1137. 'that returns a per-instance value in component ' +
  1138. 'definitions.',
  1139. vm
  1140. );
  1141. return parentVal
  1142. }
  1143. return mergeDataOrFn(parentVal, childVal)
  1144. }
  1145. return mergeDataOrFn(parentVal, childVal, vm)
  1146. };
  1147. /**
  1148. * Hooks and props are merged as arrays.
  1149. */
  1150. function mergeHook (
  1151. parentVal,
  1152. childVal
  1153. ) {
  1154. const res = childVal
  1155. ? parentVal
  1156. ? parentVal.concat(childVal)
  1157. : Array.isArray(childVal)
  1158. ? childVal
  1159. : [childVal]
  1160. : parentVal;
  1161. return res
  1162. ? dedupeHooks(res)
  1163. : res
  1164. }
  1165. function dedupeHooks (hooks) {
  1166. const res = [];
  1167. for (let i = 0; i < hooks.length; i++) {
  1168. if (res.indexOf(hooks[i]) === -1) {
  1169. res.push(hooks[i]);
  1170. }
  1171. }
  1172. return res
  1173. }
  1174. LIFECYCLE_HOOKS.forEach(hook => {
  1175. strats[hook] = mergeHook;
  1176. });
  1177. /**
  1178. * Assets
  1179. *
  1180. * When a vm is present (instance creation), we need to do
  1181. * a three-way merge between constructor options, instance
  1182. * options and parent options.
  1183. */
  1184. function mergeAssets (
  1185. parentVal,
  1186. childVal,
  1187. vm,
  1188. key
  1189. ) {
  1190. const res = Object.create(parentVal || null);
  1191. if (childVal) {
  1192. assertObjectType(key, childVal, vm);
  1193. return extend(res, childVal)
  1194. } else {
  1195. return res
  1196. }
  1197. }
  1198. ASSET_TYPES.forEach(function (type) {
  1199. strats[type + 's'] = mergeAssets;
  1200. });
  1201. /**
  1202. * Watchers.
  1203. *
  1204. * Watchers hashes should not overwrite one
  1205. * another, so we merge them as arrays.
  1206. */
  1207. strats.watch = function (
  1208. parentVal,
  1209. childVal,
  1210. vm,
  1211. key
  1212. ) {
  1213. // work around Firefox's Object.prototype.watch...
  1214. if (parentVal === nativeWatch) parentVal = undefined;
  1215. if (childVal === nativeWatch) childVal = undefined;
  1216. /* istanbul ignore if */
  1217. if (!childVal) return Object.create(parentVal || null)
  1218. {
  1219. assertObjectType(key, childVal, vm);
  1220. }
  1221. if (!parentVal) return childVal
  1222. const ret = {};
  1223. extend(ret, parentVal);
  1224. for (const key in childVal) {
  1225. let parent = ret[key];
  1226. const child = childVal[key];
  1227. if (parent && !Array.isArray(parent)) {
  1228. parent = [parent];
  1229. }
  1230. ret[key] = parent
  1231. ? parent.concat(child)
  1232. : Array.isArray(child) ? child : [child];
  1233. }
  1234. return ret
  1235. };
  1236. /**
  1237. * Other object hashes.
  1238. */
  1239. strats.props =
  1240. strats.methods =
  1241. strats.inject =
  1242. strats.computed = function (
  1243. parentVal,
  1244. childVal,
  1245. vm,
  1246. key
  1247. ) {
  1248. if (childVal && "development" !== 'production') {
  1249. assertObjectType(key, childVal, vm);
  1250. }
  1251. if (!parentVal) return childVal
  1252. const ret = Object.create(null);
  1253. extend(ret, parentVal);
  1254. if (childVal) extend(ret, childVal);
  1255. return ret
  1256. };
  1257. strats.provide = mergeDataOrFn;
  1258. /**
  1259. * Default strategy.
  1260. */
  1261. const defaultStrat = function (parentVal, childVal) {
  1262. return childVal === undefined
  1263. ? parentVal
  1264. : childVal
  1265. };
  1266. /**
  1267. * Validate component names
  1268. */
  1269. function checkComponents (options) {
  1270. for (const key in options.components) {
  1271. validateComponentName(key);
  1272. }
  1273. }
  1274. function validateComponentName (name) {
  1275. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  1276. warn(
  1277. 'Invalid component name: "' + name + '". Component names ' +
  1278. 'should conform to valid custom element name in html5 specification.'
  1279. );
  1280. }
  1281. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  1282. warn(
  1283. 'Do not use built-in or reserved HTML elements as component ' +
  1284. 'id: ' + name
  1285. );
  1286. }
  1287. }
  1288. /**
  1289. * Ensure all props option syntax are normalized into the
  1290. * Object-based format.
  1291. */
  1292. function normalizeProps (options, vm) {
  1293. const props = options.props;
  1294. if (!props) return
  1295. const res = {};
  1296. let i, val, name;
  1297. if (Array.isArray(props)) {
  1298. i = props.length;
  1299. while (i--) {
  1300. val = props[i];
  1301. if (typeof val === 'string') {
  1302. name = camelize(val);
  1303. res[name] = { type: null };
  1304. } else {
  1305. warn('props must be strings when using array syntax.');
  1306. }
  1307. }
  1308. } else if (isPlainObject(props)) {
  1309. for (const key in props) {
  1310. val = props[key];
  1311. name = camelize(key);
  1312. res[name] = isPlainObject(val)
  1313. ? val
  1314. : { type: val };
  1315. }
  1316. } else {
  1317. warn(
  1318. `Invalid value for option "props": expected an Array or an Object, ` +
  1319. `but got ${toRawType(props)}.`,
  1320. vm
  1321. );
  1322. }
  1323. options.props = res;
  1324. }
  1325. /**
  1326. * Normalize all injections into Object-based format
  1327. */
  1328. function normalizeInject (options, vm) {
  1329. const inject = options.inject;
  1330. if (!inject) return
  1331. const normalized = options.inject = {};
  1332. if (Array.isArray(inject)) {
  1333. for (let i = 0; i < inject.length; i++) {
  1334. normalized[inject[i]] = { from: inject[i] };
  1335. }
  1336. } else if (isPlainObject(inject)) {
  1337. for (const key in inject) {
  1338. const val = inject[key];
  1339. normalized[key] = isPlainObject(val)
  1340. ? extend({ from: key }, val)
  1341. : { from: val };
  1342. }
  1343. } else {
  1344. warn(
  1345. `Invalid value for option "inject": expected an Array or an Object, ` +
  1346. `but got ${toRawType(inject)}.`,
  1347. vm
  1348. );
  1349. }
  1350. }
  1351. /**
  1352. * Normalize raw function directives into object format.
  1353. */
  1354. function normalizeDirectives (options) {
  1355. const dirs = options.directives;
  1356. if (dirs) {
  1357. for (const key in dirs) {
  1358. const def$$1 = dirs[key];
  1359. if (typeof def$$1 === 'function') {
  1360. dirs[key] = { bind: def$$1, update: def$$1 };
  1361. }
  1362. }
  1363. }
  1364. }
  1365. function assertObjectType (name, value, vm) {
  1366. if (!isPlainObject(value)) {
  1367. warn(
  1368. `Invalid value for option "${name}": expected an Object, ` +
  1369. `but got ${toRawType(value)}.`,
  1370. vm
  1371. );
  1372. }
  1373. }
  1374. /**
  1375. * Merge two option objects into a new one.
  1376. * Core utility used in both instantiation and inheritance.
  1377. */
  1378. function mergeOptions (
  1379. parent,
  1380. child,
  1381. vm
  1382. ) {
  1383. {
  1384. checkComponents(child);
  1385. }
  1386. if (typeof child === 'function') {
  1387. child = child.options;
  1388. }
  1389. normalizeProps(child, vm);
  1390. normalizeInject(child, vm);
  1391. normalizeDirectives(child);
  1392. // Apply extends and mixins on the child options,
  1393. // but only if it is a raw options object that isn't
  1394. // the result of another mergeOptions call.
  1395. // Only merged options has the _base property.
  1396. if (!child._base) {
  1397. if (child.extends) {
  1398. parent = mergeOptions(parent, child.extends, vm);
  1399. }
  1400. if (child.mixins) {
  1401. for (let i = 0, l = child.mixins.length; i < l; i++) {
  1402. parent = mergeOptions(parent, child.mixins[i], vm);
  1403. }
  1404. }
  1405. }
  1406. const options = {};
  1407. let key;
  1408. for (key in parent) {
  1409. mergeField(key);
  1410. }
  1411. for (key in child) {
  1412. if (!hasOwn(parent, key)) {
  1413. mergeField(key);
  1414. }
  1415. }
  1416. function mergeField (key) {
  1417. const strat = strats[key] || defaultStrat;
  1418. options[key] = strat(parent[key], child[key], vm, key);
  1419. }
  1420. return options
  1421. }
  1422. /**
  1423. * Resolve an asset.
  1424. * This function is used because child instances need access
  1425. * to assets defined in its ancestor chain.
  1426. */
  1427. function resolveAsset (
  1428. options,
  1429. type,
  1430. id,
  1431. warnMissing
  1432. ) {
  1433. /* istanbul ignore if */
  1434. if (typeof id !== 'string') {
  1435. return
  1436. }
  1437. const assets = options[type];
  1438. // check local registration variations first
  1439. if (hasOwn(assets, id)) return assets[id]
  1440. const camelizedId = camelize(id);
  1441. if (hasOwn(assets, camelizedId)) return assets[camelizedId]
  1442. const PascalCaseId = capitalize(camelizedId);
  1443. if (hasOwn(assets, PascalCaseId)) return assets[PascalCaseId]
  1444. // fallback to prototype chain
  1445. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1446. if (warnMissing && !res) {
  1447. warn(
  1448. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1449. options
  1450. );
  1451. }
  1452. return res
  1453. }
  1454. /* */
  1455. function validateProp (
  1456. key,
  1457. propOptions,
  1458. propsData,
  1459. vm
  1460. ) {
  1461. const prop = propOptions[key];
  1462. const absent = !hasOwn(propsData, key);
  1463. let value = propsData[key];
  1464. // boolean casting
  1465. const booleanIndex = getTypeIndex(Boolean, prop.type);
  1466. if (booleanIndex > -1) {
  1467. if (absent && !hasOwn(prop, 'default')) {
  1468. value = false;
  1469. } else if (value === '' || value === hyphenate(key)) {
  1470. // only cast empty string / same name to boolean if
  1471. // boolean has higher priority
  1472. const stringIndex = getTypeIndex(String, prop.type);
  1473. if (stringIndex < 0 || booleanIndex < stringIndex) {
  1474. value = true;
  1475. }
  1476. }
  1477. }
  1478. // check default value
  1479. if (value === undefined) {
  1480. value = getPropDefaultValue(vm, prop, key);
  1481. // since the default value is a fresh copy,
  1482. // make sure to observe it.
  1483. const prevShouldObserve = shouldObserve;
  1484. toggleObserving(true);
  1485. observe(value);
  1486. toggleObserving(prevShouldObserve);
  1487. }
  1488. {
  1489. assertProp(prop, key, value, vm, absent);
  1490. }
  1491. return value
  1492. }
  1493. /**
  1494. * Get the default value of a prop.
  1495. */
  1496. function getPropDefaultValue (vm, prop, key) {
  1497. // no default, return undefined
  1498. if (!hasOwn(prop, 'default')) {
  1499. return undefined
  1500. }
  1501. const def = prop.default;
  1502. // warn against non-factory defaults for Object & Array
  1503. if (isObject(def)) {
  1504. warn(
  1505. 'Invalid default value for prop "' + key + '": ' +
  1506. 'Props with type Object/Array must use a factory function ' +
  1507. 'to return the default value.',
  1508. vm
  1509. );
  1510. }
  1511. // the raw prop value was also undefined from previous render,
  1512. // return previous default value to avoid unnecessary watcher trigger
  1513. if (vm && vm.$options.propsData &&
  1514. vm.$options.propsData[key] === undefined &&
  1515. vm._props[key] !== undefined
  1516. ) {
  1517. return vm._props[key]
  1518. }
  1519. // call factory function for non-Function types
  1520. // a value is Function if its prototype is function even across different execution context
  1521. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1522. ? def.call(vm)
  1523. : def
  1524. }
  1525. /**
  1526. * Assert whether a prop is valid.
  1527. */
  1528. function assertProp (
  1529. prop,
  1530. name,
  1531. value,
  1532. vm,
  1533. absent
  1534. ) {
  1535. if (prop.required && absent) {
  1536. warn(
  1537. 'Missing required prop: "' + name + '"',
  1538. vm
  1539. );
  1540. return
  1541. }
  1542. if (value == null && !prop.required) {
  1543. return
  1544. }
  1545. let type = prop.type;
  1546. let valid = !type || type === true;
  1547. const expectedTypes = [];
  1548. if (type) {
  1549. if (!Array.isArray(type)) {
  1550. type = [type];
  1551. }
  1552. for (let i = 0; i < type.length && !valid; i++) {
  1553. const assertedType = assertType(value, type[i]);
  1554. expectedTypes.push(assertedType.expectedType || '');
  1555. valid = assertedType.valid;
  1556. }
  1557. }
  1558. if (!valid) {
  1559. warn(
  1560. getInvalidTypeMessage(name, value, expectedTypes),
  1561. vm
  1562. );
  1563. return
  1564. }
  1565. const validator = prop.validator;
  1566. if (validator) {
  1567. if (!validator(value)) {
  1568. warn(
  1569. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1570. vm
  1571. );
  1572. }
  1573. }
  1574. }
  1575. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  1576. function assertType (value, type) {
  1577. let valid;
  1578. const expectedType = getType(type);
  1579. if (simpleCheckRE.test(expectedType)) {
  1580. const t = typeof value;
  1581. valid = t === expectedType.toLowerCase();
  1582. // for primitive wrapper objects
  1583. if (!valid && t === 'object') {
  1584. valid = value instanceof type;
  1585. }
  1586. } else if (expectedType === 'Object') {
  1587. valid = isPlainObject(value);
  1588. } else if (expectedType === 'Array') {
  1589. valid = Array.isArray(value);
  1590. } else {
  1591. valid = value instanceof type;
  1592. }
  1593. return {
  1594. valid,
  1595. expectedType
  1596. }
  1597. }
  1598. /**
  1599. * Use function string name to check built-in types,
  1600. * because a simple equality check will fail when running
  1601. * across different vms / iframes.
  1602. */
  1603. function getType (fn) {
  1604. const match = fn && fn.toString().match(/^\s*function (\w+)/);
  1605. return match ? match[1] : ''
  1606. }
  1607. function isSameType (a, b) {
  1608. return getType(a) === getType(b)
  1609. }
  1610. function getTypeIndex (type, expectedTypes) {
  1611. if (!Array.isArray(expectedTypes)) {
  1612. return isSameType(expectedTypes, type) ? 0 : -1
  1613. }
  1614. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  1615. if (isSameType(expectedTypes[i], type)) {
  1616. return i
  1617. }
  1618. }
  1619. return -1
  1620. }
  1621. function getInvalidTypeMessage (name, value, expectedTypes) {
  1622. let message = `Invalid prop: type check failed for prop "${name}".` +
  1623. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  1624. const expectedType = expectedTypes[0];
  1625. const receivedType = toRawType(value);
  1626. const expectedValue = styleValue(value, expectedType);
  1627. const receivedValue = styleValue(value, receivedType);
  1628. // check if we need to specify expected value
  1629. if (expectedTypes.length === 1 &&
  1630. isExplicable(expectedType) &&
  1631. !isBoolean(expectedType, receivedType)) {
  1632. message += ` with value ${expectedValue}`;
  1633. }
  1634. message += `, got ${receivedType} `;
  1635. // check if we need to specify received value
  1636. if (isExplicable(receivedType)) {
  1637. message += `with value ${receivedValue}.`;
  1638. }
  1639. return message
  1640. }
  1641. function styleValue (value, type) {
  1642. if (type === 'String') {
  1643. return `"${value}"`
  1644. } else if (type === 'Number') {
  1645. return `${Number(value)}`
  1646. } else {
  1647. return `${value}`
  1648. }
  1649. }
  1650. function isExplicable (value) {
  1651. const explicitTypes = ['string', 'number', 'boolean'];
  1652. return explicitTypes.some(elem => value.toLowerCase() === elem)
  1653. }
  1654. function isBoolean (...args) {
  1655. return args.some(elem => elem.toLowerCase() === 'boolean')
  1656. }
  1657. /* */
  1658. function handleError (err, vm, info) {
  1659. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  1660. // See: https://github.com/vuejs/vuex/issues/1505
  1661. pushTarget();
  1662. try {
  1663. if (vm) {
  1664. let cur = vm;
  1665. while ((cur = cur.$parent)) {
  1666. const hooks = cur.$options.errorCaptured;
  1667. if (hooks) {
  1668. for (let i = 0; i < hooks.length; i++) {
  1669. try {
  1670. const capture = hooks[i].call(cur, err, vm, info) === false;
  1671. if (capture) return
  1672. } catch (e) {
  1673. globalHandleError(e, cur, 'errorCaptured hook');
  1674. }
  1675. }
  1676. }
  1677. }
  1678. }
  1679. globalHandleError(err, vm, info);
  1680. } finally {
  1681. popTarget();
  1682. }
  1683. }
  1684. function invokeWithErrorHandling (
  1685. handler,
  1686. context,
  1687. args,
  1688. vm,
  1689. info
  1690. ) {
  1691. let res;
  1692. try {
  1693. res = args ? handler.apply(context, args) : handler.call(context);
  1694. if (res && !res._isVue && isPromise(res) && !res._handled) {
  1695. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  1696. // issue #9511
  1697. // avoid catch triggering multiple times when nested calls
  1698. res._handled = true;
  1699. }
  1700. } catch (e) {
  1701. handleError(e, vm, info);
  1702. }
  1703. return res
  1704. }
  1705. function globalHandleError (err, vm, info) {
  1706. if (config.errorHandler) {
  1707. try {
  1708. return config.errorHandler.call(null, err, vm, info)
  1709. } catch (e) {
  1710. // if the user intentionally throws the original error in the handler,
  1711. // do not log it twice
  1712. if (e !== err) {
  1713. logError(e, null, 'config.errorHandler');
  1714. }
  1715. }
  1716. }
  1717. logError(err, vm, info);
  1718. }
  1719. function logError (err, vm, info) {
  1720. {
  1721. warn(`Error in ${info}: "${err.toString()}"`, vm);
  1722. }
  1723. /* istanbul ignore else */
  1724. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  1725. console.error(err);
  1726. } else {
  1727. throw err
  1728. }
  1729. }
  1730. /* */
  1731. let isUsingMicroTask = false;
  1732. const callbacks = [];
  1733. let pending = false;
  1734. function flushCallbacks () {
  1735. pending = false;
  1736. const copies = callbacks.slice(0);
  1737. callbacks.length = 0;
  1738. for (let i = 0; i < copies.length; i++) {
  1739. copies[i]();
  1740. }
  1741. }
  1742. // Here we have async deferring wrappers using microtasks.
  1743. // In 2.5 we used (macro) tasks (in combination with microtasks).
  1744. // However, it has subtle problems when state is changed right before repaint
  1745. // (e.g. #6813, out-in transitions).
  1746. // Also, using (macro) tasks in event handler would cause some weird behaviors
  1747. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  1748. // So we now use microtasks everywhere, again.
  1749. // A major drawback of this tradeoff is that there are some scenarios
  1750. // where microtasks have too high a priority and fire in between supposedly
  1751. // sequential events (e.g. #4521, #6690, which have workarounds)
  1752. // or even between bubbling of the same event (#6566).
  1753. let timerFunc;
  1754. // The nextTick behavior leverages the microtask queue, which can be accessed
  1755. // via either native Promise.then or MutationObserver.
  1756. // MutationObserver has wider support, however it is seriously bugged in
  1757. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  1758. // completely stops working after triggering a few times... so, if native
  1759. // Promise is available, we will use it:
  1760. /* istanbul ignore next, $flow-disable-line */
  1761. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  1762. const p = Promise.resolve();
  1763. timerFunc = () => {
  1764. p.then(flushCallbacks);
  1765. // In problematic UIWebViews, Promise.then doesn't completely break, but
  1766. // it can get stuck in a weird state where callbacks are pushed into the
  1767. // microtask queue but the queue isn't being flushed, until the browser
  1768. // needs to do some other work, e.g. handle a timer. Therefore we can
  1769. // "force" the microtask queue to be flushed by adding an empty timer.
  1770. if (isIOS) setTimeout(noop);
  1771. };
  1772. isUsingMicroTask = true;
  1773. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  1774. isNative(MutationObserver) ||
  1775. // PhantomJS and iOS 7.x
  1776. MutationObserver.toString() === '[object MutationObserverConstructor]'
  1777. )) {
  1778. // Use MutationObserver where native Promise is not available,
  1779. // e.g. PhantomJS, iOS7, Android 4.4
  1780. // (#6466 MutationObserver is unreliable in IE11)
  1781. let counter = 1;
  1782. const observer = new MutationObserver(flushCallbacks);
  1783. const textNode = document.createTextNode(String(counter));
  1784. observer.observe(textNode, {
  1785. characterData: true
  1786. });
  1787. timerFunc = () => {
  1788. counter = (counter + 1) % 2;
  1789. textNode.data = String(counter);
  1790. };
  1791. isUsingMicroTask = true;
  1792. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  1793. // Fallback to setImmediate.
  1794. // Technically it leverages the (macro) task queue,
  1795. // but it is still a better choice than setTimeout.
  1796. timerFunc = () => {
  1797. setImmediate(flushCallbacks);
  1798. };
  1799. } else {
  1800. // Fallback to setTimeout.
  1801. timerFunc = () => {
  1802. setTimeout(flushCallbacks, 0);
  1803. };
  1804. }
  1805. function nextTick (cb, ctx) {
  1806. let _resolve;
  1807. callbacks.push(() => {
  1808. if (cb) {
  1809. try {
  1810. cb.call(ctx);
  1811. } catch (e) {
  1812. handleError(e, ctx, 'nextTick');
  1813. }
  1814. } else if (_resolve) {
  1815. _resolve(ctx);
  1816. }
  1817. });
  1818. if (!pending) {
  1819. pending = true;
  1820. timerFunc();
  1821. }
  1822. // $flow-disable-line
  1823. if (!cb && typeof Promise !== 'undefined') {
  1824. return new Promise(resolve => {
  1825. _resolve = resolve;
  1826. })
  1827. }
  1828. }
  1829. /* */
  1830. let mark;
  1831. let measure;
  1832. {
  1833. const perf = inBrowser && window.performance;
  1834. /* istanbul ignore if */
  1835. if (
  1836. perf &&
  1837. perf.mark &&
  1838. perf.measure &&
  1839. perf.clearMarks &&
  1840. perf.clearMeasures
  1841. ) {
  1842. mark = tag => perf.mark(tag);
  1843. measure = (name, startTag, endTag) => {
  1844. perf.measure(name, startTag, endTag);
  1845. perf.clearMarks(startTag);
  1846. perf.clearMarks(endTag);
  1847. // perf.clearMeasures(name)
  1848. };
  1849. }
  1850. }
  1851. /* not type checking this file because flow doesn't play well with Proxy */
  1852. let initProxy;
  1853. {
  1854. const allowedGlobals = makeMap(
  1855. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  1856. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  1857. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  1858. 'require' // for Webpack/Browserify
  1859. );
  1860. const warnNonPresent = (target, key) => {
  1861. warn(
  1862. `Property or method "${key}" is not defined on the instance but ` +
  1863. 'referenced during render. Make sure that this property is reactive, ' +
  1864. 'either in the data option, or for class-based components, by ' +
  1865. 'initializing the property. ' +
  1866. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  1867. target
  1868. );
  1869. };
  1870. const warnReservedPrefix = (target, key) => {
  1871. warn(
  1872. `Property "${key}" must be accessed with "$data.${key}" because ` +
  1873. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  1874. 'prevent conflicts with Vue internals. ' +
  1875. 'See: https://vuejs.org/v2/api/#data',
  1876. target
  1877. );
  1878. };
  1879. const hasProxy =
  1880. typeof Proxy !== 'undefined' && isNative(Proxy);
  1881. if (hasProxy) {
  1882. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  1883. config.keyCodes = new Proxy(config.keyCodes, {
  1884. set (target, key, value) {
  1885. if (isBuiltInModifier(key)) {
  1886. warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  1887. return false
  1888. } else {
  1889. target[key] = value;
  1890. return true
  1891. }
  1892. }
  1893. });
  1894. }
  1895. const hasHandler = {
  1896. has (target, key) {
  1897. const has = key in target;
  1898. const isAllowed = allowedGlobals(key) ||
  1899. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  1900. if (!has && !isAllowed) {
  1901. if (key in target.$data) warnReservedPrefix(target, key);
  1902. else warnNonPresent(target, key);
  1903. }
  1904. return has || !isAllowed
  1905. }
  1906. };
  1907. const getHandler = {
  1908. get (target, key) {
  1909. if (typeof key === 'string' && !(key in target)) {
  1910. if (key in target.$data) warnReservedPrefix(target, key);
  1911. else warnNonPresent(target, key);
  1912. }
  1913. return target[key]
  1914. }
  1915. };
  1916. initProxy = function initProxy (vm) {
  1917. if (hasProxy) {
  1918. // determine which proxy handler to use
  1919. const options = vm.$options;
  1920. const handlers = options.render && options.render._withStripped
  1921. ? getHandler
  1922. : hasHandler;
  1923. vm._renderProxy = new Proxy(vm, handlers);
  1924. } else {
  1925. vm._renderProxy = vm;
  1926. }
  1927. };
  1928. }
  1929. /* */
  1930. const seenObjects = new _Set();
  1931. /**
  1932. * Recursively traverse an object to evoke all converted
  1933. * getters, so that every nested property inside the object
  1934. * is collected as a "deep" dependency.
  1935. */
  1936. function traverse (val) {
  1937. _traverse(val, seenObjects);
  1938. seenObjects.clear();
  1939. }
  1940. function _traverse (val, seen) {
  1941. let i, keys;
  1942. const isA = Array.isArray(val);
  1943. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  1944. return
  1945. }
  1946. if (val.__ob__) {
  1947. const depId = val.__ob__.dep.id;
  1948. if (seen.has(depId)) {
  1949. return
  1950. }
  1951. seen.add(depId);
  1952. }
  1953. if (isA) {
  1954. i = val.length;
  1955. while (i--) _traverse(val[i], seen);
  1956. } else {
  1957. keys = Object.keys(val);
  1958. i = keys.length;
  1959. while (i--) _traverse(val[keys[i]], seen);
  1960. }
  1961. }
  1962. /* */
  1963. const normalizeEvent = cached((name) => {
  1964. const passive = name.charAt(0) === '&';
  1965. name = passive ? name.slice(1) : name;
  1966. const once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  1967. name = once$$1 ? name.slice(1) : name;
  1968. const capture = name.charAt(0) === '!';
  1969. name = capture ? name.slice(1) : name;
  1970. return {
  1971. name,
  1972. once: once$$1,
  1973. capture,
  1974. passive
  1975. }
  1976. });
  1977. function createFnInvoker (fns, vm) {
  1978. function invoker () {
  1979. const fns = invoker.fns;
  1980. if (Array.isArray(fns)) {
  1981. const cloned = fns.slice();
  1982. for (let i = 0; i < cloned.length; i++) {
  1983. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1984. }
  1985. } else {
  1986. // return handler return value for single handlers
  1987. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`)
  1988. }
  1989. }
  1990. invoker.fns = fns;
  1991. return invoker
  1992. }
  1993. function updateListeners (
  1994. on,
  1995. oldOn,
  1996. add,
  1997. remove$$1,
  1998. createOnceHandler,
  1999. vm
  2000. ) {
  2001. let name, def$$1, cur, old, event;
  2002. for (name in on) {
  2003. def$$1 = cur = on[name];
  2004. old = oldOn[name];
  2005. event = normalizeEvent(name);
  2006. if (isUndef(cur)) {
  2007. warn(
  2008. `Invalid handler for event "${event.name}": got ` + String(cur),
  2009. vm
  2010. );
  2011. } else if (isUndef(old)) {
  2012. if (isUndef(cur.fns)) {
  2013. cur = on[name] = createFnInvoker(cur, vm);
  2014. }
  2015. if (isTrue(event.once)) {
  2016. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  2017. }
  2018. add(event.name, cur, event.capture, event.passive, event.params);
  2019. } else if (cur !== old) {
  2020. old.fns = cur;
  2021. on[name] = old;
  2022. }
  2023. }
  2024. for (name in oldOn) {
  2025. if (isUndef(on[name])) {
  2026. event = normalizeEvent(name);
  2027. remove$$1(event.name, oldOn[name], event.capture);
  2028. }
  2029. }
  2030. }
  2031. /* */
  2032. function mergeVNodeHook (def, hookKey, hook) {
  2033. if (def instanceof VNode) {
  2034. def = def.data.hook || (def.data.hook = {});
  2035. }
  2036. let invoker;
  2037. const oldHook = def[hookKey];
  2038. function wrappedHook () {
  2039. hook.apply(this, arguments);
  2040. // important: remove merged hook to ensure it's called only once
  2041. // and prevent memory leak
  2042. remove(invoker.fns, wrappedHook);
  2043. }
  2044. if (isUndef(oldHook)) {
  2045. // no existing hook
  2046. invoker = createFnInvoker([wrappedHook]);
  2047. } else {
  2048. /* istanbul ignore if */
  2049. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  2050. // already a merged invoker
  2051. invoker = oldHook;
  2052. invoker.fns.push(wrappedHook);
  2053. } else {
  2054. // existing plain hook
  2055. invoker = createFnInvoker([oldHook, wrappedHook]);
  2056. }
  2057. }
  2058. invoker.merged = true;
  2059. def[hookKey] = invoker;
  2060. }
  2061. /* */
  2062. function extractPropsFromVNodeData (
  2063. data,
  2064. Ctor,
  2065. tag
  2066. ) {
  2067. // we are only extracting raw values here.
  2068. // validation and default values are handled in the child
  2069. // component itself.
  2070. const propOptions = Ctor.options.props;
  2071. if (isUndef(propOptions)) {
  2072. return
  2073. }
  2074. const res = {};
  2075. const { attrs, props } = data;
  2076. if (isDef(attrs) || isDef(props)) {
  2077. for (const key in propOptions) {
  2078. const altKey = hyphenate(key);
  2079. {
  2080. const keyInLowerCase = key.toLowerCase();
  2081. if (
  2082. key !== keyInLowerCase &&
  2083. attrs && hasOwn(attrs, keyInLowerCase)
  2084. ) {
  2085. tip(
  2086. `Prop "${keyInLowerCase}" is passed to component ` +
  2087. `${formatComponentName(tag || Ctor)}, but the declared prop name is` +
  2088. ` "${key}". ` +
  2089. `Note that HTML attributes are case-insensitive and camelCased ` +
  2090. `props need to use their kebab-case equivalents when using in-DOM ` +
  2091. `templates. You should probably use "${altKey}" instead of "${key}".`
  2092. );
  2093. }
  2094. }
  2095. checkProp(res, props, key, altKey, true) ||
  2096. checkProp(res, attrs, key, altKey, false);
  2097. }
  2098. }
  2099. return res
  2100. }
  2101. function checkProp (
  2102. res,
  2103. hash,
  2104. key,
  2105. altKey,
  2106. preserve
  2107. ) {
  2108. if (isDef(hash)) {
  2109. if (hasOwn(hash, key)) {
  2110. res[key] = hash[key];
  2111. if (!preserve) {
  2112. delete hash[key];
  2113. }
  2114. return true
  2115. } else if (hasOwn(hash, altKey)) {
  2116. res[key] = hash[altKey];
  2117. if (!preserve) {
  2118. delete hash[altKey];
  2119. }
  2120. return true
  2121. }
  2122. }
  2123. return false
  2124. }
  2125. /* */
  2126. // The template compiler attempts to minimize the need for normalization by
  2127. // statically analyzing the template at compile time.
  2128. //
  2129. // For plain HTML markup, normalization can be completely skipped because the
  2130. // generated render function is guaranteed to return Array<VNode>. There are
  2131. // two cases where extra normalization is needed:
  2132. // 1. When the children contains components - because a functional component
  2133. // may return an Array instead of a single root. In this case, just a simple
  2134. // normalization is needed - if any child is an Array, we flatten the whole
  2135. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  2136. // because functional components already normalize their own children.
  2137. function simpleNormalizeChildren (children) {
  2138. for (let i = 0; i < children.length; i++) {
  2139. if (Array.isArray(children[i])) {
  2140. return Array.prototype.concat.apply([], children)
  2141. }
  2142. }
  2143. return children
  2144. }
  2145. // 2. When the children contains constructs that always generated nested Arrays,
  2146. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  2147. // with hand-written render functions / JSX. In such cases a full normalization
  2148. // is needed to cater to all possible types of children values.
  2149. function normalizeChildren (children) {
  2150. return isPrimitive(children)
  2151. ? [createTextVNode(children)]
  2152. : Array.isArray(children)
  2153. ? normalizeArrayChildren(children)
  2154. : undefined
  2155. }
  2156. function isTextNode (node) {
  2157. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  2158. }
  2159. function normalizeArrayChildren (children, nestedIndex) {
  2160. const res = [];
  2161. let i, c, lastIndex, last;
  2162. for (i = 0; i < children.length; i++) {
  2163. c = children[i];
  2164. if (isUndef(c) || typeof c === 'boolean') continue
  2165. lastIndex = res.length - 1;
  2166. last = res[lastIndex];
  2167. // nested
  2168. if (Array.isArray(c)) {
  2169. if (c.length > 0) {
  2170. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  2171. // merge adjacent text nodes
  2172. if (isTextNode(c[0]) && isTextNode(last)) {
  2173. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  2174. c.shift();
  2175. }
  2176. res.push.apply(res, c);
  2177. }
  2178. } else if (isPrimitive(c)) {
  2179. if (isTextNode(last)) {
  2180. // merge adjacent text nodes
  2181. // this is necessary for SSR hydration because text nodes are
  2182. // essentially merged when rendered to HTML strings
  2183. res[lastIndex] = createTextVNode(last.text + c);
  2184. } else if (c !== '') {
  2185. // convert primitive to vnode
  2186. res.push(createTextVNode(c));
  2187. }
  2188. } else {
  2189. if (isTextNode(c) && isTextNode(last)) {
  2190. // merge adjacent text nodes
  2191. res[lastIndex] = createTextVNode(last.text + c.text);
  2192. } else {
  2193. // default key for nested array children (likely generated by v-for)
  2194. if (isTrue(children._isVList) &&
  2195. isDef(c.tag) &&
  2196. isUndef(c.key) &&
  2197. isDef(nestedIndex)) {
  2198. c.key = `__vlist${nestedIndex}_${i}__`;
  2199. }
  2200. res.push(c);
  2201. }
  2202. }
  2203. }
  2204. return res
  2205. }
  2206. /* */
  2207. function initProvide (vm) {
  2208. const provide = vm.$options.provide;
  2209. if (provide) {
  2210. vm._provided = typeof provide === 'function'
  2211. ? provide.call(vm)
  2212. : provide;
  2213. }
  2214. }
  2215. function initInjections (vm) {
  2216. const result = resolveInject(vm.$options.inject, vm);
  2217. if (result) {
  2218. toggleObserving(false);
  2219. Object.keys(result).forEach(key => {
  2220. /* istanbul ignore else */
  2221. {
  2222. defineReactive$$1(vm, key, result[key], () => {
  2223. warn(
  2224. `Avoid mutating an injected value directly since the changes will be ` +
  2225. `overwritten whenever the provided component re-renders. ` +
  2226. `injection being mutated: "${key}"`,
  2227. vm
  2228. );
  2229. });
  2230. }
  2231. });
  2232. toggleObserving(true);
  2233. }
  2234. }
  2235. function resolveInject (inject, vm) {
  2236. if (inject) {
  2237. // inject is :any because flow is not smart enough to figure out cached
  2238. const result = Object.create(null);
  2239. const keys = hasSymbol
  2240. ? Reflect.ownKeys(inject)
  2241. : Object.keys(inject);
  2242. for (let i = 0; i < keys.length; i++) {
  2243. const key = keys[i];
  2244. // #6574 in case the inject object is observed...
  2245. if (key === '__ob__') continue
  2246. const provideKey = inject[key].from;
  2247. let source = vm;
  2248. while (source) {
  2249. if (source._provided && hasOwn(source._provided, provideKey)) {
  2250. result[key] = source._provided[provideKey];
  2251. break
  2252. }
  2253. source = source.$parent;
  2254. }
  2255. if (!source) {
  2256. if ('default' in inject[key]) {
  2257. const provideDefault = inject[key].default;
  2258. result[key] = typeof provideDefault === 'function'
  2259. ? provideDefault.call(vm)
  2260. : provideDefault;
  2261. } else {
  2262. warn(`Injection "${key}" not found`, vm);
  2263. }
  2264. }
  2265. }
  2266. return result
  2267. }
  2268. }
  2269. /* */
  2270. /**
  2271. * Runtime helper for resolving raw children VNodes into a slot object.
  2272. */
  2273. function resolveSlots (
  2274. children,
  2275. context
  2276. ) {
  2277. if (!children || !children.length) {
  2278. return {}
  2279. }
  2280. const slots = {};
  2281. for (let i = 0, l = children.length; i < l; i++) {
  2282. const child = children[i];
  2283. const data = child.data;
  2284. // remove slot attribute if the node is resolved as a Vue slot node
  2285. if (data && data.attrs && data.attrs.slot) {
  2286. delete data.attrs.slot;
  2287. }
  2288. // named slots should only be respected if the vnode was rendered in the
  2289. // same context.
  2290. if ((child.context === context || child.fnContext === context) &&
  2291. data && data.slot != null
  2292. ) {
  2293. const name = data.slot;
  2294. const slot = (slots[name] || (slots[name] = []));
  2295. if (child.tag === 'template') {
  2296. slot.push.apply(slot, child.children || []);
  2297. } else {
  2298. slot.push(child);
  2299. }
  2300. } else {
  2301. (slots.default || (slots.default = [])).push(child);
  2302. }
  2303. }
  2304. // ignore slots that contains only whitespace
  2305. for (const name in slots) {
  2306. if (slots[name].every(isWhitespace)) {
  2307. delete slots[name];
  2308. }
  2309. }
  2310. return slots
  2311. }
  2312. function isWhitespace (node) {
  2313. return (node.isComment && !node.asyncFactory) || node.text === ' '
  2314. }
  2315. /* */
  2316. function normalizeScopedSlots (
  2317. slots,
  2318. normalSlots,
  2319. prevSlots
  2320. ) {
  2321. let res;
  2322. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2323. const isStable = slots ? !!slots.$stable : !hasNormalSlots;
  2324. const key = slots && slots.$key;
  2325. if (!slots) {
  2326. res = {};
  2327. } else if (slots._normalized) {
  2328. // fast path 1: child component re-render only, parent did not change
  2329. return slots._normalized
  2330. } else if (
  2331. isStable &&
  2332. prevSlots &&
  2333. prevSlots !== emptyObject &&
  2334. key === prevSlots.$key &&
  2335. !hasNormalSlots &&
  2336. !prevSlots.$hasNormal
  2337. ) {
  2338. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2339. // only need to normalize once
  2340. return prevSlots
  2341. } else {
  2342. res = {};
  2343. for (const key in slots) {
  2344. if (slots[key] && key[0] !== '$') {
  2345. res[key] = normalizeScopedSlot(normalSlots, key, slots[key]);
  2346. }
  2347. }
  2348. }
  2349. // expose normal slots on scopedSlots
  2350. for (const key in normalSlots) {
  2351. if (!(key in res)) {
  2352. res[key] = proxyNormalSlot(normalSlots, key);
  2353. }
  2354. }
  2355. // avoriaz seems to mock a non-extensible $scopedSlots object
  2356. // and when that is passed down this would cause an error
  2357. if (slots && Object.isExtensible(slots)) {
  2358. (slots)._normalized = res;
  2359. }
  2360. def(res, '$stable', isStable);
  2361. def(res, '$key', key);
  2362. def(res, '$hasNormal', hasNormalSlots);
  2363. return res
  2364. }
  2365. function normalizeScopedSlot(normalSlots, key, fn) {
  2366. const normalized = function () {
  2367. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2368. res = res && typeof res === 'object' && !Array.isArray(res)
  2369. ? [res] // single vnode
  2370. : normalizeChildren(res);
  2371. return res && (
  2372. res.length === 0 ||
  2373. (res.length === 1 && res[0].isComment) // #9658
  2374. ) ? undefined
  2375. : res
  2376. };
  2377. // this is a slot using the new v-slot syntax without scope. although it is
  2378. // compiled as a scoped slot, render fn users would expect it to be present
  2379. // on this.$slots because the usage is semantically a normal slot.
  2380. if (fn.proxy) {
  2381. Object.defineProperty(normalSlots, key, {
  2382. get: normalized,
  2383. enumerable: true,
  2384. configurable: true
  2385. });
  2386. }
  2387. return normalized
  2388. }
  2389. function proxyNormalSlot(slots, key) {
  2390. return () => slots[key]
  2391. }
  2392. /* */
  2393. /**
  2394. * Runtime helper for rendering v-for lists.
  2395. */
  2396. function renderList (
  2397. val,
  2398. render
  2399. ) {
  2400. let ret, i, l, keys, key;
  2401. if (Array.isArray(val) || typeof val === 'string') {
  2402. ret = new Array(val.length);
  2403. for (i = 0, l = val.length; i < l; i++) {
  2404. ret[i] = render(val[i], i);
  2405. }
  2406. } else if (typeof val === 'number') {
  2407. ret = new Array(val);
  2408. for (i = 0; i < val; i++) {
  2409. ret[i] = render(i + 1, i);
  2410. }
  2411. } else if (isObject(val)) {
  2412. if (hasSymbol && val[Symbol.iterator]) {
  2413. ret = [];
  2414. const iterator = val[Symbol.iterator]();
  2415. let result = iterator.next();
  2416. while (!result.done) {
  2417. ret.push(render(result.value, ret.length));
  2418. result = iterator.next();
  2419. }
  2420. } else {
  2421. keys = Object.keys(val);
  2422. ret = new Array(keys.length);
  2423. for (i = 0, l = keys.length; i < l; i++) {
  2424. key = keys[i];
  2425. ret[i] = render(val[key], key, i);
  2426. }
  2427. }
  2428. }
  2429. if (!isDef(ret)) {
  2430. ret = [];
  2431. }
  2432. (ret)._isVList = true;
  2433. return ret
  2434. }
  2435. /* */
  2436. /**
  2437. * Runtime helper for rendering <slot>
  2438. */
  2439. function renderSlot (
  2440. name,
  2441. fallback,
  2442. props,
  2443. bindObject
  2444. ) {
  2445. const scopedSlotFn = this.$scopedSlots[name];
  2446. let nodes;
  2447. if (scopedSlotFn) { // scoped slot
  2448. props = props || {};
  2449. if (bindObject) {
  2450. if (!isObject(bindObject)) {
  2451. warn(
  2452. 'slot v-bind without argument expects an Object',
  2453. this
  2454. );
  2455. }
  2456. props = extend(extend({}, bindObject), props);
  2457. }
  2458. nodes = scopedSlotFn(props) || fallback;
  2459. } else {
  2460. nodes = this.$slots[name] || fallback;
  2461. }
  2462. const target = props && props.slot;
  2463. if (target) {
  2464. return this.$createElement('template', { slot: target }, nodes)
  2465. } else {
  2466. return nodes
  2467. }
  2468. }
  2469. /* */
  2470. /**
  2471. * Runtime helper for resolving filters
  2472. */
  2473. function resolveFilter (id) {
  2474. return resolveAsset(this.$options, 'filters', id, true) || identity
  2475. }
  2476. /* */
  2477. function isKeyNotMatch (expect, actual) {
  2478. if (Array.isArray(expect)) {
  2479. return expect.indexOf(actual) === -1
  2480. } else {
  2481. return expect !== actual
  2482. }
  2483. }
  2484. /**
  2485. * Runtime helper for checking keyCodes from config.
  2486. * exposed as Vue.prototype._k
  2487. * passing in eventKeyName as last argument separately for backwards compat
  2488. */
  2489. function checkKeyCodes (
  2490. eventKeyCode,
  2491. key,
  2492. builtInKeyCode,
  2493. eventKeyName,
  2494. builtInKeyName
  2495. ) {
  2496. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  2497. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  2498. return isKeyNotMatch(builtInKeyName, eventKeyName)
  2499. } else if (mappedKeyCode) {
  2500. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  2501. } else if (eventKeyName) {
  2502. return hyphenate(eventKeyName) !== key
  2503. }
  2504. }
  2505. /* */
  2506. /**
  2507. * Runtime helper for merging v-bind="object" into a VNode's data.
  2508. */
  2509. function bindObjectProps (
  2510. data,
  2511. tag,
  2512. value,
  2513. asProp,
  2514. isSync
  2515. ) {
  2516. if (value) {
  2517. if (!isObject(value)) {
  2518. warn(
  2519. 'v-bind without argument expects an Object or Array value',
  2520. this
  2521. );
  2522. } else {
  2523. if (Array.isArray(value)) {
  2524. value = toObject(value);
  2525. }
  2526. let hash;
  2527. for (const key in value) {
  2528. if (
  2529. key === 'class' ||
  2530. key === 'style' ||
  2531. isReservedAttribute(key)
  2532. ) {
  2533. hash = data;
  2534. } else {
  2535. const type = data.attrs && data.attrs.type;
  2536. hash = asProp || config.mustUseProp(tag, type, key)
  2537. ? data.domProps || (data.domProps = {})
  2538. : data.attrs || (data.attrs = {});
  2539. }
  2540. const camelizedKey = camelize(key);
  2541. const hyphenatedKey = hyphenate(key);
  2542. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  2543. hash[key] = value[key];
  2544. if (isSync) {
  2545. const on = data.on || (data.on = {});
  2546. on[`update:${key}`] = function ($event) {
  2547. value[key] = $event;
  2548. };
  2549. }
  2550. }
  2551. }
  2552. }
  2553. }
  2554. return data
  2555. }
  2556. /* */
  2557. /**
  2558. * Runtime helper for rendering static trees.
  2559. */
  2560. function renderStatic (
  2561. index,
  2562. isInFor
  2563. ) {
  2564. const cached = this._staticTrees || (this._staticTrees = []);
  2565. let tree = cached[index];
  2566. // if has already-rendered static tree and not inside v-for,
  2567. // we can reuse the same tree.
  2568. if (tree && !isInFor) {
  2569. return tree
  2570. }
  2571. // otherwise, render a fresh tree.
  2572. tree = cached[index] = this.$options.staticRenderFns[index].call(
  2573. this._renderProxy,
  2574. null,
  2575. this // for render fns generated for functional component templates
  2576. );
  2577. markStatic(tree, `__static__${index}`, false);
  2578. return tree
  2579. }
  2580. /**
  2581. * Runtime helper for v-once.
  2582. * Effectively it means marking the node as static with a unique key.
  2583. */
  2584. function markOnce (
  2585. tree,
  2586. index,
  2587. key
  2588. ) {
  2589. markStatic(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  2590. return tree
  2591. }
  2592. function markStatic (
  2593. tree,
  2594. key,
  2595. isOnce
  2596. ) {
  2597. if (Array.isArray(tree)) {
  2598. for (let i = 0; i < tree.length; i++) {
  2599. if (tree[i] && typeof tree[i] !== 'string') {
  2600. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  2601. }
  2602. }
  2603. } else {
  2604. markStaticNode(tree, key, isOnce);
  2605. }
  2606. }
  2607. function markStaticNode (node, key, isOnce) {
  2608. node.isStatic = true;
  2609. node.key = key;
  2610. node.isOnce = isOnce;
  2611. }
  2612. /* */
  2613. function bindObjectListeners (data, value) {
  2614. if (value) {
  2615. if (!isPlainObject(value)) {
  2616. warn(
  2617. 'v-on without argument expects an Object value',
  2618. this
  2619. );
  2620. } else {
  2621. const on = data.on = data.on ? extend({}, data.on) : {};
  2622. for (const key in value) {
  2623. const existing = on[key];
  2624. const ours = value[key];
  2625. on[key] = existing ? [].concat(existing, ours) : ours;
  2626. }
  2627. }
  2628. }
  2629. return data
  2630. }
  2631. /* */
  2632. function resolveScopedSlots (
  2633. fns, // see flow/vnode
  2634. res,
  2635. // the following are added in 2.6
  2636. hasDynamicKeys,
  2637. contentHashKey
  2638. ) {
  2639. res = res || { $stable: !hasDynamicKeys };
  2640. for (let i = 0; i < fns.length; i++) {
  2641. const slot = fns[i];
  2642. if (Array.isArray(slot)) {
  2643. resolveScopedSlots(slot, res, hasDynamicKeys);
  2644. } else if (slot) {
  2645. // marker for reverse proxying v-slot without scope on this.$slots
  2646. if (slot.proxy) {
  2647. slot.fn.proxy = true;
  2648. }
  2649. res[slot.key] = slot.fn;
  2650. }
  2651. }
  2652. if (contentHashKey) {
  2653. (res).$key = contentHashKey;
  2654. }
  2655. return res
  2656. }
  2657. /* */
  2658. function bindDynamicKeys (baseObj, values) {
  2659. for (let i = 0; i < values.length; i += 2) {
  2660. const key = values[i];
  2661. if (typeof key === 'string' && key) {
  2662. baseObj[values[i]] = values[i + 1];
  2663. } else if (key !== '' && key !== null) {
  2664. // null is a special value for explicitly removing a binding
  2665. warn(
  2666. `Invalid value for dynamic directive argument (expected string or null): ${key}`,
  2667. this
  2668. );
  2669. }
  2670. }
  2671. return baseObj
  2672. }
  2673. // helper to dynamically append modifier runtime markers to event names.
  2674. // ensure only append when value is already string, otherwise it will be cast
  2675. // to string and cause the type check to miss.
  2676. function prependModifier (value, symbol) {
  2677. return typeof value === 'string' ? symbol + value : value
  2678. }
  2679. /* */
  2680. function installRenderHelpers (target) {
  2681. target._o = markOnce;
  2682. target._n = toNumber;
  2683. target._s = toString;
  2684. target._l = renderList;
  2685. target._t = renderSlot;
  2686. target._q = looseEqual;
  2687. target._i = looseIndexOf;
  2688. target._m = renderStatic;
  2689. target._f = resolveFilter;
  2690. target._k = checkKeyCodes;
  2691. target._b = bindObjectProps;
  2692. target._v = createTextVNode;
  2693. target._e = createEmptyVNode;
  2694. target._u = resolveScopedSlots;
  2695. target._g = bindObjectListeners;
  2696. target._d = bindDynamicKeys;
  2697. target._p = prependModifier;
  2698. }
  2699. /* */
  2700. function FunctionalRenderContext (
  2701. data,
  2702. props,
  2703. children,
  2704. parent,
  2705. Ctor
  2706. ) {
  2707. const options = Ctor.options;
  2708. // ensure the createElement function in functional components
  2709. // gets a unique context - this is necessary for correct named slot check
  2710. let contextVm;
  2711. if (hasOwn(parent, '_uid')) {
  2712. contextVm = Object.create(parent);
  2713. // $flow-disable-line
  2714. contextVm._original = parent;
  2715. } else {
  2716. // the context vm passed in is a functional context as well.
  2717. // in this case we want to make sure we are able to get a hold to the
  2718. // real context instance.
  2719. contextVm = parent;
  2720. // $flow-disable-line
  2721. parent = parent._original;
  2722. }
  2723. const isCompiled = isTrue(options._compiled);
  2724. const needNormalization = !isCompiled;
  2725. this.data = data;
  2726. this.props = props;
  2727. this.children = children;
  2728. this.parent = parent;
  2729. this.listeners = data.on || emptyObject;
  2730. this.injections = resolveInject(options.inject, parent);
  2731. this.slots = () => {
  2732. if (!this.$slots) {
  2733. normalizeScopedSlots(
  2734. data.scopedSlots,
  2735. this.$slots = resolveSlots(children, parent)
  2736. );
  2737. }
  2738. return this.$slots
  2739. };
  2740. Object.defineProperty(this, 'scopedSlots', ({
  2741. enumerable: true,
  2742. get () {
  2743. return normalizeScopedSlots(data.scopedSlots, this.slots())
  2744. }
  2745. }));
  2746. // support for compiled functional template
  2747. if (isCompiled) {
  2748. // exposing $options for renderStatic()
  2749. this.$options = options;
  2750. // pre-resolve slots for renderSlot()
  2751. this.$slots = this.slots();
  2752. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  2753. }
  2754. if (options._scopeId) {
  2755. this._c = (a, b, c, d) => {
  2756. const vnode = createElement(contextVm, a, b, c, d, needNormalization);
  2757. if (vnode && !Array.isArray(vnode)) {
  2758. vnode.fnScopeId = options._scopeId;
  2759. vnode.fnContext = parent;
  2760. }
  2761. return vnode
  2762. };
  2763. } else {
  2764. this._c = (a, b, c, d) => createElement(contextVm, a, b, c, d, needNormalization);
  2765. }
  2766. }
  2767. installRenderHelpers(FunctionalRenderContext.prototype);
  2768. function createFunctionalComponent (
  2769. Ctor,
  2770. propsData,
  2771. data,
  2772. contextVm,
  2773. children
  2774. ) {
  2775. const options = Ctor.options;
  2776. const props = {};
  2777. const propOptions = options.props;
  2778. if (isDef(propOptions)) {
  2779. for (const key in propOptions) {
  2780. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  2781. }
  2782. } else {
  2783. if (isDef(data.attrs)) mergeProps(props, data.attrs);
  2784. if (isDef(data.props)) mergeProps(props, data.props);
  2785. }
  2786. const renderContext = new FunctionalRenderContext(
  2787. data,
  2788. props,
  2789. children,
  2790. contextVm,
  2791. Ctor
  2792. );
  2793. const vnode = options.render.call(null, renderContext._c, renderContext);
  2794. if (vnode instanceof VNode) {
  2795. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  2796. } else if (Array.isArray(vnode)) {
  2797. const vnodes = normalizeChildren(vnode) || [];
  2798. const res = new Array(vnodes.length);
  2799. for (let i = 0; i < vnodes.length; i++) {
  2800. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  2801. }
  2802. return res
  2803. }
  2804. }
  2805. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  2806. // #7817 clone node before setting fnContext, otherwise if the node is reused
  2807. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  2808. // that should not be matched to match.
  2809. const clone = cloneVNode(vnode);
  2810. clone.fnContext = contextVm;
  2811. clone.fnOptions = options;
  2812. {
  2813. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  2814. }
  2815. if (data.slot) {
  2816. (clone.data || (clone.data = {})).slot = data.slot;
  2817. }
  2818. return clone
  2819. }
  2820. function mergeProps (to, from) {
  2821. for (const key in from) {
  2822. to[camelize(key)] = from[key];
  2823. }
  2824. }
  2825. /* */
  2826. /* */
  2827. /* */
  2828. /* */
  2829. // inline hooks to be invoked on component VNodes during patch
  2830. const componentVNodeHooks = {
  2831. init (vnode, hydrating) {
  2832. if (
  2833. vnode.componentInstance &&
  2834. !vnode.componentInstance._isDestroyed &&
  2835. vnode.data.keepAlive
  2836. ) {
  2837. // kept-alive components, treat as a patch
  2838. const mountedNode = vnode; // work around flow
  2839. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  2840. } else {
  2841. const child = vnode.componentInstance = createComponentInstanceForVnode(
  2842. vnode,
  2843. activeInstance
  2844. );
  2845. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  2846. }
  2847. },
  2848. prepatch (oldVnode, vnode) {
  2849. const options = vnode.componentOptions;
  2850. const child = vnode.componentInstance = oldVnode.componentInstance;
  2851. updateChildComponent(
  2852. child,
  2853. options.propsData, // updated props
  2854. options.listeners, // updated listeners
  2855. vnode, // new parent vnode
  2856. options.children // new children
  2857. );
  2858. },
  2859. insert (vnode) {
  2860. const { context, componentInstance } = vnode;
  2861. if (!componentInstance._isMounted) {
  2862. componentInstance._isMounted = true;
  2863. callHook(componentInstance, 'mounted');
  2864. }
  2865. if (vnode.data.keepAlive) {
  2866. if (context._isMounted) {
  2867. // vue-router#1212
  2868. // During updates, a kept-alive component's child components may
  2869. // change, so directly walking the tree here may call activated hooks
  2870. // on incorrect children. Instead we push them into a queue which will
  2871. // be processed after the whole patch process ended.
  2872. queueActivatedComponent(componentInstance);
  2873. } else {
  2874. activateChildComponent(componentInstance, true /* direct */);
  2875. }
  2876. }
  2877. },
  2878. destroy (vnode) {
  2879. const { componentInstance } = vnode;
  2880. if (!componentInstance._isDestroyed) {
  2881. if (!vnode.data.keepAlive) {
  2882. componentInstance.$destroy();
  2883. } else {
  2884. deactivateChildComponent(componentInstance, true /* direct */);
  2885. }
  2886. }
  2887. }
  2888. };
  2889. const hooksToMerge = Object.keys(componentVNodeHooks);
  2890. function createComponent (
  2891. Ctor,
  2892. data,
  2893. context,
  2894. children,
  2895. tag
  2896. ) {
  2897. if (isUndef(Ctor)) {
  2898. return
  2899. }
  2900. const baseCtor = context.$options._base;
  2901. // plain options object: turn it into a constructor
  2902. if (isObject(Ctor)) {
  2903. Ctor = baseCtor.extend(Ctor);
  2904. }
  2905. // if at this stage it's not a constructor or an async component factory,
  2906. // reject.
  2907. if (typeof Ctor !== 'function') {
  2908. {
  2909. warn(`Invalid Component definition: ${String(Ctor)}`, context);
  2910. }
  2911. return
  2912. }
  2913. // async component
  2914. let asyncFactory;
  2915. if (isUndef(Ctor.cid)) {
  2916. asyncFactory = Ctor;
  2917. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  2918. if (Ctor === undefined) {
  2919. // return a placeholder node for async component, which is rendered
  2920. // as a comment node but preserves all the raw information for the node.
  2921. // the information will be used for async server-rendering and hydration.
  2922. return createAsyncPlaceholder(
  2923. asyncFactory,
  2924. data,
  2925. context,
  2926. children,
  2927. tag
  2928. )
  2929. }
  2930. }
  2931. data = data || {};
  2932. // resolve constructor options in case global mixins are applied after
  2933. // component constructor creation
  2934. resolveConstructorOptions(Ctor);
  2935. // transform component v-model data into props & events
  2936. if (isDef(data.model)) {
  2937. transformModel(Ctor.options, data);
  2938. }
  2939. // extract props
  2940. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  2941. // functional component
  2942. if (isTrue(Ctor.options.functional)) {
  2943. return createFunctionalComponent(Ctor, propsData, data, context, children)
  2944. }
  2945. // extract listeners, since these needs to be treated as
  2946. // child component listeners instead of DOM listeners
  2947. const listeners = data.on;
  2948. // replace with listeners with .native modifier
  2949. // so it gets processed during parent component patch.
  2950. data.on = data.nativeOn;
  2951. if (isTrue(Ctor.options.abstract)) {
  2952. // abstract components do not keep anything
  2953. // other than props & listeners & slot
  2954. // work around flow
  2955. const slot = data.slot;
  2956. data = {};
  2957. if (slot) {
  2958. data.slot = slot;
  2959. }
  2960. }
  2961. // install component management hooks onto the placeholder node
  2962. installComponentHooks(data);
  2963. // return a placeholder vnode
  2964. const name = Ctor.options.name || tag;
  2965. const vnode = new VNode(
  2966. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`,
  2967. data, undefined, undefined, undefined, context,
  2968. { Ctor, propsData, listeners, tag, children },
  2969. asyncFactory
  2970. );
  2971. return vnode
  2972. }
  2973. function createComponentInstanceForVnode (
  2974. vnode, // we know it's MountedComponentVNode but flow doesn't
  2975. parent, // activeInstance in lifecycle state
  2976. ) {
  2977. const options = {
  2978. _isComponent: true,
  2979. _parentVnode: vnode,
  2980. parent
  2981. };
  2982. // check inline-template render functions
  2983. const inlineTemplate = vnode.data.inlineTemplate;
  2984. if (isDef(inlineTemplate)) {
  2985. options.render = inlineTemplate.render;
  2986. options.staticRenderFns = inlineTemplate.staticRenderFns;
  2987. }
  2988. return new vnode.componentOptions.Ctor(options)
  2989. }
  2990. function installComponentHooks (data) {
  2991. const hooks = data.hook || (data.hook = {});
  2992. for (let i = 0; i < hooksToMerge.length; i++) {
  2993. const key = hooksToMerge[i];
  2994. const existing = hooks[key];
  2995. const toMerge = componentVNodeHooks[key];
  2996. if (existing !== toMerge && !(existing && existing._merged)) {
  2997. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  2998. }
  2999. }
  3000. }
  3001. function mergeHook$1 (f1, f2) {
  3002. const merged = (a, b) => {
  3003. // flow complains about extra args which is why we use any
  3004. f1(a, b);
  3005. f2(a, b);
  3006. };
  3007. merged._merged = true;
  3008. return merged
  3009. }
  3010. // transform component v-model info (value and callback) into
  3011. // prop and event handler respectively.
  3012. function transformModel (options, data) {
  3013. const prop = (options.model && options.model.prop) || 'value';
  3014. const event = (options.model && options.model.event) || 'input'
  3015. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  3016. const on = data.on || (data.on = {});
  3017. const existing = on[event];
  3018. const callback = data.model.callback;
  3019. if (isDef(existing)) {
  3020. if (
  3021. Array.isArray(existing)
  3022. ? existing.indexOf(callback) === -1
  3023. : existing !== callback
  3024. ) {
  3025. on[event] = [callback].concat(existing);
  3026. }
  3027. } else {
  3028. on[event] = callback;
  3029. }
  3030. }
  3031. /* */
  3032. const SIMPLE_NORMALIZE = 1;
  3033. const ALWAYS_NORMALIZE = 2;
  3034. // wrapper function for providing a more flexible interface
  3035. // without getting yelled at by flow
  3036. function createElement (
  3037. context,
  3038. tag,
  3039. data,
  3040. children,
  3041. normalizationType,
  3042. alwaysNormalize
  3043. ) {
  3044. if (Array.isArray(data) || isPrimitive(data)) {
  3045. normalizationType = children;
  3046. children = data;
  3047. data = undefined;
  3048. }
  3049. if (isTrue(alwaysNormalize)) {
  3050. normalizationType = ALWAYS_NORMALIZE;
  3051. }
  3052. return _createElement(context, tag, data, children, normalizationType)
  3053. }
  3054. function _createElement (
  3055. context,
  3056. tag,
  3057. data,
  3058. children,
  3059. normalizationType
  3060. ) {
  3061. if (isDef(data) && isDef((data).__ob__)) {
  3062. warn(
  3063. `Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` +
  3064. 'Always create fresh vnode data objects in each render!',
  3065. context
  3066. );
  3067. return createEmptyVNode()
  3068. }
  3069. // object syntax in v-bind
  3070. if (isDef(data) && isDef(data.is)) {
  3071. tag = data.is;
  3072. }
  3073. if (!tag) {
  3074. // in case of component :is set to falsy value
  3075. return createEmptyVNode()
  3076. }
  3077. // warn against non-primitive key
  3078. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  3079. ) {
  3080. {
  3081. warn(
  3082. 'Avoid using non-primitive value as key, ' +
  3083. 'use string/number value instead.',
  3084. context
  3085. );
  3086. }
  3087. }
  3088. // support single function children as default scoped slot
  3089. if (Array.isArray(children) &&
  3090. typeof children[0] === 'function'
  3091. ) {
  3092. data = data || {};
  3093. data.scopedSlots = { default: children[0] };
  3094. children.length = 0;
  3095. }
  3096. if (normalizationType === ALWAYS_NORMALIZE) {
  3097. children = normalizeChildren(children);
  3098. } else if (normalizationType === SIMPLE_NORMALIZE) {
  3099. children = simpleNormalizeChildren(children);
  3100. }
  3101. let vnode, ns;
  3102. if (typeof tag === 'string') {
  3103. let Ctor;
  3104. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  3105. if (config.isReservedTag(tag)) {
  3106. // platform built-in elements
  3107. if (isDef(data) && isDef(data.nativeOn)) {
  3108. warn(
  3109. `The .native modifier for v-on is only valid on components but it was used on <${tag}>.`,
  3110. context
  3111. );
  3112. }
  3113. vnode = new VNode(
  3114. config.parsePlatformTagName(tag), data, children,
  3115. undefined, undefined, context
  3116. );
  3117. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  3118. // component
  3119. vnode = createComponent(Ctor, data, context, children, tag);
  3120. } else {
  3121. // unknown or unlisted namespaced elements
  3122. // check at runtime because it may get assigned a namespace when its
  3123. // parent normalizes children
  3124. vnode = new VNode(
  3125. tag, data, children,
  3126. undefined, undefined, context
  3127. );
  3128. }
  3129. } else {
  3130. // direct component options / constructor
  3131. vnode = createComponent(tag, data, context, children);
  3132. }
  3133. if (Array.isArray(vnode)) {
  3134. return vnode
  3135. } else if (isDef(vnode)) {
  3136. if (isDef(ns)) applyNS(vnode, ns);
  3137. if (isDef(data)) registerDeepBindings(data);
  3138. return vnode
  3139. } else {
  3140. return createEmptyVNode()
  3141. }
  3142. }
  3143. function applyNS (vnode, ns, force) {
  3144. vnode.ns = ns;
  3145. if (vnode.tag === 'foreignObject') {
  3146. // use default namespace inside foreignObject
  3147. ns = undefined;
  3148. force = true;
  3149. }
  3150. if (isDef(vnode.children)) {
  3151. for (let i = 0, l = vnode.children.length; i < l; i++) {
  3152. const child = vnode.children[i];
  3153. if (isDef(child.tag) && (
  3154. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  3155. applyNS(child, ns, force);
  3156. }
  3157. }
  3158. }
  3159. }
  3160. // ref #5318
  3161. // necessary to ensure parent re-render when deep bindings like :style and
  3162. // :class are used on slot nodes
  3163. function registerDeepBindings (data) {
  3164. if (isObject(data.style)) {
  3165. traverse(data.style);
  3166. }
  3167. if (isObject(data.class)) {
  3168. traverse(data.class);
  3169. }
  3170. }
  3171. /* */
  3172. function initRender (vm) {
  3173. vm._vnode = null; // the root of the child tree
  3174. vm._staticTrees = null; // v-once cached trees
  3175. const options = vm.$options;
  3176. const parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  3177. const renderContext = parentVnode && parentVnode.context;
  3178. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  3179. vm.$scopedSlots = emptyObject;
  3180. // bind the createElement fn to this instance
  3181. // so that we get proper render context inside it.
  3182. // args order: tag, data, children, normalizationType, alwaysNormalize
  3183. // internal version is used by render functions compiled from templates
  3184. vm._c = (a, b, c, d) => createElement(vm, a, b, c, d, false);
  3185. // normalization is always applied for the public version, used in
  3186. // user-written render functions.
  3187. vm.$createElement = (a, b, c, d) => createElement(vm, a, b, c, d, true);
  3188. // $attrs & $listeners are exposed for easier HOC creation.
  3189. // they need to be reactive so that HOCs using them are always updated
  3190. const parentData = parentVnode && parentVnode.data;
  3191. /* istanbul ignore else */
  3192. {
  3193. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, () => {
  3194. !isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
  3195. }, true);
  3196. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, () => {
  3197. !isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
  3198. }, true);
  3199. }
  3200. }
  3201. let currentRenderingInstance = null;
  3202. function renderMixin (Vue) {
  3203. // install runtime convenience helpers
  3204. installRenderHelpers(Vue.prototype);
  3205. Vue.prototype.$nextTick = function (fn) {
  3206. return nextTick(fn, this)
  3207. };
  3208. Vue.prototype._render = function () {
  3209. const vm = this;
  3210. const { render, _parentVnode } = vm.$options;
  3211. if (_parentVnode) {
  3212. vm.$scopedSlots = normalizeScopedSlots(
  3213. _parentVnode.data.scopedSlots,
  3214. vm.$slots,
  3215. vm.$scopedSlots
  3216. );
  3217. }
  3218. // set parent vnode. this allows render functions to have access
  3219. // to the data on the placeholder node.
  3220. vm.$vnode = _parentVnode;
  3221. // render self
  3222. let vnode;
  3223. try {
  3224. // There's no need to maintain a stack because all render fns are called
  3225. // separately from one another. Nested component's render fns are called
  3226. // when parent component is patched.
  3227. currentRenderingInstance = vm;
  3228. vnode = render.call(vm._renderProxy, vm.$createElement);
  3229. } catch (e) {
  3230. handleError(e, vm, `render`);
  3231. // return error render result,
  3232. // or previous vnode to prevent render error causing blank component
  3233. /* istanbul ignore else */
  3234. if (vm.$options.renderError) {
  3235. try {
  3236. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  3237. } catch (e) {
  3238. handleError(e, vm, `renderError`);
  3239. vnode = vm._vnode;
  3240. }
  3241. } else {
  3242. vnode = vm._vnode;
  3243. }
  3244. } finally {
  3245. currentRenderingInstance = null;
  3246. }
  3247. // if the returned array contains only a single node, allow it
  3248. if (Array.isArray(vnode) && vnode.length === 1) {
  3249. vnode = vnode[0];
  3250. }
  3251. // return empty vnode in case the render function errored out
  3252. if (!(vnode instanceof VNode)) {
  3253. if (Array.isArray(vnode)) {
  3254. warn(
  3255. 'Multiple root nodes returned from render function. Render function ' +
  3256. 'should return a single root node.',
  3257. vm
  3258. );
  3259. }
  3260. vnode = createEmptyVNode();
  3261. }
  3262. // set parent
  3263. vnode.parent = _parentVnode;
  3264. return vnode
  3265. };
  3266. }
  3267. /* */
  3268. function ensureCtor (comp, base) {
  3269. if (
  3270. comp.__esModule ||
  3271. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  3272. ) {
  3273. comp = comp.default;
  3274. }
  3275. return isObject(comp)
  3276. ? base.extend(comp)
  3277. : comp
  3278. }
  3279. function createAsyncPlaceholder (
  3280. factory,
  3281. data,
  3282. context,
  3283. children,
  3284. tag
  3285. ) {
  3286. const node = createEmptyVNode();
  3287. node.asyncFactory = factory;
  3288. node.asyncMeta = { data, context, children, tag };
  3289. return node
  3290. }
  3291. function resolveAsyncComponent (
  3292. factory,
  3293. baseCtor
  3294. ) {
  3295. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  3296. return factory.errorComp
  3297. }
  3298. if (isDef(factory.resolved)) {
  3299. return factory.resolved
  3300. }
  3301. const owner = currentRenderingInstance;
  3302. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  3303. // already pending
  3304. factory.owners.push(owner);
  3305. }
  3306. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  3307. return factory.loadingComp
  3308. }
  3309. if (owner && !isDef(factory.owners)) {
  3310. const owners = factory.owners = [owner];
  3311. let sync = true;
  3312. let timerLoading = null;
  3313. let timerTimeout = null
  3314. ;(owner).$on('hook:destroyed', () => remove(owners, owner));
  3315. const forceRender = (renderCompleted) => {
  3316. for (let i = 0, l = owners.length; i < l; i++) {
  3317. (owners[i]).$forceUpdate();
  3318. }
  3319. if (renderCompleted) {
  3320. owners.length = 0;
  3321. if (timerLoading !== null) {
  3322. clearTimeout(timerLoading);
  3323. timerLoading = null;
  3324. }
  3325. if (timerTimeout !== null) {
  3326. clearTimeout(timerTimeout);
  3327. timerTimeout = null;
  3328. }
  3329. }
  3330. };
  3331. const resolve = once((res) => {
  3332. // cache resolved
  3333. factory.resolved = ensureCtor(res, baseCtor);
  3334. // invoke callbacks only if this is not a synchronous resolve
  3335. // (async resolves are shimmed as synchronous during SSR)
  3336. if (!sync) {
  3337. forceRender(true);
  3338. } else {
  3339. owners.length = 0;
  3340. }
  3341. });
  3342. const reject = once(reason => {
  3343. warn(
  3344. `Failed to resolve async component: ${String(factory)}` +
  3345. (reason ? `\nReason: ${reason}` : '')
  3346. );
  3347. if (isDef(factory.errorComp)) {
  3348. factory.error = true;
  3349. forceRender(true);
  3350. }
  3351. });
  3352. const res = factory(resolve, reject);
  3353. if (isObject(res)) {
  3354. if (isPromise(res)) {
  3355. // () => Promise
  3356. if (isUndef(factory.resolved)) {
  3357. res.then(resolve, reject);
  3358. }
  3359. } else if (isPromise(res.component)) {
  3360. res.component.then(resolve, reject);
  3361. if (isDef(res.error)) {
  3362. factory.errorComp = ensureCtor(res.error, baseCtor);
  3363. }
  3364. if (isDef(res.loading)) {
  3365. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  3366. if (res.delay === 0) {
  3367. factory.loading = true;
  3368. } else {
  3369. timerLoading = setTimeout(() => {
  3370. timerLoading = null;
  3371. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  3372. factory.loading = true;
  3373. forceRender(false);
  3374. }
  3375. }, res.delay || 200);
  3376. }
  3377. }
  3378. if (isDef(res.timeout)) {
  3379. timerTimeout = setTimeout(() => {
  3380. timerTimeout = null;
  3381. if (isUndef(factory.resolved)) {
  3382. reject(
  3383. `timeout (${res.timeout}ms)`
  3384. );
  3385. }
  3386. }, res.timeout);
  3387. }
  3388. }
  3389. }
  3390. sync = false;
  3391. // return in case resolved synchronously
  3392. return factory.loading
  3393. ? factory.loadingComp
  3394. : factory.resolved
  3395. }
  3396. }
  3397. /* */
  3398. function isAsyncPlaceholder (node) {
  3399. return node.isComment && node.asyncFactory
  3400. }
  3401. /* */
  3402. function getFirstComponentChild (children) {
  3403. if (Array.isArray(children)) {
  3404. for (let i = 0; i < children.length; i++) {
  3405. const c = children[i];
  3406. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  3407. return c
  3408. }
  3409. }
  3410. }
  3411. }
  3412. /* */
  3413. /* */
  3414. function initEvents (vm) {
  3415. vm._events = Object.create(null);
  3416. vm._hasHookEvent = false;
  3417. // init parent attached events
  3418. const listeners = vm.$options._parentListeners;
  3419. if (listeners) {
  3420. updateComponentListeners(vm, listeners);
  3421. }
  3422. }
  3423. let target;
  3424. function add (event, fn) {
  3425. target.$on(event, fn);
  3426. }
  3427. function remove$1 (event, fn) {
  3428. target.$off(event, fn);
  3429. }
  3430. function createOnceHandler (event, fn) {
  3431. const _target = target;
  3432. return function onceHandler () {
  3433. const res = fn.apply(null, arguments);
  3434. if (res !== null) {
  3435. _target.$off(event, onceHandler);
  3436. }
  3437. }
  3438. }
  3439. function updateComponentListeners (
  3440. vm,
  3441. listeners,
  3442. oldListeners
  3443. ) {
  3444. target = vm;
  3445. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  3446. target = undefined;
  3447. }
  3448. function eventsMixin (Vue) {
  3449. const hookRE = /^hook:/;
  3450. Vue.prototype.$on = function (event, fn) {
  3451. const vm = this;
  3452. if (Array.isArray(event)) {
  3453. for (let i = 0, l = event.length; i < l; i++) {
  3454. vm.$on(event[i], fn);
  3455. }
  3456. } else {
  3457. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3458. // optimize hook:event cost by using a boolean flag marked at registration
  3459. // instead of a hash lookup
  3460. if (hookRE.test(event)) {
  3461. vm._hasHookEvent = true;
  3462. }
  3463. }
  3464. return vm
  3465. };
  3466. Vue.prototype.$once = function (event, fn) {
  3467. const vm = this;
  3468. function on () {
  3469. vm.$off(event, on);
  3470. fn.apply(vm, arguments);
  3471. }
  3472. on.fn = fn;
  3473. vm.$on(event, on);
  3474. return vm
  3475. };
  3476. Vue.prototype.$off = function (event, fn) {
  3477. const vm = this;
  3478. // all
  3479. if (!arguments.length) {
  3480. vm._events = Object.create(null);
  3481. return vm
  3482. }
  3483. // array of events
  3484. if (Array.isArray(event)) {
  3485. for (let i = 0, l = event.length; i < l; i++) {
  3486. vm.$off(event[i], fn);
  3487. }
  3488. return vm
  3489. }
  3490. // specific event
  3491. const cbs = vm._events[event];
  3492. if (!cbs) {
  3493. return vm
  3494. }
  3495. if (!fn) {
  3496. vm._events[event] = null;
  3497. return vm
  3498. }
  3499. // specific handler
  3500. let cb;
  3501. let i = cbs.length;
  3502. while (i--) {
  3503. cb = cbs[i];
  3504. if (cb === fn || cb.fn === fn) {
  3505. cbs.splice(i, 1);
  3506. break
  3507. }
  3508. }
  3509. return vm
  3510. };
  3511. Vue.prototype.$emit = function (event) {
  3512. const vm = this;
  3513. {
  3514. const lowerCaseEvent = event.toLowerCase();
  3515. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3516. tip(
  3517. `Event "${lowerCaseEvent}" is emitted in component ` +
  3518. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  3519. `Note that HTML attributes are case-insensitive and you cannot use ` +
  3520. `v-on to listen to camelCase events when using in-DOM templates. ` +
  3521. `You should probably use "${hyphenate(event)}" instead of "${event}".`
  3522. );
  3523. }
  3524. }
  3525. let cbs = vm._events[event];
  3526. if (cbs) {
  3527. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3528. const args = toArray(arguments, 1);
  3529. const info = `event handler for "${event}"`;
  3530. for (let i = 0, l = cbs.length; i < l; i++) {
  3531. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3532. }
  3533. }
  3534. return vm
  3535. };
  3536. }
  3537. /* */
  3538. let activeInstance = null;
  3539. let isUpdatingChildComponent = false;
  3540. function setActiveInstance(vm) {
  3541. const prevActiveInstance = activeInstance;
  3542. activeInstance = vm;
  3543. return () => {
  3544. activeInstance = prevActiveInstance;
  3545. }
  3546. }
  3547. function initLifecycle (vm) {
  3548. const options = vm.$options;
  3549. // locate first non-abstract parent
  3550. let parent = options.parent;
  3551. if (parent && !options.abstract) {
  3552. while (parent.$options.abstract && parent.$parent) {
  3553. parent = parent.$parent;
  3554. }
  3555. parent.$children.push(vm);
  3556. }
  3557. vm.$parent = parent;
  3558. vm.$root = parent ? parent.$root : vm;
  3559. vm.$children = [];
  3560. vm.$refs = {};
  3561. vm._watcher = null;
  3562. vm._inactive = null;
  3563. vm._directInactive = false;
  3564. vm._isMounted = false;
  3565. vm._isDestroyed = false;
  3566. vm._isBeingDestroyed = false;
  3567. }
  3568. function lifecycleMixin (Vue) {
  3569. Vue.prototype._update = function (vnode, hydrating) {
  3570. const vm = this;
  3571. const prevEl = vm.$el;
  3572. const prevVnode = vm._vnode;
  3573. const restoreActiveInstance = setActiveInstance(vm);
  3574. vm._vnode = vnode;
  3575. // Vue.prototype.__patch__ is injected in entry points
  3576. // based on the rendering backend used.
  3577. if (!prevVnode) {
  3578. // initial render
  3579. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3580. } else {
  3581. // updates
  3582. vm.$el = vm.__patch__(prevVnode, vnode);
  3583. }
  3584. restoreActiveInstance();
  3585. // update __vue__ reference
  3586. if (prevEl) {
  3587. prevEl.__vue__ = null;
  3588. }
  3589. if (vm.$el) {
  3590. vm.$el.__vue__ = vm;
  3591. }
  3592. // if parent is an HOC, update its $el as well
  3593. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  3594. vm.$parent.$el = vm.$el;
  3595. }
  3596. // updated hook is called by the scheduler to ensure that children are
  3597. // updated in a parent's updated hook.
  3598. };
  3599. Vue.prototype.$forceUpdate = function () {
  3600. const vm = this;
  3601. if (vm._watcher) {
  3602. vm._watcher.update();
  3603. }
  3604. };
  3605. Vue.prototype.$destroy = function () {
  3606. const vm = this;
  3607. if (vm._isBeingDestroyed) {
  3608. return
  3609. }
  3610. callHook(vm, 'beforeDestroy');
  3611. vm._isBeingDestroyed = true;
  3612. // remove self from parent
  3613. const parent = vm.$parent;
  3614. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3615. remove(parent.$children, vm);
  3616. }
  3617. // teardown watchers
  3618. if (vm._watcher) {
  3619. vm._watcher.teardown();
  3620. }
  3621. let i = vm._watchers.length;
  3622. while (i--) {
  3623. vm._watchers[i].teardown();
  3624. }
  3625. // remove reference from data ob
  3626. // frozen object may not have observer.
  3627. if (vm._data.__ob__) {
  3628. vm._data.__ob__.vmCount--;
  3629. }
  3630. // call the last hook...
  3631. vm._isDestroyed = true;
  3632. // invoke destroy hooks on current rendered tree
  3633. vm.__patch__(vm._vnode, null);
  3634. // fire destroyed hook
  3635. callHook(vm, 'destroyed');
  3636. // turn off all instance listeners.
  3637. vm.$off();
  3638. // remove __vue__ reference
  3639. if (vm.$el) {
  3640. vm.$el.__vue__ = null;
  3641. }
  3642. // release circular reference (#6759)
  3643. if (vm.$vnode) {
  3644. vm.$vnode.parent = null;
  3645. }
  3646. };
  3647. }
  3648. function mountComponent (
  3649. vm,
  3650. el,
  3651. hydrating
  3652. ) {
  3653. vm.$el = el;
  3654. if (!vm.$options.render) {
  3655. vm.$options.render = createEmptyVNode;
  3656. {
  3657. /* istanbul ignore if */
  3658. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3659. vm.$options.el || el) {
  3660. warn(
  3661. 'You are using the runtime-only build of Vue where the template ' +
  3662. 'compiler is not available. Either pre-compile the templates into ' +
  3663. 'render functions, or use the compiler-included build.',
  3664. vm
  3665. );
  3666. } else {
  3667. warn(
  3668. 'Failed to mount component: template or render function not defined.',
  3669. vm
  3670. );
  3671. }
  3672. }
  3673. }
  3674. callHook(vm, 'beforeMount');
  3675. let updateComponent;
  3676. /* istanbul ignore if */
  3677. if (config.performance && mark) {
  3678. updateComponent = () => {
  3679. const name = vm._name;
  3680. const id = vm._uid;
  3681. const startTag = `vue-perf-start:${id}`;
  3682. const endTag = `vue-perf-end:${id}`;
  3683. mark(startTag);
  3684. const vnode = vm._render();
  3685. mark(endTag);
  3686. measure(`vue ${name} render`, startTag, endTag);
  3687. mark(startTag);
  3688. vm._update(vnode, hydrating);
  3689. mark(endTag);
  3690. measure(`vue ${name} patch`, startTag, endTag);
  3691. };
  3692. } else {
  3693. updateComponent = () => {
  3694. vm._update(vm._render(), hydrating);
  3695. };
  3696. }
  3697. // we set this to vm._watcher inside the watcher's constructor
  3698. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3699. // component's mounted hook), which relies on vm._watcher being already defined
  3700. new Watcher(vm, updateComponent, noop, {
  3701. before () {
  3702. if (vm._isMounted && !vm._isDestroyed) {
  3703. callHook(vm, 'beforeUpdate');
  3704. }
  3705. }
  3706. }, true /* isRenderWatcher */);
  3707. hydrating = false;
  3708. // manually mounted instance, call mounted on self
  3709. // mounted is called for render-created child components in its inserted hook
  3710. if (vm.$vnode == null) {
  3711. vm._isMounted = true;
  3712. callHook(vm, 'mounted');
  3713. }
  3714. return vm
  3715. }
  3716. function updateChildComponent (
  3717. vm,
  3718. propsData,
  3719. listeners,
  3720. parentVnode,
  3721. renderChildren
  3722. ) {
  3723. {
  3724. isUpdatingChildComponent = true;
  3725. }
  3726. // determine whether component has slot children
  3727. // we need to do this before overwriting $options._renderChildren.
  3728. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3729. // dynamic slot names). Static scoped slots compiled from template has the
  3730. // "$stable" marker.
  3731. const newScopedSlots = parentVnode.data.scopedSlots;
  3732. const oldScopedSlots = vm.$scopedSlots;
  3733. const hasDynamicScopedSlot = !!(
  3734. (newScopedSlots && !newScopedSlots.$stable) ||
  3735. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3736. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  3737. );
  3738. // Any static slot children from the parent may have changed during parent's
  3739. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3740. // update is necessary to ensure correctness.
  3741. const needsForceUpdate = !!(
  3742. renderChildren || // has new static slots
  3743. vm.$options._renderChildren || // has old static slots
  3744. hasDynamicScopedSlot
  3745. );
  3746. vm.$options._parentVnode = parentVnode;
  3747. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3748. if (vm._vnode) { // update child tree's parent
  3749. vm._vnode.parent = parentVnode;
  3750. }
  3751. vm.$options._renderChildren = renderChildren;
  3752. // update $attrs and $listeners hash
  3753. // these are also reactive so they may trigger child update if the child
  3754. // used them during render
  3755. vm.$attrs = parentVnode.data.attrs || emptyObject;
  3756. vm.$listeners = listeners || emptyObject;
  3757. // update props
  3758. if (propsData && vm.$options.props) {
  3759. toggleObserving(false);
  3760. const props = vm._props;
  3761. const propKeys = vm.$options._propKeys || [];
  3762. for (let i = 0; i < propKeys.length; i++) {
  3763. const key = propKeys[i];
  3764. const propOptions = vm.$options.props; // wtf flow?
  3765. props[key] = validateProp(key, propOptions, propsData, vm);
  3766. }
  3767. toggleObserving(true);
  3768. // keep a copy of raw propsData
  3769. vm.$options.propsData = propsData;
  3770. }
  3771. // update listeners
  3772. listeners = listeners || emptyObject;
  3773. const oldListeners = vm.$options._parentListeners;
  3774. vm.$options._parentListeners = listeners;
  3775. updateComponentListeners(vm, listeners, oldListeners);
  3776. // resolve slots + force update if has children
  3777. if (needsForceUpdate) {
  3778. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3779. vm.$forceUpdate();
  3780. }
  3781. {
  3782. isUpdatingChildComponent = false;
  3783. }
  3784. }
  3785. function isInInactiveTree (vm) {
  3786. while (vm && (vm = vm.$parent)) {
  3787. if (vm._inactive) return true
  3788. }
  3789. return false
  3790. }
  3791. function activateChildComponent (vm, direct) {
  3792. if (direct) {
  3793. vm._directInactive = false;
  3794. if (isInInactiveTree(vm)) {
  3795. return
  3796. }
  3797. } else if (vm._directInactive) {
  3798. return
  3799. }
  3800. if (vm._inactive || vm._inactive === null) {
  3801. vm._inactive = false;
  3802. for (let i = 0; i < vm.$children.length; i++) {
  3803. activateChildComponent(vm.$children[i]);
  3804. }
  3805. callHook(vm, 'activated');
  3806. }
  3807. }
  3808. function deactivateChildComponent (vm, direct) {
  3809. if (direct) {
  3810. vm._directInactive = true;
  3811. if (isInInactiveTree(vm)) {
  3812. return
  3813. }
  3814. }
  3815. if (!vm._inactive) {
  3816. vm._inactive = true;
  3817. for (let i = 0; i < vm.$children.length; i++) {
  3818. deactivateChildComponent(vm.$children[i]);
  3819. }
  3820. callHook(vm, 'deactivated');
  3821. }
  3822. }
  3823. function callHook (vm, hook) {
  3824. // #7573 disable dep collection when invoking lifecycle hooks
  3825. pushTarget();
  3826. const handlers = vm.$options[hook];
  3827. const info = `${hook} hook`;
  3828. if (handlers) {
  3829. for (let i = 0, j = handlers.length; i < j; i++) {
  3830. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  3831. }
  3832. }
  3833. if (vm._hasHookEvent) {
  3834. vm.$emit('hook:' + hook);
  3835. }
  3836. popTarget();
  3837. }
  3838. /* */
  3839. const MAX_UPDATE_COUNT = 100;
  3840. const queue = [];
  3841. const activatedChildren = [];
  3842. let has = {};
  3843. let circular = {};
  3844. let waiting = false;
  3845. let flushing = false;
  3846. let index = 0;
  3847. /**
  3848. * Reset the scheduler's state.
  3849. */
  3850. function resetSchedulerState () {
  3851. index = queue.length = activatedChildren.length = 0;
  3852. has = {};
  3853. {
  3854. circular = {};
  3855. }
  3856. waiting = flushing = false;
  3857. }
  3858. // Async edge case #6566 requires saving the timestamp when event listeners are
  3859. // attached. However, calling performance.now() has a perf overhead especially
  3860. // if the page has thousands of event listeners. Instead, we take a timestamp
  3861. // every time the scheduler flushes and use that for all event listeners
  3862. // attached during that flush.
  3863. let currentFlushTimestamp = 0;
  3864. // Async edge case fix requires storing an event listener's attach timestamp.
  3865. let getNow = Date.now;
  3866. // Determine what event timestamp the browser is using. Annoyingly, the
  3867. // timestamp can either be hi-res (relative to page load) or low-res
  3868. // (relative to UNIX epoch), so in order to compare time we have to use the
  3869. // same timestamp type when saving the flush timestamp.
  3870. // All IE versions use low-res event timestamps, and have problematic clock
  3871. // implementations (#9632)
  3872. if (inBrowser && !isIE) {
  3873. const performance = window.performance;
  3874. if (
  3875. performance &&
  3876. typeof performance.now === 'function' &&
  3877. getNow() > document.createEvent('Event').timeStamp
  3878. ) {
  3879. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3880. // smaller than it, it means the event is using a hi-res timestamp,
  3881. // and we need to use the hi-res version for event listener timestamps as
  3882. // well.
  3883. getNow = () => performance.now();
  3884. }
  3885. }
  3886. /**
  3887. * Flush both queues and run the watchers.
  3888. */
  3889. function flushSchedulerQueue () {
  3890. currentFlushTimestamp = getNow();
  3891. flushing = true;
  3892. let watcher, id;
  3893. // Sort queue before flush.
  3894. // This ensures that:
  3895. // 1. Components are updated from parent to child. (because parent is always
  3896. // created before the child)
  3897. // 2. A component's user watchers are run before its render watcher (because
  3898. // user watchers are created before the render watcher)
  3899. // 3. If a component is destroyed during a parent component's watcher run,
  3900. // its watchers can be skipped.
  3901. queue.sort((a, b) => a.id - b.id);
  3902. // do not cache length because more watchers might be pushed
  3903. // as we run existing watchers
  3904. for (index = 0; index < queue.length; index++) {
  3905. watcher = queue[index];
  3906. if (watcher.before) {
  3907. watcher.before();
  3908. }
  3909. id = watcher.id;
  3910. has[id] = null;
  3911. watcher.run();
  3912. // in dev build, check and stop circular updates.
  3913. if (has[id] != null) {
  3914. circular[id] = (circular[id] || 0) + 1;
  3915. if (circular[id] > MAX_UPDATE_COUNT) {
  3916. warn(
  3917. 'You may have an infinite update loop ' + (
  3918. watcher.user
  3919. ? `in watcher with expression "${watcher.expression}"`
  3920. : `in a component render function.`
  3921. ),
  3922. watcher.vm
  3923. );
  3924. break
  3925. }
  3926. }
  3927. }
  3928. // keep copies of post queues before resetting state
  3929. const activatedQueue = activatedChildren.slice();
  3930. const updatedQueue = queue.slice();
  3931. resetSchedulerState();
  3932. // call component updated and activated hooks
  3933. callActivatedHooks(activatedQueue);
  3934. callUpdatedHooks(updatedQueue);
  3935. // devtool hook
  3936. /* istanbul ignore if */
  3937. if (devtools && config.devtools) {
  3938. devtools.emit('flush');
  3939. }
  3940. }
  3941. function callUpdatedHooks (queue) {
  3942. let i = queue.length;
  3943. while (i--) {
  3944. const watcher = queue[i];
  3945. const vm = watcher.vm;
  3946. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3947. callHook(vm, 'updated');
  3948. }
  3949. }
  3950. }
  3951. /**
  3952. * Queue a kept-alive component that was activated during patch.
  3953. * The queue will be processed after the entire tree has been patched.
  3954. */
  3955. function queueActivatedComponent (vm) {
  3956. // setting _inactive to false here so that a render function can
  3957. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3958. vm._inactive = false;
  3959. activatedChildren.push(vm);
  3960. }
  3961. function callActivatedHooks (queue) {
  3962. for (let i = 0; i < queue.length; i++) {
  3963. queue[i]._inactive = true;
  3964. activateChildComponent(queue[i], true /* true */);
  3965. }
  3966. }
  3967. /**
  3968. * Push a watcher into the watcher queue.
  3969. * Jobs with duplicate IDs will be skipped unless it's
  3970. * pushed when the queue is being flushed.
  3971. */
  3972. function queueWatcher (watcher) {
  3973. const id = watcher.id;
  3974. if (has[id] == null) {
  3975. has[id] = true;
  3976. if (!flushing) {
  3977. queue.push(watcher);
  3978. } else {
  3979. // if already flushing, splice the watcher based on its id
  3980. // if already past its id, it will be run next immediately.
  3981. let i = queue.length - 1;
  3982. while (i > index && queue[i].id > watcher.id) {
  3983. i--;
  3984. }
  3985. queue.splice(i + 1, 0, watcher);
  3986. }
  3987. // queue the flush
  3988. if (!waiting) {
  3989. waiting = true;
  3990. if (!config.async) {
  3991. flushSchedulerQueue();
  3992. return
  3993. }
  3994. nextTick(flushSchedulerQueue);
  3995. }
  3996. }
  3997. }
  3998. /* */
  3999. let uid$2 = 0;
  4000. /**
  4001. * A watcher parses an expression, collects dependencies,
  4002. * and fires callback when the expression value changes.
  4003. * This is used for both the $watch() api and directives.
  4004. */
  4005. class Watcher {
  4006. constructor (
  4007. vm,
  4008. expOrFn,
  4009. cb,
  4010. options,
  4011. isRenderWatcher
  4012. ) {
  4013. this.vm = vm;
  4014. if (isRenderWatcher) {
  4015. vm._watcher = this;
  4016. }
  4017. vm._watchers.push(this);
  4018. // options
  4019. if (options) {
  4020. this.deep = !!options.deep;
  4021. this.user = !!options.user;
  4022. this.lazy = !!options.lazy;
  4023. this.sync = !!options.sync;
  4024. this.before = options.before;
  4025. } else {
  4026. this.deep = this.user = this.lazy = this.sync = false;
  4027. }
  4028. this.cb = cb;
  4029. this.id = ++uid$2; // uid for batching
  4030. this.active = true;
  4031. this.dirty = this.lazy; // for lazy watchers
  4032. this.deps = [];
  4033. this.newDeps = [];
  4034. this.depIds = new _Set();
  4035. this.newDepIds = new _Set();
  4036. this.expression = expOrFn.toString();
  4037. // parse expression for getter
  4038. if (typeof expOrFn === 'function') {
  4039. this.getter = expOrFn;
  4040. } else {
  4041. this.getter = parsePath(expOrFn);
  4042. if (!this.getter) {
  4043. this.getter = noop;
  4044. warn(
  4045. `Failed watching path: "${expOrFn}" ` +
  4046. 'Watcher only accepts simple dot-delimited paths. ' +
  4047. 'For full control, use a function instead.',
  4048. vm
  4049. );
  4050. }
  4051. }
  4052. this.value = this.lazy
  4053. ? undefined
  4054. : this.get();
  4055. }
  4056. /**
  4057. * Evaluate the getter, and re-collect dependencies.
  4058. */
  4059. get () {
  4060. pushTarget(this);
  4061. let value;
  4062. const vm = this.vm;
  4063. try {
  4064. value = this.getter.call(vm, vm);
  4065. } catch (e) {
  4066. if (this.user) {
  4067. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4068. } else {
  4069. throw e
  4070. }
  4071. } finally {
  4072. // "touch" every property so they are all tracked as
  4073. // dependencies for deep watching
  4074. if (this.deep) {
  4075. traverse(value);
  4076. }
  4077. popTarget();
  4078. this.cleanupDeps();
  4079. }
  4080. return value
  4081. }
  4082. /**
  4083. * Add a dependency to this directive.
  4084. */
  4085. addDep (dep) {
  4086. const id = dep.id;
  4087. if (!this.newDepIds.has(id)) {
  4088. this.newDepIds.add(id);
  4089. this.newDeps.push(dep);
  4090. if (!this.depIds.has(id)) {
  4091. dep.addSub(this);
  4092. }
  4093. }
  4094. }
  4095. /**
  4096. * Clean up for dependency collection.
  4097. */
  4098. cleanupDeps () {
  4099. let i = this.deps.length;
  4100. while (i--) {
  4101. const dep = this.deps[i];
  4102. if (!this.newDepIds.has(dep.id)) {
  4103. dep.removeSub(this);
  4104. }
  4105. }
  4106. let tmp = this.depIds;
  4107. this.depIds = this.newDepIds;
  4108. this.newDepIds = tmp;
  4109. this.newDepIds.clear();
  4110. tmp = this.deps;
  4111. this.deps = this.newDeps;
  4112. this.newDeps = tmp;
  4113. this.newDeps.length = 0;
  4114. }
  4115. /**
  4116. * Subscriber interface.
  4117. * Will be called when a dependency changes.
  4118. */
  4119. update () {
  4120. /* istanbul ignore else */
  4121. if (this.lazy) {
  4122. this.dirty = true;
  4123. } else if (this.sync) {
  4124. this.run();
  4125. } else {
  4126. queueWatcher(this);
  4127. }
  4128. }
  4129. /**
  4130. * Scheduler job interface.
  4131. * Will be called by the scheduler.
  4132. */
  4133. run () {
  4134. if (this.active) {
  4135. const value = this.get();
  4136. if (
  4137. value !== this.value ||
  4138. // Deep watchers and watchers on Object/Arrays should fire even
  4139. // when the value is the same, because the value may
  4140. // have mutated.
  4141. isObject(value) ||
  4142. this.deep
  4143. ) {
  4144. // set new value
  4145. const oldValue = this.value;
  4146. this.value = value;
  4147. if (this.user) {
  4148. try {
  4149. this.cb.call(this.vm, value, oldValue);
  4150. } catch (e) {
  4151. handleError(e, this.vm, `callback for watcher "${this.expression}"`);
  4152. }
  4153. } else {
  4154. this.cb.call(this.vm, value, oldValue);
  4155. }
  4156. }
  4157. }
  4158. }
  4159. /**
  4160. * Evaluate the value of the watcher.
  4161. * This only gets called for lazy watchers.
  4162. */
  4163. evaluate () {
  4164. this.value = this.get();
  4165. this.dirty = false;
  4166. }
  4167. /**
  4168. * Depend on all deps collected by this watcher.
  4169. */
  4170. depend () {
  4171. let i = this.deps.length;
  4172. while (i--) {
  4173. this.deps[i].depend();
  4174. }
  4175. }
  4176. /**
  4177. * Remove self from all dependencies' subscriber list.
  4178. */
  4179. teardown () {
  4180. if (this.active) {
  4181. // remove self from vm's watcher list
  4182. // this is a somewhat expensive operation so we skip it
  4183. // if the vm is being destroyed.
  4184. if (!this.vm._isBeingDestroyed) {
  4185. remove(this.vm._watchers, this);
  4186. }
  4187. let i = this.deps.length;
  4188. while (i--) {
  4189. this.deps[i].removeSub(this);
  4190. }
  4191. this.active = false;
  4192. }
  4193. }
  4194. }
  4195. /* */
  4196. const sharedPropertyDefinition = {
  4197. enumerable: true,
  4198. configurable: true,
  4199. get: noop,
  4200. set: noop
  4201. };
  4202. function proxy (target, sourceKey, key) {
  4203. sharedPropertyDefinition.get = function proxyGetter () {
  4204. return this[sourceKey][key]
  4205. };
  4206. sharedPropertyDefinition.set = function proxySetter (val) {
  4207. this[sourceKey][key] = val;
  4208. };
  4209. Object.defineProperty(target, key, sharedPropertyDefinition);
  4210. }
  4211. function initState (vm) {
  4212. vm._watchers = [];
  4213. const opts = vm.$options;
  4214. if (opts.props) initProps(vm, opts.props);
  4215. if (opts.methods) initMethods(vm, opts.methods);
  4216. if (opts.data) {
  4217. initData(vm);
  4218. } else {
  4219. observe(vm._data = {}, true /* asRootData */);
  4220. }
  4221. if (opts.computed) initComputed(vm, opts.computed);
  4222. if (opts.watch && opts.watch !== nativeWatch) {
  4223. initWatch(vm, opts.watch);
  4224. }
  4225. }
  4226. function initProps (vm, propsOptions) {
  4227. const propsData = vm.$options.propsData || {};
  4228. const props = vm._props = {};
  4229. // cache prop keys so that future props updates can iterate using Array
  4230. // instead of dynamic object key enumeration.
  4231. const keys = vm.$options._propKeys = [];
  4232. const isRoot = !vm.$parent;
  4233. // root instance props should be converted
  4234. if (!isRoot) {
  4235. toggleObserving(false);
  4236. }
  4237. for (const key in propsOptions) {
  4238. keys.push(key);
  4239. const value = validateProp(key, propsOptions, propsData, vm);
  4240. /* istanbul ignore else */
  4241. {
  4242. const hyphenatedKey = hyphenate(key);
  4243. if (isReservedAttribute(hyphenatedKey) ||
  4244. config.isReservedAttr(hyphenatedKey)) {
  4245. warn(
  4246. `"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`,
  4247. vm
  4248. );
  4249. }
  4250. defineReactive$$1(props, key, value, () => {
  4251. if (!isRoot && !isUpdatingChildComponent) {
  4252. warn(
  4253. `Avoid mutating a prop directly since the value will be ` +
  4254. `overwritten whenever the parent component re-renders. ` +
  4255. `Instead, use a data or computed property based on the prop's ` +
  4256. `value. Prop being mutated: "${key}"`,
  4257. vm
  4258. );
  4259. }
  4260. });
  4261. }
  4262. // static props are already proxied on the component's prototype
  4263. // during Vue.extend(). We only need to proxy props defined at
  4264. // instantiation here.
  4265. if (!(key in vm)) {
  4266. proxy(vm, `_props`, key);
  4267. }
  4268. }
  4269. toggleObserving(true);
  4270. }
  4271. function initData (vm) {
  4272. let data = vm.$options.data;
  4273. data = vm._data = typeof data === 'function'
  4274. ? getData(data, vm)
  4275. : data || {};
  4276. if (!isPlainObject(data)) {
  4277. data = {};
  4278. warn(
  4279. 'data functions should return an object:\n' +
  4280. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  4281. vm
  4282. );
  4283. }
  4284. // proxy data on instance
  4285. const keys = Object.keys(data);
  4286. const props = vm.$options.props;
  4287. const methods = vm.$options.methods;
  4288. let i = keys.length;
  4289. while (i--) {
  4290. const key = keys[i];
  4291. {
  4292. if (methods && hasOwn(methods, key)) {
  4293. warn(
  4294. `Method "${key}" has already been defined as a data property.`,
  4295. vm
  4296. );
  4297. }
  4298. }
  4299. if (props && hasOwn(props, key)) {
  4300. warn(
  4301. `The data property "${key}" is already declared as a prop. ` +
  4302. `Use prop default value instead.`,
  4303. vm
  4304. );
  4305. } else if (!isReserved(key)) {
  4306. proxy(vm, `_data`, key);
  4307. }
  4308. }
  4309. // observe data
  4310. observe(data, true /* asRootData */);
  4311. }
  4312. function getData (data, vm) {
  4313. // #7573 disable dep collection when invoking data getters
  4314. pushTarget();
  4315. try {
  4316. return data.call(vm, vm)
  4317. } catch (e) {
  4318. handleError(e, vm, `data()`);
  4319. return {}
  4320. } finally {
  4321. popTarget();
  4322. }
  4323. }
  4324. const computedWatcherOptions = { lazy: true };
  4325. function initComputed (vm, computed) {
  4326. // $flow-disable-line
  4327. const watchers = vm._computedWatchers = Object.create(null);
  4328. // computed properties are just getters during SSR
  4329. const isSSR = isServerRendering();
  4330. for (const key in computed) {
  4331. const userDef = computed[key];
  4332. const getter = typeof userDef === 'function' ? userDef : userDef.get;
  4333. if (getter == null) {
  4334. warn(
  4335. `Getter is missing for computed property "${key}".`,
  4336. vm
  4337. );
  4338. }
  4339. if (!isSSR) {
  4340. // create internal watcher for the computed property.
  4341. watchers[key] = new Watcher(
  4342. vm,
  4343. getter || noop,
  4344. noop,
  4345. computedWatcherOptions
  4346. );
  4347. }
  4348. // component-defined computed properties are already defined on the
  4349. // component prototype. We only need to define computed properties defined
  4350. // at instantiation here.
  4351. if (!(key in vm)) {
  4352. defineComputed(vm, key, userDef);
  4353. } else {
  4354. if (key in vm.$data) {
  4355. warn(`The computed property "${key}" is already defined in data.`, vm);
  4356. } else if (vm.$options.props && key in vm.$options.props) {
  4357. warn(`The computed property "${key}" is already defined as a prop.`, vm);
  4358. }
  4359. }
  4360. }
  4361. }
  4362. function defineComputed (
  4363. target,
  4364. key,
  4365. userDef
  4366. ) {
  4367. const shouldCache = !isServerRendering();
  4368. if (typeof userDef === 'function') {
  4369. sharedPropertyDefinition.get = shouldCache
  4370. ? createComputedGetter(key)
  4371. : createGetterInvoker(userDef);
  4372. sharedPropertyDefinition.set = noop;
  4373. } else {
  4374. sharedPropertyDefinition.get = userDef.get
  4375. ? shouldCache && userDef.cache !== false
  4376. ? createComputedGetter(key)
  4377. : createGetterInvoker(userDef.get)
  4378. : noop;
  4379. sharedPropertyDefinition.set = userDef.set || noop;
  4380. }
  4381. if (sharedPropertyDefinition.set === noop) {
  4382. sharedPropertyDefinition.set = function () {
  4383. warn(
  4384. `Computed property "${key}" was assigned to but it has no setter.`,
  4385. this
  4386. );
  4387. };
  4388. }
  4389. Object.defineProperty(target, key, sharedPropertyDefinition);
  4390. }
  4391. function createComputedGetter (key) {
  4392. return function computedGetter () {
  4393. const watcher = this._computedWatchers && this._computedWatchers[key];
  4394. if (watcher) {
  4395. if (watcher.dirty) {
  4396. watcher.evaluate();
  4397. }
  4398. if (Dep.target) {
  4399. watcher.depend();
  4400. }
  4401. return watcher.value
  4402. }
  4403. }
  4404. }
  4405. function createGetterInvoker(fn) {
  4406. return function computedGetter () {
  4407. return fn.call(this, this)
  4408. }
  4409. }
  4410. function initMethods (vm, methods) {
  4411. const props = vm.$options.props;
  4412. for (const key in methods) {
  4413. {
  4414. if (typeof methods[key] !== 'function') {
  4415. warn(
  4416. `Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4417. `Did you reference the function correctly?`,
  4418. vm
  4419. );
  4420. }
  4421. if (props && hasOwn(props, key)) {
  4422. warn(
  4423. `Method "${key}" has already been defined as a prop.`,
  4424. vm
  4425. );
  4426. }
  4427. if ((key in vm) && isReserved(key)) {
  4428. warn(
  4429. `Method "${key}" conflicts with an existing Vue instance method. ` +
  4430. `Avoid defining component methods that start with _ or $.`
  4431. );
  4432. }
  4433. }
  4434. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  4435. }
  4436. }
  4437. function initWatch (vm, watch) {
  4438. for (const key in watch) {
  4439. const handler = watch[key];
  4440. if (Array.isArray(handler)) {
  4441. for (let i = 0; i < handler.length; i++) {
  4442. createWatcher(vm, key, handler[i]);
  4443. }
  4444. } else {
  4445. createWatcher(vm, key, handler);
  4446. }
  4447. }
  4448. }
  4449. function createWatcher (
  4450. vm,
  4451. expOrFn,
  4452. handler,
  4453. options
  4454. ) {
  4455. if (isPlainObject(handler)) {
  4456. options = handler;
  4457. handler = handler.handler;
  4458. }
  4459. if (typeof handler === 'string') {
  4460. handler = vm[handler];
  4461. }
  4462. return vm.$watch(expOrFn, handler, options)
  4463. }
  4464. function stateMixin (Vue) {
  4465. // flow somehow has problems with directly declared definition object
  4466. // when using Object.defineProperty, so we have to procedurally build up
  4467. // the object here.
  4468. const dataDef = {};
  4469. dataDef.get = function () { return this._data };
  4470. const propsDef = {};
  4471. propsDef.get = function () { return this._props };
  4472. {
  4473. dataDef.set = function () {
  4474. warn(
  4475. 'Avoid replacing instance root $data. ' +
  4476. 'Use nested data properties instead.',
  4477. this
  4478. );
  4479. };
  4480. propsDef.set = function () {
  4481. warn(`$props is readonly.`, this);
  4482. };
  4483. }
  4484. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4485. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4486. Vue.prototype.$set = set;
  4487. Vue.prototype.$delete = del;
  4488. Vue.prototype.$watch = function (
  4489. expOrFn,
  4490. cb,
  4491. options
  4492. ) {
  4493. const vm = this;
  4494. if (isPlainObject(cb)) {
  4495. return createWatcher(vm, expOrFn, cb, options)
  4496. }
  4497. options = options || {};
  4498. options.user = true;
  4499. const watcher = new Watcher(vm, expOrFn, cb, options);
  4500. if (options.immediate) {
  4501. try {
  4502. cb.call(vm, watcher.value);
  4503. } catch (error) {
  4504. handleError(error, vm, `callback for immediate watcher "${watcher.expression}"`);
  4505. }
  4506. }
  4507. return function unwatchFn () {
  4508. watcher.teardown();
  4509. }
  4510. };
  4511. }
  4512. /* */
  4513. let uid$3 = 0;
  4514. function initMixin (Vue) {
  4515. Vue.prototype._init = function (options) {
  4516. const vm = this;
  4517. // a uid
  4518. vm._uid = uid$3++;
  4519. let startTag, endTag;
  4520. /* istanbul ignore if */
  4521. if (config.performance && mark) {
  4522. startTag = `vue-perf-start:${vm._uid}`;
  4523. endTag = `vue-perf-end:${vm._uid}`;
  4524. mark(startTag);
  4525. }
  4526. // a flag to avoid this being observed
  4527. vm._isVue = true;
  4528. // merge options
  4529. if (options && options._isComponent) {
  4530. // optimize internal component instantiation
  4531. // since dynamic options merging is pretty slow, and none of the
  4532. // internal component options needs special treatment.
  4533. initInternalComponent(vm, options);
  4534. } else {
  4535. vm.$options = mergeOptions(
  4536. resolveConstructorOptions(vm.constructor),
  4537. options || {},
  4538. vm
  4539. );
  4540. }
  4541. /* istanbul ignore else */
  4542. {
  4543. initProxy(vm);
  4544. }
  4545. // expose real self
  4546. vm._self = vm;
  4547. initLifecycle(vm);
  4548. initEvents(vm);
  4549. initRender(vm);
  4550. callHook(vm, 'beforeCreate');
  4551. initInjections(vm); // resolve injections before data/props
  4552. initState(vm);
  4553. initProvide(vm); // resolve provide after data/props
  4554. callHook(vm, 'created');
  4555. /* istanbul ignore if */
  4556. if (config.performance && mark) {
  4557. vm._name = formatComponentName(vm, false);
  4558. mark(endTag);
  4559. measure(`vue ${vm._name} init`, startTag, endTag);
  4560. }
  4561. if (vm.$options.el) {
  4562. vm.$mount(vm.$options.el);
  4563. }
  4564. };
  4565. }
  4566. function initInternalComponent (vm, options) {
  4567. const opts = vm.$options = Object.create(vm.constructor.options);
  4568. // doing this because it's faster than dynamic enumeration.
  4569. const parentVnode = options._parentVnode;
  4570. opts.parent = options.parent;
  4571. opts._parentVnode = parentVnode;
  4572. const vnodeComponentOptions = parentVnode.componentOptions;
  4573. opts.propsData = vnodeComponentOptions.propsData;
  4574. opts._parentListeners = vnodeComponentOptions.listeners;
  4575. opts._renderChildren = vnodeComponentOptions.children;
  4576. opts._componentTag = vnodeComponentOptions.tag;
  4577. if (options.render) {
  4578. opts.render = options.render;
  4579. opts.staticRenderFns = options.staticRenderFns;
  4580. }
  4581. }
  4582. function resolveConstructorOptions (Ctor) {
  4583. let options = Ctor.options;
  4584. if (Ctor.super) {
  4585. const superOptions = resolveConstructorOptions(Ctor.super);
  4586. const cachedSuperOptions = Ctor.superOptions;
  4587. if (superOptions !== cachedSuperOptions) {
  4588. // super option changed,
  4589. // need to resolve new options.
  4590. Ctor.superOptions = superOptions;
  4591. // check if there are any late-modified/attached options (#4976)
  4592. const modifiedOptions = resolveModifiedOptions(Ctor);
  4593. // update base extend options
  4594. if (modifiedOptions) {
  4595. extend(Ctor.extendOptions, modifiedOptions);
  4596. }
  4597. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4598. if (options.name) {
  4599. options.components[options.name] = Ctor;
  4600. }
  4601. }
  4602. }
  4603. return options
  4604. }
  4605. function resolveModifiedOptions (Ctor) {
  4606. let modified;
  4607. const latest = Ctor.options;
  4608. const sealed = Ctor.sealedOptions;
  4609. for (const key in latest) {
  4610. if (latest[key] !== sealed[key]) {
  4611. if (!modified) modified = {};
  4612. modified[key] = latest[key];
  4613. }
  4614. }
  4615. return modified
  4616. }
  4617. function Vue (options) {
  4618. if (!(this instanceof Vue)
  4619. ) {
  4620. warn('Vue is a constructor and should be called with the `new` keyword');
  4621. }
  4622. this._init(options);
  4623. }
  4624. initMixin(Vue);
  4625. stateMixin(Vue);
  4626. eventsMixin(Vue);
  4627. lifecycleMixin(Vue);
  4628. renderMixin(Vue);
  4629. /* */
  4630. function initUse (Vue) {
  4631. Vue.use = function (plugin) {
  4632. const installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  4633. if (installedPlugins.indexOf(plugin) > -1) {
  4634. return this
  4635. }
  4636. // additional parameters
  4637. const args = toArray(arguments, 1);
  4638. args.unshift(this);
  4639. if (typeof plugin.install === 'function') {
  4640. plugin.install.apply(plugin, args);
  4641. } else if (typeof plugin === 'function') {
  4642. plugin.apply(null, args);
  4643. }
  4644. installedPlugins.push(plugin);
  4645. return this
  4646. };
  4647. }
  4648. /* */
  4649. function initMixin$1 (Vue) {
  4650. Vue.mixin = function (mixin) {
  4651. this.options = mergeOptions(this.options, mixin);
  4652. return this
  4653. };
  4654. }
  4655. /* */
  4656. function initExtend (Vue) {
  4657. /**
  4658. * Each instance constructor, including Vue, has a unique
  4659. * cid. This enables us to create wrapped "child
  4660. * constructors" for prototypal inheritance and cache them.
  4661. */
  4662. Vue.cid = 0;
  4663. let cid = 1;
  4664. /**
  4665. * Class inheritance
  4666. */
  4667. Vue.extend = function (extendOptions) {
  4668. extendOptions = extendOptions || {};
  4669. const Super = this;
  4670. const SuperId = Super.cid;
  4671. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  4672. if (cachedCtors[SuperId]) {
  4673. return cachedCtors[SuperId]
  4674. }
  4675. const name = extendOptions.name || Super.options.name;
  4676. if (name) {
  4677. validateComponentName(name);
  4678. }
  4679. const Sub = function VueComponent (options) {
  4680. this._init(options);
  4681. };
  4682. Sub.prototype = Object.create(Super.prototype);
  4683. Sub.prototype.constructor = Sub;
  4684. Sub.cid = cid++;
  4685. Sub.options = mergeOptions(
  4686. Super.options,
  4687. extendOptions
  4688. );
  4689. Sub['super'] = Super;
  4690. // For props and computed properties, we define the proxy getters on
  4691. // the Vue instances at extension time, on the extended prototype. This
  4692. // avoids Object.defineProperty calls for each instance created.
  4693. if (Sub.options.props) {
  4694. initProps$1(Sub);
  4695. }
  4696. if (Sub.options.computed) {
  4697. initComputed$1(Sub);
  4698. }
  4699. // allow further extension/mixin/plugin usage
  4700. Sub.extend = Super.extend;
  4701. Sub.mixin = Super.mixin;
  4702. Sub.use = Super.use;
  4703. // create asset registers, so extended classes
  4704. // can have their private assets too.
  4705. ASSET_TYPES.forEach(function (type) {
  4706. Sub[type] = Super[type];
  4707. });
  4708. // enable recursive self-lookup
  4709. if (name) {
  4710. Sub.options.components[name] = Sub;
  4711. }
  4712. // keep a reference to the super options at extension time.
  4713. // later at instantiation we can check if Super's options have
  4714. // been updated.
  4715. Sub.superOptions = Super.options;
  4716. Sub.extendOptions = extendOptions;
  4717. Sub.sealedOptions = extend({}, Sub.options);
  4718. // cache constructor
  4719. cachedCtors[SuperId] = Sub;
  4720. return Sub
  4721. };
  4722. }
  4723. function initProps$1 (Comp) {
  4724. const props = Comp.options.props;
  4725. for (const key in props) {
  4726. proxy(Comp.prototype, `_props`, key);
  4727. }
  4728. }
  4729. function initComputed$1 (Comp) {
  4730. const computed = Comp.options.computed;
  4731. for (const key in computed) {
  4732. defineComputed(Comp.prototype, key, computed[key]);
  4733. }
  4734. }
  4735. /* */
  4736. function initAssetRegisters (Vue) {
  4737. /**
  4738. * Create asset registration methods.
  4739. */
  4740. ASSET_TYPES.forEach(type => {
  4741. Vue[type] = function (
  4742. id,
  4743. definition
  4744. ) {
  4745. if (!definition) {
  4746. return this.options[type + 's'][id]
  4747. } else {
  4748. /* istanbul ignore if */
  4749. if (type === 'component') {
  4750. validateComponentName(id);
  4751. }
  4752. if (type === 'component' && isPlainObject(definition)) {
  4753. definition.name = definition.name || id;
  4754. definition = this.options._base.extend(definition);
  4755. }
  4756. if (type === 'directive' && typeof definition === 'function') {
  4757. definition = { bind: definition, update: definition };
  4758. }
  4759. this.options[type + 's'][id] = definition;
  4760. return definition
  4761. }
  4762. };
  4763. });
  4764. }
  4765. /* */
  4766. function getComponentName (opts) {
  4767. return opts && (opts.Ctor.options.name || opts.tag)
  4768. }
  4769. function matches (pattern, name) {
  4770. if (Array.isArray(pattern)) {
  4771. return pattern.indexOf(name) > -1
  4772. } else if (typeof pattern === 'string') {
  4773. return pattern.split(',').indexOf(name) > -1
  4774. } else if (isRegExp(pattern)) {
  4775. return pattern.test(name)
  4776. }
  4777. /* istanbul ignore next */
  4778. return false
  4779. }
  4780. function pruneCache (keepAliveInstance, filter) {
  4781. const { cache, keys, _vnode } = keepAliveInstance;
  4782. for (const key in cache) {
  4783. const cachedNode = cache[key];
  4784. if (cachedNode) {
  4785. const name = getComponentName(cachedNode.componentOptions);
  4786. if (name && !filter(name)) {
  4787. pruneCacheEntry(cache, key, keys, _vnode);
  4788. }
  4789. }
  4790. }
  4791. }
  4792. function pruneCacheEntry (
  4793. cache,
  4794. key,
  4795. keys,
  4796. current
  4797. ) {
  4798. const cached$$1 = cache[key];
  4799. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  4800. cached$$1.componentInstance.$destroy();
  4801. }
  4802. cache[key] = null;
  4803. remove(keys, key);
  4804. }
  4805. const patternTypes = [String, RegExp, Array];
  4806. var KeepAlive = {
  4807. name: 'keep-alive',
  4808. abstract: true,
  4809. props: {
  4810. include: patternTypes,
  4811. exclude: patternTypes,
  4812. max: [String, Number]
  4813. },
  4814. created () {
  4815. this.cache = Object.create(null);
  4816. this.keys = [];
  4817. },
  4818. destroyed () {
  4819. for (const key in this.cache) {
  4820. pruneCacheEntry(this.cache, key, this.keys);
  4821. }
  4822. },
  4823. mounted () {
  4824. this.$watch('include', val => {
  4825. pruneCache(this, name => matches(val, name));
  4826. });
  4827. this.$watch('exclude', val => {
  4828. pruneCache(this, name => !matches(val, name));
  4829. });
  4830. },
  4831. render () {
  4832. const slot = this.$slots.default;
  4833. const vnode = getFirstComponentChild(slot);
  4834. const componentOptions = vnode && vnode.componentOptions;
  4835. if (componentOptions) {
  4836. // check pattern
  4837. const name = getComponentName(componentOptions);
  4838. const { include, exclude } = this;
  4839. if (
  4840. // not included
  4841. (include && (!name || !matches(include, name))) ||
  4842. // excluded
  4843. (exclude && name && matches(exclude, name))
  4844. ) {
  4845. return vnode
  4846. }
  4847. const { cache, keys } = this;
  4848. const key = vnode.key == null
  4849. // same constructor may get registered as different local components
  4850. // so cid alone is not enough (#3269)
  4851. ? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
  4852. : vnode.key;
  4853. if (cache[key]) {
  4854. vnode.componentInstance = cache[key].componentInstance;
  4855. // make current key freshest
  4856. remove(keys, key);
  4857. keys.push(key);
  4858. } else {
  4859. cache[key] = vnode;
  4860. keys.push(key);
  4861. // prune oldest entry
  4862. if (this.max && keys.length > parseInt(this.max)) {
  4863. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  4864. }
  4865. }
  4866. vnode.data.keepAlive = true;
  4867. }
  4868. return vnode || (slot && slot[0])
  4869. }
  4870. };
  4871. var builtInComponents = {
  4872. KeepAlive
  4873. };
  4874. /* */
  4875. function initGlobalAPI (Vue) {
  4876. // config
  4877. const configDef = {};
  4878. configDef.get = () => config;
  4879. {
  4880. configDef.set = () => {
  4881. warn(
  4882. 'Do not replace the Vue.config object, set individual fields instead.'
  4883. );
  4884. };
  4885. }
  4886. Object.defineProperty(Vue, 'config', configDef);
  4887. // exposed util methods.
  4888. // NOTE: these are not considered part of the public API - avoid relying on
  4889. // them unless you are aware of the risk.
  4890. Vue.util = {
  4891. warn,
  4892. extend,
  4893. mergeOptions,
  4894. defineReactive: defineReactive$$1
  4895. };
  4896. Vue.set = set;
  4897. Vue.delete = del;
  4898. Vue.nextTick = nextTick;
  4899. // 2.6 explicit observable API
  4900. Vue.observable = (obj) => {
  4901. observe(obj);
  4902. return obj
  4903. };
  4904. Vue.options = Object.create(null);
  4905. ASSET_TYPES.forEach(type => {
  4906. Vue.options[type + 's'] = Object.create(null);
  4907. });
  4908. // this is used to identify the "base" constructor to extend all plain-object
  4909. // components with in Weex's multi-instance scenarios.
  4910. Vue.options._base = Vue;
  4911. extend(Vue.options.components, builtInComponents);
  4912. initUse(Vue);
  4913. initMixin$1(Vue);
  4914. initExtend(Vue);
  4915. initAssetRegisters(Vue);
  4916. }
  4917. initGlobalAPI(Vue);
  4918. Object.defineProperty(Vue.prototype, '$isServer', {
  4919. get: isServerRendering
  4920. });
  4921. Object.defineProperty(Vue.prototype, '$ssrContext', {
  4922. get () {
  4923. /* istanbul ignore next */
  4924. return this.$vnode && this.$vnode.ssrContext
  4925. }
  4926. });
  4927. // expose FunctionalRenderContext for ssr runtime helper installation
  4928. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  4929. value: FunctionalRenderContext
  4930. });
  4931. Vue.version = '2.6.12';
  4932. /* */
  4933. // these are reserved for web because they are directly compiled away
  4934. // during template compilation
  4935. const isReservedAttr = makeMap('style,class');
  4936. // attributes that should be using props for binding
  4937. const acceptValue = makeMap('input,textarea,option,select,progress');
  4938. const mustUseProp = (tag, type, attr) => {
  4939. return (
  4940. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  4941. (attr === 'selected' && tag === 'option') ||
  4942. (attr === 'checked' && tag === 'input') ||
  4943. (attr === 'muted' && tag === 'video')
  4944. )
  4945. };
  4946. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  4947. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  4948. const convertEnumeratedValue = (key, value) => {
  4949. return isFalsyAttrValue(value) || value === 'false'
  4950. ? 'false'
  4951. // allow arbitrary string value for contenteditable
  4952. : key === 'contenteditable' && isValidContentEditableValue(value)
  4953. ? value
  4954. : 'true'
  4955. };
  4956. const isBooleanAttr = makeMap(
  4957. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  4958. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  4959. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  4960. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  4961. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  4962. 'truespeed,typemustmatch,visible'
  4963. );
  4964. const xlinkNS = 'http://www.w3.org/1999/xlink';
  4965. const isXlink = (name) => {
  4966. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  4967. };
  4968. const getXlinkProp = (name) => {
  4969. return isXlink(name) ? name.slice(6, name.length) : ''
  4970. };
  4971. const isFalsyAttrValue = (val) => {
  4972. return val == null || val === false
  4973. };
  4974. /* */
  4975. function genClassForVnode (vnode) {
  4976. let data = vnode.data;
  4977. let parentNode = vnode;
  4978. let childNode = vnode;
  4979. while (isDef(childNode.componentInstance)) {
  4980. childNode = childNode.componentInstance._vnode;
  4981. if (childNode && childNode.data) {
  4982. data = mergeClassData(childNode.data, data);
  4983. }
  4984. }
  4985. while (isDef(parentNode = parentNode.parent)) {
  4986. if (parentNode && parentNode.data) {
  4987. data = mergeClassData(data, parentNode.data);
  4988. }
  4989. }
  4990. return renderClass(data.staticClass, data.class)
  4991. }
  4992. function mergeClassData (child, parent) {
  4993. return {
  4994. staticClass: concat(child.staticClass, parent.staticClass),
  4995. class: isDef(child.class)
  4996. ? [child.class, parent.class]
  4997. : parent.class
  4998. }
  4999. }
  5000. function renderClass (
  5001. staticClass,
  5002. dynamicClass
  5003. ) {
  5004. if (isDef(staticClass) || isDef(dynamicClass)) {
  5005. return concat(staticClass, stringifyClass(dynamicClass))
  5006. }
  5007. /* istanbul ignore next */
  5008. return ''
  5009. }
  5010. function concat (a, b) {
  5011. return a ? b ? (a + ' ' + b) : a : (b || '')
  5012. }
  5013. function stringifyClass (value) {
  5014. if (Array.isArray(value)) {
  5015. return stringifyArray(value)
  5016. }
  5017. if (isObject(value)) {
  5018. return stringifyObject(value)
  5019. }
  5020. if (typeof value === 'string') {
  5021. return value
  5022. }
  5023. /* istanbul ignore next */
  5024. return ''
  5025. }
  5026. function stringifyArray (value) {
  5027. let res = '';
  5028. let stringified;
  5029. for (let i = 0, l = value.length; i < l; i++) {
  5030. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  5031. if (res) res += ' ';
  5032. res += stringified;
  5033. }
  5034. }
  5035. return res
  5036. }
  5037. function stringifyObject (value) {
  5038. let res = '';
  5039. for (const key in value) {
  5040. if (value[key]) {
  5041. if (res) res += ' ';
  5042. res += key;
  5043. }
  5044. }
  5045. return res
  5046. }
  5047. /* */
  5048. const namespaceMap = {
  5049. svg: 'http://www.w3.org/2000/svg',
  5050. math: 'http://www.w3.org/1998/Math/MathML'
  5051. };
  5052. const isHTMLTag = makeMap(
  5053. 'html,body,base,head,link,meta,style,title,' +
  5054. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5055. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5056. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5057. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5058. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5059. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5060. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5061. 'output,progress,select,textarea,' +
  5062. 'details,dialog,menu,menuitem,summary,' +
  5063. 'content,element,shadow,template,blockquote,iframe,tfoot'
  5064. );
  5065. // this map is intentionally selective, only covering SVG elements that may
  5066. // contain child elements.
  5067. const isSVG = makeMap(
  5068. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5069. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5070. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  5071. true
  5072. );
  5073. const isPreTag = (tag) => tag === 'pre';
  5074. const isReservedTag = (tag) => {
  5075. return isHTMLTag(tag) || isSVG(tag)
  5076. };
  5077. function getTagNamespace (tag) {
  5078. if (isSVG(tag)) {
  5079. return 'svg'
  5080. }
  5081. // basic support for MathML
  5082. // note it doesn't support other MathML elements being component roots
  5083. if (tag === 'math') {
  5084. return 'math'
  5085. }
  5086. }
  5087. const unknownElementCache = Object.create(null);
  5088. function isUnknownElement (tag) {
  5089. /* istanbul ignore if */
  5090. if (!inBrowser) {
  5091. return true
  5092. }
  5093. if (isReservedTag(tag)) {
  5094. return false
  5095. }
  5096. tag = tag.toLowerCase();
  5097. /* istanbul ignore if */
  5098. if (unknownElementCache[tag] != null) {
  5099. return unknownElementCache[tag]
  5100. }
  5101. const el = document.createElement(tag);
  5102. if (tag.indexOf('-') > -1) {
  5103. // http://stackoverflow.com/a/28210364/1070244
  5104. return (unknownElementCache[tag] = (
  5105. el.constructor === window.HTMLUnknownElement ||
  5106. el.constructor === window.HTMLElement
  5107. ))
  5108. } else {
  5109. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  5110. }
  5111. }
  5112. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  5113. /* */
  5114. /**
  5115. * Query an element selector if it's not an element already.
  5116. */
  5117. function query (el) {
  5118. if (typeof el === 'string') {
  5119. const selected = document.querySelector(el);
  5120. if (!selected) {
  5121. warn(
  5122. 'Cannot find element: ' + el
  5123. );
  5124. return document.createElement('div')
  5125. }
  5126. return selected
  5127. } else {
  5128. return el
  5129. }
  5130. }
  5131. /* */
  5132. function createElement$1 (tagName, vnode) {
  5133. const elm = document.createElement(tagName);
  5134. if (tagName !== 'select') {
  5135. return elm
  5136. }
  5137. // false or null will remove the attribute but undefined will not
  5138. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  5139. elm.setAttribute('multiple', 'multiple');
  5140. }
  5141. return elm
  5142. }
  5143. function createElementNS (namespace, tagName) {
  5144. return document.createElementNS(namespaceMap[namespace], tagName)
  5145. }
  5146. function createTextNode (text) {
  5147. return document.createTextNode(text)
  5148. }
  5149. function createComment (text) {
  5150. return document.createComment(text)
  5151. }
  5152. function insertBefore (parentNode, newNode, referenceNode) {
  5153. parentNode.insertBefore(newNode, referenceNode);
  5154. }
  5155. function removeChild (node, child) {
  5156. node.removeChild(child);
  5157. }
  5158. function appendChild (node, child) {
  5159. node.appendChild(child);
  5160. }
  5161. function parentNode (node) {
  5162. return node.parentNode
  5163. }
  5164. function nextSibling (node) {
  5165. return node.nextSibling
  5166. }
  5167. function tagName (node) {
  5168. return node.tagName
  5169. }
  5170. function setTextContent (node, text) {
  5171. node.textContent = text;
  5172. }
  5173. function setStyleScope (node, scopeId) {
  5174. node.setAttribute(scopeId, '');
  5175. }
  5176. var nodeOps = /*#__PURE__*/Object.freeze({
  5177. createElement: createElement$1,
  5178. createElementNS: createElementNS,
  5179. createTextNode: createTextNode,
  5180. createComment: createComment,
  5181. insertBefore: insertBefore,
  5182. removeChild: removeChild,
  5183. appendChild: appendChild,
  5184. parentNode: parentNode,
  5185. nextSibling: nextSibling,
  5186. tagName: tagName,
  5187. setTextContent: setTextContent,
  5188. setStyleScope: setStyleScope
  5189. });
  5190. /* */
  5191. var ref = {
  5192. create (_, vnode) {
  5193. registerRef(vnode);
  5194. },
  5195. update (oldVnode, vnode) {
  5196. if (oldVnode.data.ref !== vnode.data.ref) {
  5197. registerRef(oldVnode, true);
  5198. registerRef(vnode);
  5199. }
  5200. },
  5201. destroy (vnode) {
  5202. registerRef(vnode, true);
  5203. }
  5204. };
  5205. function registerRef (vnode, isRemoval) {
  5206. const key = vnode.data.ref;
  5207. if (!isDef(key)) return
  5208. const vm = vnode.context;
  5209. const ref = vnode.componentInstance || vnode.elm;
  5210. const refs = vm.$refs;
  5211. if (isRemoval) {
  5212. if (Array.isArray(refs[key])) {
  5213. remove(refs[key], ref);
  5214. } else if (refs[key] === ref) {
  5215. refs[key] = undefined;
  5216. }
  5217. } else {
  5218. if (vnode.data.refInFor) {
  5219. if (!Array.isArray(refs[key])) {
  5220. refs[key] = [ref];
  5221. } else if (refs[key].indexOf(ref) < 0) {
  5222. // $flow-disable-line
  5223. refs[key].push(ref);
  5224. }
  5225. } else {
  5226. refs[key] = ref;
  5227. }
  5228. }
  5229. }
  5230. /**
  5231. * Virtual DOM patching algorithm based on Snabbdom by
  5232. * Simon Friis Vindum (@paldepind)
  5233. * Licensed under the MIT License
  5234. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  5235. *
  5236. * modified by Evan You (@yyx990803)
  5237. *
  5238. * Not type-checking this because this file is perf-critical and the cost
  5239. * of making flow understand it is not worth it.
  5240. */
  5241. const emptyNode = new VNode('', {}, []);
  5242. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  5243. function sameVnode (a, b) {
  5244. return (
  5245. a.key === b.key && (
  5246. (
  5247. a.tag === b.tag &&
  5248. a.isComment === b.isComment &&
  5249. isDef(a.data) === isDef(b.data) &&
  5250. sameInputType(a, b)
  5251. ) || (
  5252. isTrue(a.isAsyncPlaceholder) &&
  5253. a.asyncFactory === b.asyncFactory &&
  5254. isUndef(b.asyncFactory.error)
  5255. )
  5256. )
  5257. )
  5258. }
  5259. function sameInputType (a, b) {
  5260. if (a.tag !== 'input') return true
  5261. let i;
  5262. const typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  5263. const typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  5264. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  5265. }
  5266. function createKeyToOldIdx (children, beginIdx, endIdx) {
  5267. let i, key;
  5268. const map = {};
  5269. for (i = beginIdx; i <= endIdx; ++i) {
  5270. key = children[i].key;
  5271. if (isDef(key)) map[key] = i;
  5272. }
  5273. return map
  5274. }
  5275. function createPatchFunction (backend) {
  5276. let i, j;
  5277. const cbs = {};
  5278. const { modules, nodeOps } = backend;
  5279. for (i = 0; i < hooks.length; ++i) {
  5280. cbs[hooks[i]] = [];
  5281. for (j = 0; j < modules.length; ++j) {
  5282. if (isDef(modules[j][hooks[i]])) {
  5283. cbs[hooks[i]].push(modules[j][hooks[i]]);
  5284. }
  5285. }
  5286. }
  5287. function emptyNodeAt (elm) {
  5288. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  5289. }
  5290. function createRmCb (childElm, listeners) {
  5291. function remove$$1 () {
  5292. if (--remove$$1.listeners === 0) {
  5293. removeNode(childElm);
  5294. }
  5295. }
  5296. remove$$1.listeners = listeners;
  5297. return remove$$1
  5298. }
  5299. function removeNode (el) {
  5300. const parent = nodeOps.parentNode(el);
  5301. // element may have already been removed due to v-html / v-text
  5302. if (isDef(parent)) {
  5303. nodeOps.removeChild(parent, el);
  5304. }
  5305. }
  5306. function isUnknownElement$$1 (vnode, inVPre) {
  5307. return (
  5308. !inVPre &&
  5309. !vnode.ns &&
  5310. !(
  5311. config.ignoredElements.length &&
  5312. config.ignoredElements.some(ignore => {
  5313. return isRegExp(ignore)
  5314. ? ignore.test(vnode.tag)
  5315. : ignore === vnode.tag
  5316. })
  5317. ) &&
  5318. config.isUnknownElement(vnode.tag)
  5319. )
  5320. }
  5321. let creatingElmInVPre = 0;
  5322. function createElm (
  5323. vnode,
  5324. insertedVnodeQueue,
  5325. parentElm,
  5326. refElm,
  5327. nested,
  5328. ownerArray,
  5329. index
  5330. ) {
  5331. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5332. // This vnode was used in a previous render!
  5333. // now it's used as a new node, overwriting its elm would cause
  5334. // potential patch errors down the road when it's used as an insertion
  5335. // reference node. Instead, we clone the node on-demand before creating
  5336. // associated DOM element for it.
  5337. vnode = ownerArray[index] = cloneVNode(vnode);
  5338. }
  5339. vnode.isRootInsert = !nested; // for transition enter check
  5340. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  5341. return
  5342. }
  5343. const data = vnode.data;
  5344. const children = vnode.children;
  5345. const tag = vnode.tag;
  5346. if (isDef(tag)) {
  5347. {
  5348. if (data && data.pre) {
  5349. creatingElmInVPre++;
  5350. }
  5351. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  5352. warn(
  5353. 'Unknown custom element: <' + tag + '> - did you ' +
  5354. 'register the component correctly? For recursive components, ' +
  5355. 'make sure to provide the "name" option.',
  5356. vnode.context
  5357. );
  5358. }
  5359. }
  5360. vnode.elm = vnode.ns
  5361. ? nodeOps.createElementNS(vnode.ns, tag)
  5362. : nodeOps.createElement(tag, vnode);
  5363. setScope(vnode);
  5364. /* istanbul ignore if */
  5365. {
  5366. createChildren(vnode, children, insertedVnodeQueue);
  5367. if (isDef(data)) {
  5368. invokeCreateHooks(vnode, insertedVnodeQueue);
  5369. }
  5370. insert(parentElm, vnode.elm, refElm);
  5371. }
  5372. if (data && data.pre) {
  5373. creatingElmInVPre--;
  5374. }
  5375. } else if (isTrue(vnode.isComment)) {
  5376. vnode.elm = nodeOps.createComment(vnode.text);
  5377. insert(parentElm, vnode.elm, refElm);
  5378. } else {
  5379. vnode.elm = nodeOps.createTextNode(vnode.text);
  5380. insert(parentElm, vnode.elm, refElm);
  5381. }
  5382. }
  5383. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5384. let i = vnode.data;
  5385. if (isDef(i)) {
  5386. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  5387. if (isDef(i = i.hook) && isDef(i = i.init)) {
  5388. i(vnode, false /* hydrating */);
  5389. }
  5390. // after calling the init hook, if the vnode is a child component
  5391. // it should've created a child instance and mounted it. the child
  5392. // component also has set the placeholder vnode's elm.
  5393. // in that case we can just return the element and be done.
  5394. if (isDef(vnode.componentInstance)) {
  5395. initComponent(vnode, insertedVnodeQueue);
  5396. insert(parentElm, vnode.elm, refElm);
  5397. if (isTrue(isReactivated)) {
  5398. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  5399. }
  5400. return true
  5401. }
  5402. }
  5403. }
  5404. function initComponent (vnode, insertedVnodeQueue) {
  5405. if (isDef(vnode.data.pendingInsert)) {
  5406. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  5407. vnode.data.pendingInsert = null;
  5408. }
  5409. vnode.elm = vnode.componentInstance.$el;
  5410. if (isPatchable(vnode)) {
  5411. invokeCreateHooks(vnode, insertedVnodeQueue);
  5412. setScope(vnode);
  5413. } else {
  5414. // empty component root.
  5415. // skip all element-related modules except for ref (#3455)
  5416. registerRef(vnode);
  5417. // make sure to invoke the insert hook
  5418. insertedVnodeQueue.push(vnode);
  5419. }
  5420. }
  5421. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5422. let i;
  5423. // hack for #4339: a reactivated component with inner transition
  5424. // does not trigger because the inner node's created hooks are not called
  5425. // again. It's not ideal to involve module-specific logic in here but
  5426. // there doesn't seem to be a better way to do it.
  5427. let innerNode = vnode;
  5428. while (innerNode.componentInstance) {
  5429. innerNode = innerNode.componentInstance._vnode;
  5430. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  5431. for (i = 0; i < cbs.activate.length; ++i) {
  5432. cbs.activate[i](emptyNode, innerNode);
  5433. }
  5434. insertedVnodeQueue.push(innerNode);
  5435. break
  5436. }
  5437. }
  5438. // unlike a newly created component,
  5439. // a reactivated keep-alive component doesn't insert itself
  5440. insert(parentElm, vnode.elm, refElm);
  5441. }
  5442. function insert (parent, elm, ref$$1) {
  5443. if (isDef(parent)) {
  5444. if (isDef(ref$$1)) {
  5445. if (nodeOps.parentNode(ref$$1) === parent) {
  5446. nodeOps.insertBefore(parent, elm, ref$$1);
  5447. }
  5448. } else {
  5449. nodeOps.appendChild(parent, elm);
  5450. }
  5451. }
  5452. }
  5453. function createChildren (vnode, children, insertedVnodeQueue) {
  5454. if (Array.isArray(children)) {
  5455. {
  5456. checkDuplicateKeys(children);
  5457. }
  5458. for (let i = 0; i < children.length; ++i) {
  5459. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  5460. }
  5461. } else if (isPrimitive(vnode.text)) {
  5462. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  5463. }
  5464. }
  5465. function isPatchable (vnode) {
  5466. while (vnode.componentInstance) {
  5467. vnode = vnode.componentInstance._vnode;
  5468. }
  5469. return isDef(vnode.tag)
  5470. }
  5471. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  5472. for (let i = 0; i < cbs.create.length; ++i) {
  5473. cbs.create[i](emptyNode, vnode);
  5474. }
  5475. i = vnode.data.hook; // Reuse variable
  5476. if (isDef(i)) {
  5477. if (isDef(i.create)) i.create(emptyNode, vnode);
  5478. if (isDef(i.insert)) insertedVnodeQueue.push(vnode);
  5479. }
  5480. }
  5481. // set scope id attribute for scoped CSS.
  5482. // this is implemented as a special case to avoid the overhead
  5483. // of going through the normal attribute patching process.
  5484. function setScope (vnode) {
  5485. let i;
  5486. if (isDef(i = vnode.fnScopeId)) {
  5487. nodeOps.setStyleScope(vnode.elm, i);
  5488. } else {
  5489. let ancestor = vnode;
  5490. while (ancestor) {
  5491. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  5492. nodeOps.setStyleScope(vnode.elm, i);
  5493. }
  5494. ancestor = ancestor.parent;
  5495. }
  5496. }
  5497. // for slot content they should also get the scopeId from the host instance.
  5498. if (isDef(i = activeInstance) &&
  5499. i !== vnode.context &&
  5500. i !== vnode.fnContext &&
  5501. isDef(i = i.$options._scopeId)
  5502. ) {
  5503. nodeOps.setStyleScope(vnode.elm, i);
  5504. }
  5505. }
  5506. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  5507. for (; startIdx <= endIdx; ++startIdx) {
  5508. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  5509. }
  5510. }
  5511. function invokeDestroyHook (vnode) {
  5512. let i, j;
  5513. const data = vnode.data;
  5514. if (isDef(data)) {
  5515. if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode);
  5516. for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode);
  5517. }
  5518. if (isDef(i = vnode.children)) {
  5519. for (j = 0; j < vnode.children.length; ++j) {
  5520. invokeDestroyHook(vnode.children[j]);
  5521. }
  5522. }
  5523. }
  5524. function removeVnodes (vnodes, startIdx, endIdx) {
  5525. for (; startIdx <= endIdx; ++startIdx) {
  5526. const ch = vnodes[startIdx];
  5527. if (isDef(ch)) {
  5528. if (isDef(ch.tag)) {
  5529. removeAndInvokeRemoveHook(ch);
  5530. invokeDestroyHook(ch);
  5531. } else { // Text node
  5532. removeNode(ch.elm);
  5533. }
  5534. }
  5535. }
  5536. }
  5537. function removeAndInvokeRemoveHook (vnode, rm) {
  5538. if (isDef(rm) || isDef(vnode.data)) {
  5539. let i;
  5540. const listeners = cbs.remove.length + 1;
  5541. if (isDef(rm)) {
  5542. // we have a recursively passed down rm callback
  5543. // increase the listeners count
  5544. rm.listeners += listeners;
  5545. } else {
  5546. // directly removing
  5547. rm = createRmCb(vnode.elm, listeners);
  5548. }
  5549. // recursively invoke hooks on child component root node
  5550. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  5551. removeAndInvokeRemoveHook(i, rm);
  5552. }
  5553. for (i = 0; i < cbs.remove.length; ++i) {
  5554. cbs.remove[i](vnode, rm);
  5555. }
  5556. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  5557. i(vnode, rm);
  5558. } else {
  5559. rm();
  5560. }
  5561. } else {
  5562. removeNode(vnode.elm);
  5563. }
  5564. }
  5565. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  5566. let oldStartIdx = 0;
  5567. let newStartIdx = 0;
  5568. let oldEndIdx = oldCh.length - 1;
  5569. let oldStartVnode = oldCh[0];
  5570. let oldEndVnode = oldCh[oldEndIdx];
  5571. let newEndIdx = newCh.length - 1;
  5572. let newStartVnode = newCh[0];
  5573. let newEndVnode = newCh[newEndIdx];
  5574. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  5575. // removeOnly is a special flag used only by <transition-group>
  5576. // to ensure removed elements stay in correct relative positions
  5577. // during leaving transitions
  5578. const canMove = !removeOnly;
  5579. {
  5580. checkDuplicateKeys(newCh);
  5581. }
  5582. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  5583. if (isUndef(oldStartVnode)) {
  5584. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  5585. } else if (isUndef(oldEndVnode)) {
  5586. oldEndVnode = oldCh[--oldEndIdx];
  5587. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  5588. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5589. oldStartVnode = oldCh[++oldStartIdx];
  5590. newStartVnode = newCh[++newStartIdx];
  5591. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  5592. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5593. oldEndVnode = oldCh[--oldEndIdx];
  5594. newEndVnode = newCh[--newEndIdx];
  5595. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  5596. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5597. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  5598. oldStartVnode = oldCh[++oldStartIdx];
  5599. newEndVnode = newCh[--newEndIdx];
  5600. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  5601. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5602. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  5603. oldEndVnode = oldCh[--oldEndIdx];
  5604. newStartVnode = newCh[++newStartIdx];
  5605. } else {
  5606. if (isUndef(oldKeyToIdx)) oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  5607. idxInOld = isDef(newStartVnode.key)
  5608. ? oldKeyToIdx[newStartVnode.key]
  5609. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  5610. if (isUndef(idxInOld)) { // New element
  5611. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5612. } else {
  5613. vnodeToMove = oldCh[idxInOld];
  5614. if (sameVnode(vnodeToMove, newStartVnode)) {
  5615. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5616. oldCh[idxInOld] = undefined;
  5617. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  5618. } else {
  5619. // same key but different element. treat as new element
  5620. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5621. }
  5622. }
  5623. newStartVnode = newCh[++newStartIdx];
  5624. }
  5625. }
  5626. if (oldStartIdx > oldEndIdx) {
  5627. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  5628. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  5629. } else if (newStartIdx > newEndIdx) {
  5630. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  5631. }
  5632. }
  5633. function checkDuplicateKeys (children) {
  5634. const seenKeys = {};
  5635. for (let i = 0; i < children.length; i++) {
  5636. const vnode = children[i];
  5637. const key = vnode.key;
  5638. if (isDef(key)) {
  5639. if (seenKeys[key]) {
  5640. warn(
  5641. `Duplicate keys detected: '${key}'. This may cause an update error.`,
  5642. vnode.context
  5643. );
  5644. } else {
  5645. seenKeys[key] = true;
  5646. }
  5647. }
  5648. }
  5649. }
  5650. function findIdxInOld (node, oldCh, start, end) {
  5651. for (let i = start; i < end; i++) {
  5652. const c = oldCh[i];
  5653. if (isDef(c) && sameVnode(node, c)) return i
  5654. }
  5655. }
  5656. function patchVnode (
  5657. oldVnode,
  5658. vnode,
  5659. insertedVnodeQueue,
  5660. ownerArray,
  5661. index,
  5662. removeOnly
  5663. ) {
  5664. if (oldVnode === vnode) {
  5665. return
  5666. }
  5667. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5668. // clone reused vnode
  5669. vnode = ownerArray[index] = cloneVNode(vnode);
  5670. }
  5671. const elm = vnode.elm = oldVnode.elm;
  5672. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  5673. if (isDef(vnode.asyncFactory.resolved)) {
  5674. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  5675. } else {
  5676. vnode.isAsyncPlaceholder = true;
  5677. }
  5678. return
  5679. }
  5680. // reuse element for static trees.
  5681. // note we only do this if the vnode is cloned -
  5682. // if the new node is not cloned it means the render functions have been
  5683. // reset by the hot-reload-api and we need to do a proper re-render.
  5684. if (isTrue(vnode.isStatic) &&
  5685. isTrue(oldVnode.isStatic) &&
  5686. vnode.key === oldVnode.key &&
  5687. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  5688. ) {
  5689. vnode.componentInstance = oldVnode.componentInstance;
  5690. return
  5691. }
  5692. let i;
  5693. const data = vnode.data;
  5694. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  5695. i(oldVnode, vnode);
  5696. }
  5697. const oldCh = oldVnode.children;
  5698. const ch = vnode.children;
  5699. if (isDef(data) && isPatchable(vnode)) {
  5700. for (i = 0; i < cbs.update.length; ++i) cbs.update[i](oldVnode, vnode);
  5701. if (isDef(i = data.hook) && isDef(i = i.update)) i(oldVnode, vnode);
  5702. }
  5703. if (isUndef(vnode.text)) {
  5704. if (isDef(oldCh) && isDef(ch)) {
  5705. if (oldCh !== ch) updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  5706. } else if (isDef(ch)) {
  5707. {
  5708. checkDuplicateKeys(ch);
  5709. }
  5710. if (isDef(oldVnode.text)) nodeOps.setTextContent(elm, '');
  5711. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  5712. } else if (isDef(oldCh)) {
  5713. removeVnodes(oldCh, 0, oldCh.length - 1);
  5714. } else if (isDef(oldVnode.text)) {
  5715. nodeOps.setTextContent(elm, '');
  5716. }
  5717. } else if (oldVnode.text !== vnode.text) {
  5718. nodeOps.setTextContent(elm, vnode.text);
  5719. }
  5720. if (isDef(data)) {
  5721. if (isDef(i = data.hook) && isDef(i = i.postpatch)) i(oldVnode, vnode);
  5722. }
  5723. }
  5724. function invokeInsertHook (vnode, queue, initial) {
  5725. // delay insert hooks for component root nodes, invoke them after the
  5726. // element is really inserted
  5727. if (isTrue(initial) && isDef(vnode.parent)) {
  5728. vnode.parent.data.pendingInsert = queue;
  5729. } else {
  5730. for (let i = 0; i < queue.length; ++i) {
  5731. queue[i].data.hook.insert(queue[i]);
  5732. }
  5733. }
  5734. }
  5735. let hydrationBailed = false;
  5736. // list of modules that can skip create hook during hydration because they
  5737. // are already rendered on the client or has no need for initialization
  5738. // Note: style is excluded because it relies on initial clone for future
  5739. // deep updates (#7063).
  5740. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  5741. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  5742. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  5743. let i;
  5744. const { tag, data, children } = vnode;
  5745. inVPre = inVPre || (data && data.pre);
  5746. vnode.elm = elm;
  5747. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  5748. vnode.isAsyncPlaceholder = true;
  5749. return true
  5750. }
  5751. // assert node match
  5752. {
  5753. if (!assertNodeMatch(elm, vnode, inVPre)) {
  5754. return false
  5755. }
  5756. }
  5757. if (isDef(data)) {
  5758. if (isDef(i = data.hook) && isDef(i = i.init)) i(vnode, true /* hydrating */);
  5759. if (isDef(i = vnode.componentInstance)) {
  5760. // child component. it should have hydrated its own tree.
  5761. initComponent(vnode, insertedVnodeQueue);
  5762. return true
  5763. }
  5764. }
  5765. if (isDef(tag)) {
  5766. if (isDef(children)) {
  5767. // empty element, allow client to pick up and populate children
  5768. if (!elm.hasChildNodes()) {
  5769. createChildren(vnode, children, insertedVnodeQueue);
  5770. } else {
  5771. // v-html and domProps: innerHTML
  5772. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  5773. if (i !== elm.innerHTML) {
  5774. /* istanbul ignore if */
  5775. if (typeof console !== 'undefined' &&
  5776. !hydrationBailed
  5777. ) {
  5778. hydrationBailed = true;
  5779. console.warn('Parent: ', elm);
  5780. console.warn('server innerHTML: ', i);
  5781. console.warn('client innerHTML: ', elm.innerHTML);
  5782. }
  5783. return false
  5784. }
  5785. } else {
  5786. // iterate and compare children lists
  5787. let childrenMatch = true;
  5788. let childNode = elm.firstChild;
  5789. for (let i = 0; i < children.length; i++) {
  5790. if (!childNode || !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  5791. childrenMatch = false;
  5792. break
  5793. }
  5794. childNode = childNode.nextSibling;
  5795. }
  5796. // if childNode is not null, it means the actual childNodes list is
  5797. // longer than the virtual children list.
  5798. if (!childrenMatch || childNode) {
  5799. /* istanbul ignore if */
  5800. if (typeof console !== 'undefined' &&
  5801. !hydrationBailed
  5802. ) {
  5803. hydrationBailed = true;
  5804. console.warn('Parent: ', elm);
  5805. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  5806. }
  5807. return false
  5808. }
  5809. }
  5810. }
  5811. }
  5812. if (isDef(data)) {
  5813. let fullInvoke = false;
  5814. for (const key in data) {
  5815. if (!isRenderedModule(key)) {
  5816. fullInvoke = true;
  5817. invokeCreateHooks(vnode, insertedVnodeQueue);
  5818. break
  5819. }
  5820. }
  5821. if (!fullInvoke && data['class']) {
  5822. // ensure collecting deps for deep class bindings for future updates
  5823. traverse(data['class']);
  5824. }
  5825. }
  5826. } else if (elm.data !== vnode.text) {
  5827. elm.data = vnode.text;
  5828. }
  5829. return true
  5830. }
  5831. function assertNodeMatch (node, vnode, inVPre) {
  5832. if (isDef(vnode.tag)) {
  5833. return vnode.tag.indexOf('vue-component') === 0 || (
  5834. !isUnknownElement$$1(vnode, inVPre) &&
  5835. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  5836. )
  5837. } else {
  5838. return node.nodeType === (vnode.isComment ? 8 : 3)
  5839. }
  5840. }
  5841. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  5842. if (isUndef(vnode)) {
  5843. if (isDef(oldVnode)) invokeDestroyHook(oldVnode);
  5844. return
  5845. }
  5846. let isInitialPatch = false;
  5847. const insertedVnodeQueue = [];
  5848. if (isUndef(oldVnode)) {
  5849. // empty mount (likely as component), create new root element
  5850. isInitialPatch = true;
  5851. createElm(vnode, insertedVnodeQueue);
  5852. } else {
  5853. const isRealElement = isDef(oldVnode.nodeType);
  5854. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  5855. // patch existing root node
  5856. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  5857. } else {
  5858. if (isRealElement) {
  5859. // mounting to a real element
  5860. // check if this is server-rendered content and if we can perform
  5861. // a successful hydration.
  5862. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  5863. oldVnode.removeAttribute(SSR_ATTR);
  5864. hydrating = true;
  5865. }
  5866. if (isTrue(hydrating)) {
  5867. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  5868. invokeInsertHook(vnode, insertedVnodeQueue, true);
  5869. return oldVnode
  5870. } else {
  5871. warn(
  5872. 'The client-side rendered virtual DOM tree is not matching ' +
  5873. 'server-rendered content. This is likely caused by incorrect ' +
  5874. 'HTML markup, for example nesting block-level elements inside ' +
  5875. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  5876. 'full client-side render.'
  5877. );
  5878. }
  5879. }
  5880. // either not server-rendered, or hydration failed.
  5881. // create an empty node and replace it
  5882. oldVnode = emptyNodeAt(oldVnode);
  5883. }
  5884. // replacing existing element
  5885. const oldElm = oldVnode.elm;
  5886. const parentElm = nodeOps.parentNode(oldElm);
  5887. // create new node
  5888. createElm(
  5889. vnode,
  5890. insertedVnodeQueue,
  5891. // extremely rare edge case: do not insert if old element is in a
  5892. // leaving transition. Only happens when combining transition +
  5893. // keep-alive + HOCs. (#4590)
  5894. oldElm._leaveCb ? null : parentElm,
  5895. nodeOps.nextSibling(oldElm)
  5896. );
  5897. // update parent placeholder node element, recursively
  5898. if (isDef(vnode.parent)) {
  5899. let ancestor = vnode.parent;
  5900. const patchable = isPatchable(vnode);
  5901. while (ancestor) {
  5902. for (let i = 0; i < cbs.destroy.length; ++i) {
  5903. cbs.destroy[i](ancestor);
  5904. }
  5905. ancestor.elm = vnode.elm;
  5906. if (patchable) {
  5907. for (let i = 0; i < cbs.create.length; ++i) {
  5908. cbs.create[i](emptyNode, ancestor);
  5909. }
  5910. // #6513
  5911. // invoke insert hooks that may have been merged by create hooks.
  5912. // e.g. for directives that uses the "inserted" hook.
  5913. const insert = ancestor.data.hook.insert;
  5914. if (insert.merged) {
  5915. // start at index 1 to avoid re-invoking component mounted hook
  5916. for (let i = 1; i < insert.fns.length; i++) {
  5917. insert.fns[i]();
  5918. }
  5919. }
  5920. } else {
  5921. registerRef(ancestor);
  5922. }
  5923. ancestor = ancestor.parent;
  5924. }
  5925. }
  5926. // destroy old node
  5927. if (isDef(parentElm)) {
  5928. removeVnodes([oldVnode], 0, 0);
  5929. } else if (isDef(oldVnode.tag)) {
  5930. invokeDestroyHook(oldVnode);
  5931. }
  5932. }
  5933. }
  5934. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  5935. return vnode.elm
  5936. }
  5937. }
  5938. /* */
  5939. var directives = {
  5940. create: updateDirectives,
  5941. update: updateDirectives,
  5942. destroy: function unbindDirectives (vnode) {
  5943. updateDirectives(vnode, emptyNode);
  5944. }
  5945. };
  5946. function updateDirectives (oldVnode, vnode) {
  5947. if (oldVnode.data.directives || vnode.data.directives) {
  5948. _update(oldVnode, vnode);
  5949. }
  5950. }
  5951. function _update (oldVnode, vnode) {
  5952. const isCreate = oldVnode === emptyNode;
  5953. const isDestroy = vnode === emptyNode;
  5954. const oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  5955. const newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  5956. const dirsWithInsert = [];
  5957. const dirsWithPostpatch = [];
  5958. let key, oldDir, dir;
  5959. for (key in newDirs) {
  5960. oldDir = oldDirs[key];
  5961. dir = newDirs[key];
  5962. if (!oldDir) {
  5963. // new directive, bind
  5964. callHook$1(dir, 'bind', vnode, oldVnode);
  5965. if (dir.def && dir.def.inserted) {
  5966. dirsWithInsert.push(dir);
  5967. }
  5968. } else {
  5969. // existing directive, update
  5970. dir.oldValue = oldDir.value;
  5971. dir.oldArg = oldDir.arg;
  5972. callHook$1(dir, 'update', vnode, oldVnode);
  5973. if (dir.def && dir.def.componentUpdated) {
  5974. dirsWithPostpatch.push(dir);
  5975. }
  5976. }
  5977. }
  5978. if (dirsWithInsert.length) {
  5979. const callInsert = () => {
  5980. for (let i = 0; i < dirsWithInsert.length; i++) {
  5981. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  5982. }
  5983. };
  5984. if (isCreate) {
  5985. mergeVNodeHook(vnode, 'insert', callInsert);
  5986. } else {
  5987. callInsert();
  5988. }
  5989. }
  5990. if (dirsWithPostpatch.length) {
  5991. mergeVNodeHook(vnode, 'postpatch', () => {
  5992. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  5993. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  5994. }
  5995. });
  5996. }
  5997. if (!isCreate) {
  5998. for (key in oldDirs) {
  5999. if (!newDirs[key]) {
  6000. // no longer present, unbind
  6001. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  6002. }
  6003. }
  6004. }
  6005. }
  6006. const emptyModifiers = Object.create(null);
  6007. function normalizeDirectives$1 (
  6008. dirs,
  6009. vm
  6010. ) {
  6011. const res = Object.create(null);
  6012. if (!dirs) {
  6013. // $flow-disable-line
  6014. return res
  6015. }
  6016. let i, dir;
  6017. for (i = 0; i < dirs.length; i++) {
  6018. dir = dirs[i];
  6019. if (!dir.modifiers) {
  6020. // $flow-disable-line
  6021. dir.modifiers = emptyModifiers;
  6022. }
  6023. res[getRawDirName(dir)] = dir;
  6024. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  6025. }
  6026. // $flow-disable-line
  6027. return res
  6028. }
  6029. function getRawDirName (dir) {
  6030. return dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`
  6031. }
  6032. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  6033. const fn = dir.def && dir.def[hook];
  6034. if (fn) {
  6035. try {
  6036. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  6037. } catch (e) {
  6038. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  6039. }
  6040. }
  6041. }
  6042. var baseModules = [
  6043. ref,
  6044. directives
  6045. ];
  6046. /* */
  6047. function updateAttrs (oldVnode, vnode) {
  6048. const opts = vnode.componentOptions;
  6049. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  6050. return
  6051. }
  6052. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  6053. return
  6054. }
  6055. let key, cur, old;
  6056. const elm = vnode.elm;
  6057. const oldAttrs = oldVnode.data.attrs || {};
  6058. let attrs = vnode.data.attrs || {};
  6059. // clone observed objects, as the user probably wants to mutate it
  6060. if (isDef(attrs.__ob__)) {
  6061. attrs = vnode.data.attrs = extend({}, attrs);
  6062. }
  6063. for (key in attrs) {
  6064. cur = attrs[key];
  6065. old = oldAttrs[key];
  6066. if (old !== cur) {
  6067. setAttr(elm, key, cur);
  6068. }
  6069. }
  6070. // #4391: in IE9, setting type can reset value for input[type=radio]
  6071. // #6666: IE/Edge forces progress value down to 1 before setting a max
  6072. /* istanbul ignore if */
  6073. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  6074. setAttr(elm, 'value', attrs.value);
  6075. }
  6076. for (key in oldAttrs) {
  6077. if (isUndef(attrs[key])) {
  6078. if (isXlink(key)) {
  6079. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6080. } else if (!isEnumeratedAttr(key)) {
  6081. elm.removeAttribute(key);
  6082. }
  6083. }
  6084. }
  6085. }
  6086. function setAttr (el, key, value) {
  6087. if (el.tagName.indexOf('-') > -1) {
  6088. baseSetAttr(el, key, value);
  6089. } else if (isBooleanAttr(key)) {
  6090. // set attribute for blank value
  6091. // e.g. <option disabled>Select one</option>
  6092. if (isFalsyAttrValue(value)) {
  6093. el.removeAttribute(key);
  6094. } else {
  6095. // technically allowfullscreen is a boolean attribute for <iframe>,
  6096. // but Flash expects a value of "true" when used on <embed> tag
  6097. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  6098. ? 'true'
  6099. : key;
  6100. el.setAttribute(key, value);
  6101. }
  6102. } else if (isEnumeratedAttr(key)) {
  6103. el.setAttribute(key, convertEnumeratedValue(key, value));
  6104. } else if (isXlink(key)) {
  6105. if (isFalsyAttrValue(value)) {
  6106. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6107. } else {
  6108. el.setAttributeNS(xlinkNS, key, value);
  6109. }
  6110. } else {
  6111. baseSetAttr(el, key, value);
  6112. }
  6113. }
  6114. function baseSetAttr (el, key, value) {
  6115. if (isFalsyAttrValue(value)) {
  6116. el.removeAttribute(key);
  6117. } else {
  6118. // #7138: IE10 & 11 fires input event when setting placeholder on
  6119. // <textarea>... block the first input event and remove the blocker
  6120. // immediately.
  6121. /* istanbul ignore if */
  6122. if (
  6123. isIE && !isIE9 &&
  6124. el.tagName === 'TEXTAREA' &&
  6125. key === 'placeholder' && value !== '' && !el.__ieph
  6126. ) {
  6127. const blocker = e => {
  6128. e.stopImmediatePropagation();
  6129. el.removeEventListener('input', blocker);
  6130. };
  6131. el.addEventListener('input', blocker);
  6132. // $flow-disable-line
  6133. el.__ieph = true; /* IE placeholder patched */
  6134. }
  6135. el.setAttribute(key, value);
  6136. }
  6137. }
  6138. var attrs = {
  6139. create: updateAttrs,
  6140. update: updateAttrs
  6141. };
  6142. /* */
  6143. function updateClass (oldVnode, vnode) {
  6144. const el = vnode.elm;
  6145. const data = vnode.data;
  6146. const oldData = oldVnode.data;
  6147. if (
  6148. isUndef(data.staticClass) &&
  6149. isUndef(data.class) && (
  6150. isUndef(oldData) || (
  6151. isUndef(oldData.staticClass) &&
  6152. isUndef(oldData.class)
  6153. )
  6154. )
  6155. ) {
  6156. return
  6157. }
  6158. let cls = genClassForVnode(vnode);
  6159. // handle transition classes
  6160. const transitionClass = el._transitionClasses;
  6161. if (isDef(transitionClass)) {
  6162. cls = concat(cls, stringifyClass(transitionClass));
  6163. }
  6164. // set the class
  6165. if (cls !== el._prevClass) {
  6166. el.setAttribute('class', cls);
  6167. el._prevClass = cls;
  6168. }
  6169. }
  6170. var klass = {
  6171. create: updateClass,
  6172. update: updateClass
  6173. };
  6174. /* */
  6175. const validDivisionCharRE = /[\w).+\-_$\]]/;
  6176. function parseFilters (exp) {
  6177. let inSingle = false;
  6178. let inDouble = false;
  6179. let inTemplateString = false;
  6180. let inRegex = false;
  6181. let curly = 0;
  6182. let square = 0;
  6183. let paren = 0;
  6184. let lastFilterIndex = 0;
  6185. let c, prev, i, expression, filters;
  6186. for (i = 0; i < exp.length; i++) {
  6187. prev = c;
  6188. c = exp.charCodeAt(i);
  6189. if (inSingle) {
  6190. if (c === 0x27 && prev !== 0x5C) inSingle = false;
  6191. } else if (inDouble) {
  6192. if (c === 0x22 && prev !== 0x5C) inDouble = false;
  6193. } else if (inTemplateString) {
  6194. if (c === 0x60 && prev !== 0x5C) inTemplateString = false;
  6195. } else if (inRegex) {
  6196. if (c === 0x2f && prev !== 0x5C) inRegex = false;
  6197. } else if (
  6198. c === 0x7C && // pipe
  6199. exp.charCodeAt(i + 1) !== 0x7C &&
  6200. exp.charCodeAt(i - 1) !== 0x7C &&
  6201. !curly && !square && !paren
  6202. ) {
  6203. if (expression === undefined) {
  6204. // first filter, end of expression
  6205. lastFilterIndex = i + 1;
  6206. expression = exp.slice(0, i).trim();
  6207. } else {
  6208. pushFilter();
  6209. }
  6210. } else {
  6211. switch (c) {
  6212. case 0x22: inDouble = true; break // "
  6213. case 0x27: inSingle = true; break // '
  6214. case 0x60: inTemplateString = true; break // `
  6215. case 0x28: paren++; break // (
  6216. case 0x29: paren--; break // )
  6217. case 0x5B: square++; break // [
  6218. case 0x5D: square--; break // ]
  6219. case 0x7B: curly++; break // {
  6220. case 0x7D: curly--; break // }
  6221. }
  6222. if (c === 0x2f) { // /
  6223. let j = i - 1;
  6224. let p;
  6225. // find first non-whitespace prev char
  6226. for (; j >= 0; j--) {
  6227. p = exp.charAt(j);
  6228. if (p !== ' ') break
  6229. }
  6230. if (!p || !validDivisionCharRE.test(p)) {
  6231. inRegex = true;
  6232. }
  6233. }
  6234. }
  6235. }
  6236. if (expression === undefined) {
  6237. expression = exp.slice(0, i).trim();
  6238. } else if (lastFilterIndex !== 0) {
  6239. pushFilter();
  6240. }
  6241. function pushFilter () {
  6242. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  6243. lastFilterIndex = i + 1;
  6244. }
  6245. if (filters) {
  6246. for (i = 0; i < filters.length; i++) {
  6247. expression = wrapFilter(expression, filters[i]);
  6248. }
  6249. }
  6250. return expression
  6251. }
  6252. function wrapFilter (exp, filter) {
  6253. const i = filter.indexOf('(');
  6254. if (i < 0) {
  6255. // _f: resolveFilter
  6256. return `_f("${filter}")(${exp})`
  6257. } else {
  6258. const name = filter.slice(0, i);
  6259. const args = filter.slice(i + 1);
  6260. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`
  6261. }
  6262. }
  6263. /* */
  6264. /* eslint-disable no-unused-vars */
  6265. function baseWarn (msg, range) {
  6266. console.error(`[Vue compiler]: ${msg}`);
  6267. }
  6268. /* eslint-enable no-unused-vars */
  6269. function pluckModuleFunction (
  6270. modules,
  6271. key
  6272. ) {
  6273. return modules
  6274. ? modules.map(m => m[key]).filter(_ => _)
  6275. : []
  6276. }
  6277. function addProp (el, name, value, range, dynamic) {
  6278. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  6279. el.plain = false;
  6280. }
  6281. function addAttr (el, name, value, range, dynamic) {
  6282. const attrs = dynamic
  6283. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  6284. : (el.attrs || (el.attrs = []));
  6285. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  6286. el.plain = false;
  6287. }
  6288. // add a raw attr (use this in preTransforms)
  6289. function addRawAttr (el, name, value, range) {
  6290. el.attrsMap[name] = value;
  6291. el.attrsList.push(rangeSetItem({ name, value }, range));
  6292. }
  6293. function addDirective (
  6294. el,
  6295. name,
  6296. rawName,
  6297. value,
  6298. arg,
  6299. isDynamicArg,
  6300. modifiers,
  6301. range
  6302. ) {
  6303. (el.directives || (el.directives = [])).push(rangeSetItem({
  6304. name,
  6305. rawName,
  6306. value,
  6307. arg,
  6308. isDynamicArg,
  6309. modifiers
  6310. }, range));
  6311. el.plain = false;
  6312. }
  6313. function prependModifierMarker (symbol, name, dynamic) {
  6314. return dynamic
  6315. ? `_p(${name},"${symbol}")`
  6316. : symbol + name // mark the event as captured
  6317. }
  6318. function addHandler (
  6319. el,
  6320. name,
  6321. value,
  6322. modifiers,
  6323. important,
  6324. warn,
  6325. range,
  6326. dynamic
  6327. ) {
  6328. modifiers = modifiers || emptyObject;
  6329. // warn prevent and passive modifier
  6330. /* istanbul ignore if */
  6331. if (
  6332. warn &&
  6333. modifiers.prevent && modifiers.passive
  6334. ) {
  6335. warn(
  6336. 'passive and prevent can\'t be used together. ' +
  6337. 'Passive handler can\'t prevent default event.',
  6338. range
  6339. );
  6340. }
  6341. // normalize click.right and click.middle since they don't actually fire
  6342. // this is technically browser-specific, but at least for now browsers are
  6343. // the only target envs that have right/middle clicks.
  6344. if (modifiers.right) {
  6345. if (dynamic) {
  6346. name = `(${name})==='click'?'contextmenu':(${name})`;
  6347. } else if (name === 'click') {
  6348. name = 'contextmenu';
  6349. delete modifiers.right;
  6350. }
  6351. } else if (modifiers.middle) {
  6352. if (dynamic) {
  6353. name = `(${name})==='click'?'mouseup':(${name})`;
  6354. } else if (name === 'click') {
  6355. name = 'mouseup';
  6356. }
  6357. }
  6358. // check capture modifier
  6359. if (modifiers.capture) {
  6360. delete modifiers.capture;
  6361. name = prependModifierMarker('!', name, dynamic);
  6362. }
  6363. if (modifiers.once) {
  6364. delete modifiers.once;
  6365. name = prependModifierMarker('~', name, dynamic);
  6366. }
  6367. /* istanbul ignore if */
  6368. if (modifiers.passive) {
  6369. delete modifiers.passive;
  6370. name = prependModifierMarker('&', name, dynamic);
  6371. }
  6372. let events;
  6373. if (modifiers.native) {
  6374. delete modifiers.native;
  6375. events = el.nativeEvents || (el.nativeEvents = {});
  6376. } else {
  6377. events = el.events || (el.events = {});
  6378. }
  6379. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  6380. if (modifiers !== emptyObject) {
  6381. newHandler.modifiers = modifiers;
  6382. }
  6383. const handlers = events[name];
  6384. /* istanbul ignore if */
  6385. if (Array.isArray(handlers)) {
  6386. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  6387. } else if (handlers) {
  6388. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  6389. } else {
  6390. events[name] = newHandler;
  6391. }
  6392. el.plain = false;
  6393. }
  6394. function getRawBindingAttr (
  6395. el,
  6396. name
  6397. ) {
  6398. return el.rawAttrsMap[':' + name] ||
  6399. el.rawAttrsMap['v-bind:' + name] ||
  6400. el.rawAttrsMap[name]
  6401. }
  6402. function getBindingAttr (
  6403. el,
  6404. name,
  6405. getStatic
  6406. ) {
  6407. const dynamicValue =
  6408. getAndRemoveAttr(el, ':' + name) ||
  6409. getAndRemoveAttr(el, 'v-bind:' + name);
  6410. if (dynamicValue != null) {
  6411. return parseFilters(dynamicValue)
  6412. } else if (getStatic !== false) {
  6413. const staticValue = getAndRemoveAttr(el, name);
  6414. if (staticValue != null) {
  6415. return JSON.stringify(staticValue)
  6416. }
  6417. }
  6418. }
  6419. // note: this only removes the attr from the Array (attrsList) so that it
  6420. // doesn't get processed by processAttrs.
  6421. // By default it does NOT remove it from the map (attrsMap) because the map is
  6422. // needed during codegen.
  6423. function getAndRemoveAttr (
  6424. el,
  6425. name,
  6426. removeFromMap
  6427. ) {
  6428. let val;
  6429. if ((val = el.attrsMap[name]) != null) {
  6430. const list = el.attrsList;
  6431. for (let i = 0, l = list.length; i < l; i++) {
  6432. if (list[i].name === name) {
  6433. list.splice(i, 1);
  6434. break
  6435. }
  6436. }
  6437. }
  6438. if (removeFromMap) {
  6439. delete el.attrsMap[name];
  6440. }
  6441. return val
  6442. }
  6443. function getAndRemoveAttrByRegex (
  6444. el,
  6445. name
  6446. ) {
  6447. const list = el.attrsList;
  6448. for (let i = 0, l = list.length; i < l; i++) {
  6449. const attr = list[i];
  6450. if (name.test(attr.name)) {
  6451. list.splice(i, 1);
  6452. return attr
  6453. }
  6454. }
  6455. }
  6456. function rangeSetItem (
  6457. item,
  6458. range
  6459. ) {
  6460. if (range) {
  6461. if (range.start != null) {
  6462. item.start = range.start;
  6463. }
  6464. if (range.end != null) {
  6465. item.end = range.end;
  6466. }
  6467. }
  6468. return item
  6469. }
  6470. /* */
  6471. /**
  6472. * Cross-platform code generation for component v-model
  6473. */
  6474. function genComponentModel (
  6475. el,
  6476. value,
  6477. modifiers
  6478. ) {
  6479. const { number, trim } = modifiers || {};
  6480. const baseValueExpression = '$$v';
  6481. let valueExpression = baseValueExpression;
  6482. if (trim) {
  6483. valueExpression =
  6484. `(typeof ${baseValueExpression} === 'string'` +
  6485. `? ${baseValueExpression}.trim()` +
  6486. `: ${baseValueExpression})`;
  6487. }
  6488. if (number) {
  6489. valueExpression = `_n(${valueExpression})`;
  6490. }
  6491. const assignment = genAssignmentCode(value, valueExpression);
  6492. el.model = {
  6493. value: `(${value})`,
  6494. expression: JSON.stringify(value),
  6495. callback: `function (${baseValueExpression}) {${assignment}}`
  6496. };
  6497. }
  6498. /**
  6499. * Cross-platform codegen helper for generating v-model value assignment code.
  6500. */
  6501. function genAssignmentCode (
  6502. value,
  6503. assignment
  6504. ) {
  6505. const res = parseModel(value);
  6506. if (res.key === null) {
  6507. return `${value}=${assignment}`
  6508. } else {
  6509. return `$set(${res.exp}, ${res.key}, ${assignment})`
  6510. }
  6511. }
  6512. /**
  6513. * Parse a v-model expression into a base path and a final key segment.
  6514. * Handles both dot-path and possible square brackets.
  6515. *
  6516. * Possible cases:
  6517. *
  6518. * - test
  6519. * - test[key]
  6520. * - test[test1[key]]
  6521. * - test["a"][key]
  6522. * - xxx.test[a[a].test1[key]]
  6523. * - test.xxx.a["asa"][test1[key]]
  6524. *
  6525. */
  6526. let len, str, chr, index$1, expressionPos, expressionEndPos;
  6527. function parseModel (val) {
  6528. // Fix https://github.com/vuejs/vue/pull/7730
  6529. // allow v-model="obj.val " (trailing whitespace)
  6530. val = val.trim();
  6531. len = val.length;
  6532. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6533. index$1 = val.lastIndexOf('.');
  6534. if (index$1 > -1) {
  6535. return {
  6536. exp: val.slice(0, index$1),
  6537. key: '"' + val.slice(index$1 + 1) + '"'
  6538. }
  6539. } else {
  6540. return {
  6541. exp: val,
  6542. key: null
  6543. }
  6544. }
  6545. }
  6546. str = val;
  6547. index$1 = expressionPos = expressionEndPos = 0;
  6548. while (!eof()) {
  6549. chr = next();
  6550. /* istanbul ignore if */
  6551. if (isStringStart(chr)) {
  6552. parseString(chr);
  6553. } else if (chr === 0x5B) {
  6554. parseBracket(chr);
  6555. }
  6556. }
  6557. return {
  6558. exp: val.slice(0, expressionPos),
  6559. key: val.slice(expressionPos + 1, expressionEndPos)
  6560. }
  6561. }
  6562. function next () {
  6563. return str.charCodeAt(++index$1)
  6564. }
  6565. function eof () {
  6566. return index$1 >= len
  6567. }
  6568. function isStringStart (chr) {
  6569. return chr === 0x22 || chr === 0x27
  6570. }
  6571. function parseBracket (chr) {
  6572. let inBracket = 1;
  6573. expressionPos = index$1;
  6574. while (!eof()) {
  6575. chr = next();
  6576. if (isStringStart(chr)) {
  6577. parseString(chr);
  6578. continue
  6579. }
  6580. if (chr === 0x5B) inBracket++;
  6581. if (chr === 0x5D) inBracket--;
  6582. if (inBracket === 0) {
  6583. expressionEndPos = index$1;
  6584. break
  6585. }
  6586. }
  6587. }
  6588. function parseString (chr) {
  6589. const stringQuote = chr;
  6590. while (!eof()) {
  6591. chr = next();
  6592. if (chr === stringQuote) {
  6593. break
  6594. }
  6595. }
  6596. }
  6597. /* */
  6598. let warn$1;
  6599. // in some cases, the event used has to be determined at runtime
  6600. // so we used some reserved tokens during compile.
  6601. const RANGE_TOKEN = '__r';
  6602. const CHECKBOX_RADIO_TOKEN = '__c';
  6603. function model (
  6604. el,
  6605. dir,
  6606. _warn
  6607. ) {
  6608. warn$1 = _warn;
  6609. const value = dir.value;
  6610. const modifiers = dir.modifiers;
  6611. const tag = el.tag;
  6612. const type = el.attrsMap.type;
  6613. {
  6614. // inputs with type="file" are read only and setting the input's
  6615. // value will throw an error.
  6616. if (tag === 'input' && type === 'file') {
  6617. warn$1(
  6618. `<${el.tag} v-model="${value}" type="file">:\n` +
  6619. `File inputs are read only. Use a v-on:change listener instead.`,
  6620. el.rawAttrsMap['v-model']
  6621. );
  6622. }
  6623. }
  6624. if (el.component) {
  6625. genComponentModel(el, value, modifiers);
  6626. // component v-model doesn't need extra runtime
  6627. return false
  6628. } else if (tag === 'select') {
  6629. genSelect(el, value, modifiers);
  6630. } else if (tag === 'input' && type === 'checkbox') {
  6631. genCheckboxModel(el, value, modifiers);
  6632. } else if (tag === 'input' && type === 'radio') {
  6633. genRadioModel(el, value, modifiers);
  6634. } else if (tag === 'input' || tag === 'textarea') {
  6635. genDefaultModel(el, value, modifiers);
  6636. } else if (!config.isReservedTag(tag)) {
  6637. genComponentModel(el, value, modifiers);
  6638. // component v-model doesn't need extra runtime
  6639. return false
  6640. } else {
  6641. warn$1(
  6642. `<${el.tag} v-model="${value}">: ` +
  6643. `v-model is not supported on this element type. ` +
  6644. 'If you are working with contenteditable, it\'s recommended to ' +
  6645. 'wrap a library dedicated for that purpose inside a custom component.',
  6646. el.rawAttrsMap['v-model']
  6647. );
  6648. }
  6649. // ensure runtime directive metadata
  6650. return true
  6651. }
  6652. function genCheckboxModel (
  6653. el,
  6654. value,
  6655. modifiers
  6656. ) {
  6657. const number = modifiers && modifiers.number;
  6658. const valueBinding = getBindingAttr(el, 'value') || 'null';
  6659. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  6660. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  6661. addProp(el, 'checked',
  6662. `Array.isArray(${value})` +
  6663. `?_i(${value},${valueBinding})>-1` + (
  6664. trueValueBinding === 'true'
  6665. ? `:(${value})`
  6666. : `:_q(${value},${trueValueBinding})`
  6667. )
  6668. );
  6669. addHandler(el, 'change',
  6670. `var $$a=${value},` +
  6671. '$$el=$event.target,' +
  6672. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  6673. 'if(Array.isArray($$a)){' +
  6674. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  6675. '$$i=_i($$a,$$v);' +
  6676. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  6677. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  6678. `}else{${genAssignmentCode(value, '$$c')}}`,
  6679. null, true
  6680. );
  6681. }
  6682. function genRadioModel (
  6683. el,
  6684. value,
  6685. modifiers
  6686. ) {
  6687. const number = modifiers && modifiers.number;
  6688. let valueBinding = getBindingAttr(el, 'value') || 'null';
  6689. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  6690. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  6691. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  6692. }
  6693. function genSelect (
  6694. el,
  6695. value,
  6696. modifiers
  6697. ) {
  6698. const number = modifiers && modifiers.number;
  6699. const selectedVal = `Array.prototype.filter` +
  6700. `.call($event.target.options,function(o){return o.selected})` +
  6701. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  6702. `return ${number ? '_n(val)' : 'val'}})`;
  6703. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  6704. let code = `var $$selectedVal = ${selectedVal};`;
  6705. code = `${code} ${genAssignmentCode(value, assignment)}`;
  6706. addHandler(el, 'change', code, null, true);
  6707. }
  6708. function genDefaultModel (
  6709. el,
  6710. value,
  6711. modifiers
  6712. ) {
  6713. const type = el.attrsMap.type;
  6714. // warn if v-bind:value conflicts with v-model
  6715. // except for inputs with v-bind:type
  6716. {
  6717. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  6718. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  6719. if (value && !typeBinding) {
  6720. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  6721. warn$1(
  6722. `${binding}="${value}" conflicts with v-model on the same element ` +
  6723. 'because the latter already expands to a value binding internally',
  6724. el.rawAttrsMap[binding]
  6725. );
  6726. }
  6727. }
  6728. const { lazy, number, trim } = modifiers || {};
  6729. const needCompositionGuard = !lazy && type !== 'range';
  6730. const event = lazy
  6731. ? 'change'
  6732. : type === 'range'
  6733. ? RANGE_TOKEN
  6734. : 'input';
  6735. let valueExpression = '$event.target.value';
  6736. if (trim) {
  6737. valueExpression = `$event.target.value.trim()`;
  6738. }
  6739. if (number) {
  6740. valueExpression = `_n(${valueExpression})`;
  6741. }
  6742. let code = genAssignmentCode(value, valueExpression);
  6743. if (needCompositionGuard) {
  6744. code = `if($event.target.composing)return;${code}`;
  6745. }
  6746. addProp(el, 'value', `(${value})`);
  6747. addHandler(el, event, code, null, true);
  6748. if (trim || number) {
  6749. addHandler(el, 'blur', '$forceUpdate()');
  6750. }
  6751. }
  6752. /* */
  6753. // normalize v-model event tokens that can only be determined at runtime.
  6754. // it's important to place the event as the first in the array because
  6755. // the whole point is ensuring the v-model callback gets called before
  6756. // user-attached handlers.
  6757. function normalizeEvents (on) {
  6758. /* istanbul ignore if */
  6759. if (isDef(on[RANGE_TOKEN])) {
  6760. // IE input[type=range] only supports `change` event
  6761. const event = isIE ? 'change' : 'input';
  6762. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  6763. delete on[RANGE_TOKEN];
  6764. }
  6765. // This was originally intended to fix #4521 but no longer necessary
  6766. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  6767. /* istanbul ignore if */
  6768. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  6769. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  6770. delete on[CHECKBOX_RADIO_TOKEN];
  6771. }
  6772. }
  6773. let target$1;
  6774. function createOnceHandler$1 (event, handler, capture) {
  6775. const _target = target$1; // save current target element in closure
  6776. return function onceHandler () {
  6777. const res = handler.apply(null, arguments);
  6778. if (res !== null) {
  6779. remove$2(event, onceHandler, capture, _target);
  6780. }
  6781. }
  6782. }
  6783. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  6784. // implementation and does not fire microtasks in between event propagation, so
  6785. // safe to exclude.
  6786. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  6787. function add$1 (
  6788. name,
  6789. handler,
  6790. capture,
  6791. passive
  6792. ) {
  6793. // async edge case #6566: inner click event triggers patch, event handler
  6794. // attached to outer element during patch, and triggered again. This
  6795. // happens because browsers fire microtask ticks between event propagation.
  6796. // the solution is simple: we save the timestamp when a handler is attached,
  6797. // and the handler would only fire if the event passed to it was fired
  6798. // AFTER it was attached.
  6799. if (useMicrotaskFix) {
  6800. const attachedTimestamp = currentFlushTimestamp;
  6801. const original = handler;
  6802. handler = original._wrapper = function (e) {
  6803. if (
  6804. // no bubbling, should always fire.
  6805. // this is just a safety net in case event.timeStamp is unreliable in
  6806. // certain weird environments...
  6807. e.target === e.currentTarget ||
  6808. // event is fired after handler attachment
  6809. e.timeStamp >= attachedTimestamp ||
  6810. // bail for environments that have buggy event.timeStamp implementations
  6811. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  6812. // #9681 QtWebEngine event.timeStamp is negative value
  6813. e.timeStamp <= 0 ||
  6814. // #9448 bail if event is fired in another document in a multi-page
  6815. // electron/nw.js app, since event.timeStamp will be using a different
  6816. // starting reference
  6817. e.target.ownerDocument !== document
  6818. ) {
  6819. return original.apply(this, arguments)
  6820. }
  6821. };
  6822. }
  6823. target$1.addEventListener(
  6824. name,
  6825. handler,
  6826. supportsPassive
  6827. ? { capture, passive }
  6828. : capture
  6829. );
  6830. }
  6831. function remove$2 (
  6832. name,
  6833. handler,
  6834. capture,
  6835. _target
  6836. ) {
  6837. (_target || target$1).removeEventListener(
  6838. name,
  6839. handler._wrapper || handler,
  6840. capture
  6841. );
  6842. }
  6843. function updateDOMListeners (oldVnode, vnode) {
  6844. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  6845. return
  6846. }
  6847. const on = vnode.data.on || {};
  6848. const oldOn = oldVnode.data.on || {};
  6849. target$1 = vnode.elm;
  6850. normalizeEvents(on);
  6851. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  6852. target$1 = undefined;
  6853. }
  6854. var events = {
  6855. create: updateDOMListeners,
  6856. update: updateDOMListeners
  6857. };
  6858. /* */
  6859. let svgContainer;
  6860. function updateDOMProps (oldVnode, vnode) {
  6861. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  6862. return
  6863. }
  6864. let key, cur;
  6865. const elm = vnode.elm;
  6866. const oldProps = oldVnode.data.domProps || {};
  6867. let props = vnode.data.domProps || {};
  6868. // clone observed objects, as the user probably wants to mutate it
  6869. if (isDef(props.__ob__)) {
  6870. props = vnode.data.domProps = extend({}, props);
  6871. }
  6872. for (key in oldProps) {
  6873. if (!(key in props)) {
  6874. elm[key] = '';
  6875. }
  6876. }
  6877. for (key in props) {
  6878. cur = props[key];
  6879. // ignore children if the node has textContent or innerHTML,
  6880. // as these will throw away existing DOM nodes and cause removal errors
  6881. // on subsequent patches (#3360)
  6882. if (key === 'textContent' || key === 'innerHTML') {
  6883. if (vnode.children) vnode.children.length = 0;
  6884. if (cur === oldProps[key]) continue
  6885. // #6601 work around Chrome version <= 55 bug where single textNode
  6886. // replaced by innerHTML/textContent retains its parentNode property
  6887. if (elm.childNodes.length === 1) {
  6888. elm.removeChild(elm.childNodes[0]);
  6889. }
  6890. }
  6891. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  6892. // store value as _value as well since
  6893. // non-string values will be stringified
  6894. elm._value = cur;
  6895. // avoid resetting cursor position when value is the same
  6896. const strCur = isUndef(cur) ? '' : String(cur);
  6897. if (shouldUpdateValue(elm, strCur)) {
  6898. elm.value = strCur;
  6899. }
  6900. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  6901. // IE doesn't support innerHTML for SVG elements
  6902. svgContainer = svgContainer || document.createElement('div');
  6903. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  6904. const svg = svgContainer.firstChild;
  6905. while (elm.firstChild) {
  6906. elm.removeChild(elm.firstChild);
  6907. }
  6908. while (svg.firstChild) {
  6909. elm.appendChild(svg.firstChild);
  6910. }
  6911. } else if (
  6912. // skip the update if old and new VDOM state is the same.
  6913. // `value` is handled separately because the DOM value may be temporarily
  6914. // out of sync with VDOM state due to focus, composition and modifiers.
  6915. // This #4521 by skipping the unnecessary `checked` update.
  6916. cur !== oldProps[key]
  6917. ) {
  6918. // some property updates can throw
  6919. // e.g. `value` on <progress> w/ non-finite value
  6920. try {
  6921. elm[key] = cur;
  6922. } catch (e) {}
  6923. }
  6924. }
  6925. }
  6926. // check platforms/web/util/attrs.js acceptValue
  6927. function shouldUpdateValue (elm, checkVal) {
  6928. return (!elm.composing && (
  6929. elm.tagName === 'OPTION' ||
  6930. isNotInFocusAndDirty(elm, checkVal) ||
  6931. isDirtyWithModifiers(elm, checkVal)
  6932. ))
  6933. }
  6934. function isNotInFocusAndDirty (elm, checkVal) {
  6935. // return true when textbox (.number and .trim) loses focus and its value is
  6936. // not equal to the updated value
  6937. let notInFocus = true;
  6938. // #6157
  6939. // work around IE bug when accessing document.activeElement in an iframe
  6940. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  6941. return notInFocus && elm.value !== checkVal
  6942. }
  6943. function isDirtyWithModifiers (elm, newVal) {
  6944. const value = elm.value;
  6945. const modifiers = elm._vModifiers; // injected by v-model runtime
  6946. if (isDef(modifiers)) {
  6947. if (modifiers.number) {
  6948. return toNumber(value) !== toNumber(newVal)
  6949. }
  6950. if (modifiers.trim) {
  6951. return value.trim() !== newVal.trim()
  6952. }
  6953. }
  6954. return value !== newVal
  6955. }
  6956. var domProps = {
  6957. create: updateDOMProps,
  6958. update: updateDOMProps
  6959. };
  6960. /* */
  6961. const parseStyleText = cached(function (cssText) {
  6962. const res = {};
  6963. const listDelimiter = /;(?![^(]*\))/g;
  6964. const propertyDelimiter = /:(.+)/;
  6965. cssText.split(listDelimiter).forEach(function (item) {
  6966. if (item) {
  6967. const tmp = item.split(propertyDelimiter);
  6968. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  6969. }
  6970. });
  6971. return res
  6972. });
  6973. // merge static and dynamic style data on the same vnode
  6974. function normalizeStyleData (data) {
  6975. const style = normalizeStyleBinding(data.style);
  6976. // static style is pre-processed into an object during compilation
  6977. // and is always a fresh object, so it's safe to merge into it
  6978. return data.staticStyle
  6979. ? extend(data.staticStyle, style)
  6980. : style
  6981. }
  6982. // normalize possible array / string values into Object
  6983. function normalizeStyleBinding (bindingStyle) {
  6984. if (Array.isArray(bindingStyle)) {
  6985. return toObject(bindingStyle)
  6986. }
  6987. if (typeof bindingStyle === 'string') {
  6988. return parseStyleText(bindingStyle)
  6989. }
  6990. return bindingStyle
  6991. }
  6992. /**
  6993. * parent component style should be after child's
  6994. * so that parent component's style could override it
  6995. */
  6996. function getStyle (vnode, checkChild) {
  6997. const res = {};
  6998. let styleData;
  6999. if (checkChild) {
  7000. let childNode = vnode;
  7001. while (childNode.componentInstance) {
  7002. childNode = childNode.componentInstance._vnode;
  7003. if (
  7004. childNode && childNode.data &&
  7005. (styleData = normalizeStyleData(childNode.data))
  7006. ) {
  7007. extend(res, styleData);
  7008. }
  7009. }
  7010. }
  7011. if ((styleData = normalizeStyleData(vnode.data))) {
  7012. extend(res, styleData);
  7013. }
  7014. let parentNode = vnode;
  7015. while ((parentNode = parentNode.parent)) {
  7016. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7017. extend(res, styleData);
  7018. }
  7019. }
  7020. return res
  7021. }
  7022. /* */
  7023. const cssVarRE = /^--/;
  7024. const importantRE = /\s*!important$/;
  7025. const setProp = (el, name, val) => {
  7026. /* istanbul ignore if */
  7027. if (cssVarRE.test(name)) {
  7028. el.style.setProperty(name, val);
  7029. } else if (importantRE.test(val)) {
  7030. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7031. } else {
  7032. const normalizedName = normalize(name);
  7033. if (Array.isArray(val)) {
  7034. // Support values array created by autoprefixer, e.g.
  7035. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7036. // Set them one by one, and the browser will only set those it can recognize
  7037. for (let i = 0, len = val.length; i < len; i++) {
  7038. el.style[normalizedName] = val[i];
  7039. }
  7040. } else {
  7041. el.style[normalizedName] = val;
  7042. }
  7043. }
  7044. };
  7045. const vendorNames = ['Webkit', 'Moz', 'ms'];
  7046. let emptyStyle;
  7047. const normalize = cached(function (prop) {
  7048. emptyStyle = emptyStyle || document.createElement('div').style;
  7049. prop = camelize(prop);
  7050. if (prop !== 'filter' && (prop in emptyStyle)) {
  7051. return prop
  7052. }
  7053. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7054. for (let i = 0; i < vendorNames.length; i++) {
  7055. const name = vendorNames[i] + capName;
  7056. if (name in emptyStyle) {
  7057. return name
  7058. }
  7059. }
  7060. });
  7061. function updateStyle (oldVnode, vnode) {
  7062. const data = vnode.data;
  7063. const oldData = oldVnode.data;
  7064. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  7065. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  7066. ) {
  7067. return
  7068. }
  7069. let cur, name;
  7070. const el = vnode.elm;
  7071. const oldStaticStyle = oldData.staticStyle;
  7072. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  7073. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  7074. const oldStyle = oldStaticStyle || oldStyleBinding;
  7075. const style = normalizeStyleBinding(vnode.data.style) || {};
  7076. // store normalized style under a different key for next diff
  7077. // make sure to clone it if it's reactive, since the user likely wants
  7078. // to mutate it.
  7079. vnode.data.normalizedStyle = isDef(style.__ob__)
  7080. ? extend({}, style)
  7081. : style;
  7082. const newStyle = getStyle(vnode, true);
  7083. for (name in oldStyle) {
  7084. if (isUndef(newStyle[name])) {
  7085. setProp(el, name, '');
  7086. }
  7087. }
  7088. for (name in newStyle) {
  7089. cur = newStyle[name];
  7090. if (cur !== oldStyle[name]) {
  7091. // ie9 setting to null has no effect, must use empty string
  7092. setProp(el, name, cur == null ? '' : cur);
  7093. }
  7094. }
  7095. }
  7096. var style = {
  7097. create: updateStyle,
  7098. update: updateStyle
  7099. };
  7100. /* */
  7101. const whitespaceRE = /\s+/;
  7102. /**
  7103. * Add class with compatibility for SVG since classList is not supported on
  7104. * SVG elements in IE
  7105. */
  7106. function addClass (el, cls) {
  7107. /* istanbul ignore if */
  7108. if (!cls || !(cls = cls.trim())) {
  7109. return
  7110. }
  7111. /* istanbul ignore else */
  7112. if (el.classList) {
  7113. if (cls.indexOf(' ') > -1) {
  7114. cls.split(whitespaceRE).forEach(c => el.classList.add(c));
  7115. } else {
  7116. el.classList.add(cls);
  7117. }
  7118. } else {
  7119. const cur = ` ${el.getAttribute('class') || ''} `;
  7120. if (cur.indexOf(' ' + cls + ' ') < 0) {
  7121. el.setAttribute('class', (cur + cls).trim());
  7122. }
  7123. }
  7124. }
  7125. /**
  7126. * Remove class with compatibility for SVG since classList is not supported on
  7127. * SVG elements in IE
  7128. */
  7129. function removeClass (el, cls) {
  7130. /* istanbul ignore if */
  7131. if (!cls || !(cls = cls.trim())) {
  7132. return
  7133. }
  7134. /* istanbul ignore else */
  7135. if (el.classList) {
  7136. if (cls.indexOf(' ') > -1) {
  7137. cls.split(whitespaceRE).forEach(c => el.classList.remove(c));
  7138. } else {
  7139. el.classList.remove(cls);
  7140. }
  7141. if (!el.classList.length) {
  7142. el.removeAttribute('class');
  7143. }
  7144. } else {
  7145. let cur = ` ${el.getAttribute('class') || ''} `;
  7146. const tar = ' ' + cls + ' ';
  7147. while (cur.indexOf(tar) >= 0) {
  7148. cur = cur.replace(tar, ' ');
  7149. }
  7150. cur = cur.trim();
  7151. if (cur) {
  7152. el.setAttribute('class', cur);
  7153. } else {
  7154. el.removeAttribute('class');
  7155. }
  7156. }
  7157. }
  7158. /* */
  7159. function resolveTransition (def$$1) {
  7160. if (!def$$1) {
  7161. return
  7162. }
  7163. /* istanbul ignore else */
  7164. if (typeof def$$1 === 'object') {
  7165. const res = {};
  7166. if (def$$1.css !== false) {
  7167. extend(res, autoCssTransition(def$$1.name || 'v'));
  7168. }
  7169. extend(res, def$$1);
  7170. return res
  7171. } else if (typeof def$$1 === 'string') {
  7172. return autoCssTransition(def$$1)
  7173. }
  7174. }
  7175. const autoCssTransition = cached(name => {
  7176. return {
  7177. enterClass: `${name}-enter`,
  7178. enterToClass: `${name}-enter-to`,
  7179. enterActiveClass: `${name}-enter-active`,
  7180. leaveClass: `${name}-leave`,
  7181. leaveToClass: `${name}-leave-to`,
  7182. leaveActiveClass: `${name}-leave-active`
  7183. }
  7184. });
  7185. const hasTransition = inBrowser && !isIE9;
  7186. const TRANSITION = 'transition';
  7187. const ANIMATION = 'animation';
  7188. // Transition property/event sniffing
  7189. let transitionProp = 'transition';
  7190. let transitionEndEvent = 'transitionend';
  7191. let animationProp = 'animation';
  7192. let animationEndEvent = 'animationend';
  7193. if (hasTransition) {
  7194. /* istanbul ignore if */
  7195. if (window.ontransitionend === undefined &&
  7196. window.onwebkittransitionend !== undefined
  7197. ) {
  7198. transitionProp = 'WebkitTransition';
  7199. transitionEndEvent = 'webkitTransitionEnd';
  7200. }
  7201. if (window.onanimationend === undefined &&
  7202. window.onwebkitanimationend !== undefined
  7203. ) {
  7204. animationProp = 'WebkitAnimation';
  7205. animationEndEvent = 'webkitAnimationEnd';
  7206. }
  7207. }
  7208. // binding to window is necessary to make hot reload work in IE in strict mode
  7209. const raf = inBrowser
  7210. ? window.requestAnimationFrame
  7211. ? window.requestAnimationFrame.bind(window)
  7212. : setTimeout
  7213. : /* istanbul ignore next */ fn => fn();
  7214. function nextFrame (fn) {
  7215. raf(() => {
  7216. raf(fn);
  7217. });
  7218. }
  7219. function addTransitionClass (el, cls) {
  7220. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  7221. if (transitionClasses.indexOf(cls) < 0) {
  7222. transitionClasses.push(cls);
  7223. addClass(el, cls);
  7224. }
  7225. }
  7226. function removeTransitionClass (el, cls) {
  7227. if (el._transitionClasses) {
  7228. remove(el._transitionClasses, cls);
  7229. }
  7230. removeClass(el, cls);
  7231. }
  7232. function whenTransitionEnds (
  7233. el,
  7234. expectedType,
  7235. cb
  7236. ) {
  7237. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  7238. if (!type) return cb()
  7239. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  7240. let ended = 0;
  7241. const end = () => {
  7242. el.removeEventListener(event, onEnd);
  7243. cb();
  7244. };
  7245. const onEnd = e => {
  7246. if (e.target === el) {
  7247. if (++ended >= propCount) {
  7248. end();
  7249. }
  7250. }
  7251. };
  7252. setTimeout(() => {
  7253. if (ended < propCount) {
  7254. end();
  7255. }
  7256. }, timeout + 1);
  7257. el.addEventListener(event, onEnd);
  7258. }
  7259. const transformRE = /\b(transform|all)(,|$)/;
  7260. function getTransitionInfo (el, expectedType) {
  7261. const styles = window.getComputedStyle(el);
  7262. // JSDOM may return undefined for transition properties
  7263. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  7264. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  7265. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  7266. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  7267. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  7268. const animationTimeout = getTimeout(animationDelays, animationDurations);
  7269. let type;
  7270. let timeout = 0;
  7271. let propCount = 0;
  7272. /* istanbul ignore if */
  7273. if (expectedType === TRANSITION) {
  7274. if (transitionTimeout > 0) {
  7275. type = TRANSITION;
  7276. timeout = transitionTimeout;
  7277. propCount = transitionDurations.length;
  7278. }
  7279. } else if (expectedType === ANIMATION) {
  7280. if (animationTimeout > 0) {
  7281. type = ANIMATION;
  7282. timeout = animationTimeout;
  7283. propCount = animationDurations.length;
  7284. }
  7285. } else {
  7286. timeout = Math.max(transitionTimeout, animationTimeout);
  7287. type = timeout > 0
  7288. ? transitionTimeout > animationTimeout
  7289. ? TRANSITION
  7290. : ANIMATION
  7291. : null;
  7292. propCount = type
  7293. ? type === TRANSITION
  7294. ? transitionDurations.length
  7295. : animationDurations.length
  7296. : 0;
  7297. }
  7298. const hasTransform =
  7299. type === TRANSITION &&
  7300. transformRE.test(styles[transitionProp + 'Property']);
  7301. return {
  7302. type,
  7303. timeout,
  7304. propCount,
  7305. hasTransform
  7306. }
  7307. }
  7308. function getTimeout (delays, durations) {
  7309. /* istanbul ignore next */
  7310. while (delays.length < durations.length) {
  7311. delays = delays.concat(delays);
  7312. }
  7313. return Math.max.apply(null, durations.map((d, i) => {
  7314. return toMs(d) + toMs(delays[i])
  7315. }))
  7316. }
  7317. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  7318. // in a locale-dependent way, using a comma instead of a dot.
  7319. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  7320. // as a floor function) causing unexpected behaviors
  7321. function toMs (s) {
  7322. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  7323. }
  7324. /* */
  7325. function enter (vnode, toggleDisplay) {
  7326. const el = vnode.elm;
  7327. // call leave callback now
  7328. if (isDef(el._leaveCb)) {
  7329. el._leaveCb.cancelled = true;
  7330. el._leaveCb();
  7331. }
  7332. const data = resolveTransition(vnode.data.transition);
  7333. if (isUndef(data)) {
  7334. return
  7335. }
  7336. /* istanbul ignore if */
  7337. if (isDef(el._enterCb) || el.nodeType !== 1) {
  7338. return
  7339. }
  7340. const {
  7341. css,
  7342. type,
  7343. enterClass,
  7344. enterToClass,
  7345. enterActiveClass,
  7346. appearClass,
  7347. appearToClass,
  7348. appearActiveClass,
  7349. beforeEnter,
  7350. enter,
  7351. afterEnter,
  7352. enterCancelled,
  7353. beforeAppear,
  7354. appear,
  7355. afterAppear,
  7356. appearCancelled,
  7357. duration
  7358. } = data;
  7359. // activeInstance will always be the <transition> component managing this
  7360. // transition. One edge case to check is when the <transition> is placed
  7361. // as the root node of a child component. In that case we need to check
  7362. // <transition>'s parent for appear check.
  7363. let context = activeInstance;
  7364. let transitionNode = activeInstance.$vnode;
  7365. while (transitionNode && transitionNode.parent) {
  7366. context = transitionNode.context;
  7367. transitionNode = transitionNode.parent;
  7368. }
  7369. const isAppear = !context._isMounted || !vnode.isRootInsert;
  7370. if (isAppear && !appear && appear !== '') {
  7371. return
  7372. }
  7373. const startClass = isAppear && appearClass
  7374. ? appearClass
  7375. : enterClass;
  7376. const activeClass = isAppear && appearActiveClass
  7377. ? appearActiveClass
  7378. : enterActiveClass;
  7379. const toClass = isAppear && appearToClass
  7380. ? appearToClass
  7381. : enterToClass;
  7382. const beforeEnterHook = isAppear
  7383. ? (beforeAppear || beforeEnter)
  7384. : beforeEnter;
  7385. const enterHook = isAppear
  7386. ? (typeof appear === 'function' ? appear : enter)
  7387. : enter;
  7388. const afterEnterHook = isAppear
  7389. ? (afterAppear || afterEnter)
  7390. : afterEnter;
  7391. const enterCancelledHook = isAppear
  7392. ? (appearCancelled || enterCancelled)
  7393. : enterCancelled;
  7394. const explicitEnterDuration = toNumber(
  7395. isObject(duration)
  7396. ? duration.enter
  7397. : duration
  7398. );
  7399. if (explicitEnterDuration != null) {
  7400. checkDuration(explicitEnterDuration, 'enter', vnode);
  7401. }
  7402. const expectsCSS = css !== false && !isIE9;
  7403. const userWantsControl = getHookArgumentsLength(enterHook);
  7404. const cb = el._enterCb = once(() => {
  7405. if (expectsCSS) {
  7406. removeTransitionClass(el, toClass);
  7407. removeTransitionClass(el, activeClass);
  7408. }
  7409. if (cb.cancelled) {
  7410. if (expectsCSS) {
  7411. removeTransitionClass(el, startClass);
  7412. }
  7413. enterCancelledHook && enterCancelledHook(el);
  7414. } else {
  7415. afterEnterHook && afterEnterHook(el);
  7416. }
  7417. el._enterCb = null;
  7418. });
  7419. if (!vnode.data.show) {
  7420. // remove pending leave element on enter by injecting an insert hook
  7421. mergeVNodeHook(vnode, 'insert', () => {
  7422. const parent = el.parentNode;
  7423. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7424. if (pendingNode &&
  7425. pendingNode.tag === vnode.tag &&
  7426. pendingNode.elm._leaveCb
  7427. ) {
  7428. pendingNode.elm._leaveCb();
  7429. }
  7430. enterHook && enterHook(el, cb);
  7431. });
  7432. }
  7433. // start enter transition
  7434. beforeEnterHook && beforeEnterHook(el);
  7435. if (expectsCSS) {
  7436. addTransitionClass(el, startClass);
  7437. addTransitionClass(el, activeClass);
  7438. nextFrame(() => {
  7439. removeTransitionClass(el, startClass);
  7440. if (!cb.cancelled) {
  7441. addTransitionClass(el, toClass);
  7442. if (!userWantsControl) {
  7443. if (isValidDuration(explicitEnterDuration)) {
  7444. setTimeout(cb, explicitEnterDuration);
  7445. } else {
  7446. whenTransitionEnds(el, type, cb);
  7447. }
  7448. }
  7449. }
  7450. });
  7451. }
  7452. if (vnode.data.show) {
  7453. toggleDisplay && toggleDisplay();
  7454. enterHook && enterHook(el, cb);
  7455. }
  7456. if (!expectsCSS && !userWantsControl) {
  7457. cb();
  7458. }
  7459. }
  7460. function leave (vnode, rm) {
  7461. const el = vnode.elm;
  7462. // call enter callback now
  7463. if (isDef(el._enterCb)) {
  7464. el._enterCb.cancelled = true;
  7465. el._enterCb();
  7466. }
  7467. const data = resolveTransition(vnode.data.transition);
  7468. if (isUndef(data) || el.nodeType !== 1) {
  7469. return rm()
  7470. }
  7471. /* istanbul ignore if */
  7472. if (isDef(el._leaveCb)) {
  7473. return
  7474. }
  7475. const {
  7476. css,
  7477. type,
  7478. leaveClass,
  7479. leaveToClass,
  7480. leaveActiveClass,
  7481. beforeLeave,
  7482. leave,
  7483. afterLeave,
  7484. leaveCancelled,
  7485. delayLeave,
  7486. duration
  7487. } = data;
  7488. const expectsCSS = css !== false && !isIE9;
  7489. const userWantsControl = getHookArgumentsLength(leave);
  7490. const explicitLeaveDuration = toNumber(
  7491. isObject(duration)
  7492. ? duration.leave
  7493. : duration
  7494. );
  7495. if (isDef(explicitLeaveDuration)) {
  7496. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7497. }
  7498. const cb = el._leaveCb = once(() => {
  7499. if (el.parentNode && el.parentNode._pending) {
  7500. el.parentNode._pending[vnode.key] = null;
  7501. }
  7502. if (expectsCSS) {
  7503. removeTransitionClass(el, leaveToClass);
  7504. removeTransitionClass(el, leaveActiveClass);
  7505. }
  7506. if (cb.cancelled) {
  7507. if (expectsCSS) {
  7508. removeTransitionClass(el, leaveClass);
  7509. }
  7510. leaveCancelled && leaveCancelled(el);
  7511. } else {
  7512. rm();
  7513. afterLeave && afterLeave(el);
  7514. }
  7515. el._leaveCb = null;
  7516. });
  7517. if (delayLeave) {
  7518. delayLeave(performLeave);
  7519. } else {
  7520. performLeave();
  7521. }
  7522. function performLeave () {
  7523. // the delayed leave may have already been cancelled
  7524. if (cb.cancelled) {
  7525. return
  7526. }
  7527. // record leaving element
  7528. if (!vnode.data.show && el.parentNode) {
  7529. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  7530. }
  7531. beforeLeave && beforeLeave(el);
  7532. if (expectsCSS) {
  7533. addTransitionClass(el, leaveClass);
  7534. addTransitionClass(el, leaveActiveClass);
  7535. nextFrame(() => {
  7536. removeTransitionClass(el, leaveClass);
  7537. if (!cb.cancelled) {
  7538. addTransitionClass(el, leaveToClass);
  7539. if (!userWantsControl) {
  7540. if (isValidDuration(explicitLeaveDuration)) {
  7541. setTimeout(cb, explicitLeaveDuration);
  7542. } else {
  7543. whenTransitionEnds(el, type, cb);
  7544. }
  7545. }
  7546. }
  7547. });
  7548. }
  7549. leave && leave(el, cb);
  7550. if (!expectsCSS && !userWantsControl) {
  7551. cb();
  7552. }
  7553. }
  7554. }
  7555. // only used in dev mode
  7556. function checkDuration (val, name, vnode) {
  7557. if (typeof val !== 'number') {
  7558. warn(
  7559. `<transition> explicit ${name} duration is not a valid number - ` +
  7560. `got ${JSON.stringify(val)}.`,
  7561. vnode.context
  7562. );
  7563. } else if (isNaN(val)) {
  7564. warn(
  7565. `<transition> explicit ${name} duration is NaN - ` +
  7566. 'the duration expression might be incorrect.',
  7567. vnode.context
  7568. );
  7569. }
  7570. }
  7571. function isValidDuration (val) {
  7572. return typeof val === 'number' && !isNaN(val)
  7573. }
  7574. /**
  7575. * Normalize a transition hook's argument length. The hook may be:
  7576. * - a merged hook (invoker) with the original in .fns
  7577. * - a wrapped component method (check ._length)
  7578. * - a plain function (.length)
  7579. */
  7580. function getHookArgumentsLength (fn) {
  7581. if (isUndef(fn)) {
  7582. return false
  7583. }
  7584. const invokerFns = fn.fns;
  7585. if (isDef(invokerFns)) {
  7586. // invoker
  7587. return getHookArgumentsLength(
  7588. Array.isArray(invokerFns)
  7589. ? invokerFns[0]
  7590. : invokerFns
  7591. )
  7592. } else {
  7593. return (fn._length || fn.length) > 1
  7594. }
  7595. }
  7596. function _enter (_, vnode) {
  7597. if (vnode.data.show !== true) {
  7598. enter(vnode);
  7599. }
  7600. }
  7601. var transition = inBrowser ? {
  7602. create: _enter,
  7603. activate: _enter,
  7604. remove (vnode, rm) {
  7605. /* istanbul ignore else */
  7606. if (vnode.data.show !== true) {
  7607. leave(vnode, rm);
  7608. } else {
  7609. rm();
  7610. }
  7611. }
  7612. } : {};
  7613. var platformModules = [
  7614. attrs,
  7615. klass,
  7616. events,
  7617. domProps,
  7618. style,
  7619. transition
  7620. ];
  7621. /* */
  7622. // the directive module should be applied last, after all
  7623. // built-in modules have been applied.
  7624. const modules = platformModules.concat(baseModules);
  7625. const patch = createPatchFunction({ nodeOps, modules });
  7626. /**
  7627. * Not type checking this file because flow doesn't like attaching
  7628. * properties to Elements.
  7629. */
  7630. /* istanbul ignore if */
  7631. if (isIE9) {
  7632. // http://www.matts411.com/post/internet-explorer-9-oninput/
  7633. document.addEventListener('selectionchange', () => {
  7634. const el = document.activeElement;
  7635. if (el && el.vmodel) {
  7636. trigger(el, 'input');
  7637. }
  7638. });
  7639. }
  7640. const directive = {
  7641. inserted (el, binding, vnode, oldVnode) {
  7642. if (vnode.tag === 'select') {
  7643. // #6903
  7644. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  7645. mergeVNodeHook(vnode, 'postpatch', () => {
  7646. directive.componentUpdated(el, binding, vnode);
  7647. });
  7648. } else {
  7649. setSelected(el, binding, vnode.context);
  7650. }
  7651. el._vOptions = [].map.call(el.options, getValue);
  7652. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  7653. el._vModifiers = binding.modifiers;
  7654. if (!binding.modifiers.lazy) {
  7655. el.addEventListener('compositionstart', onCompositionStart);
  7656. el.addEventListener('compositionend', onCompositionEnd);
  7657. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  7658. // switching focus before confirming composition choice
  7659. // this also fixes the issue where some browsers e.g. iOS Chrome
  7660. // fires "change" instead of "input" on autocomplete.
  7661. el.addEventListener('change', onCompositionEnd);
  7662. /* istanbul ignore if */
  7663. if (isIE9) {
  7664. el.vmodel = true;
  7665. }
  7666. }
  7667. }
  7668. },
  7669. componentUpdated (el, binding, vnode) {
  7670. if (vnode.tag === 'select') {
  7671. setSelected(el, binding, vnode.context);
  7672. // in case the options rendered by v-for have changed,
  7673. // it's possible that the value is out-of-sync with the rendered options.
  7674. // detect such cases and filter out values that no longer has a matching
  7675. // option in the DOM.
  7676. const prevOptions = el._vOptions;
  7677. const curOptions = el._vOptions = [].map.call(el.options, getValue);
  7678. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  7679. // trigger change event if
  7680. // no matching option found for at least one value
  7681. const needReset = el.multiple
  7682. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  7683. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  7684. if (needReset) {
  7685. trigger(el, 'change');
  7686. }
  7687. }
  7688. }
  7689. }
  7690. };
  7691. function setSelected (el, binding, vm) {
  7692. actuallySetSelected(el, binding, vm);
  7693. /* istanbul ignore if */
  7694. if (isIE || isEdge) {
  7695. setTimeout(() => {
  7696. actuallySetSelected(el, binding, vm);
  7697. }, 0);
  7698. }
  7699. }
  7700. function actuallySetSelected (el, binding, vm) {
  7701. const value = binding.value;
  7702. const isMultiple = el.multiple;
  7703. if (isMultiple && !Array.isArray(value)) {
  7704. warn(
  7705. `<select multiple v-model="${binding.expression}"> ` +
  7706. `expects an Array value for its binding, but got ${
  7707. Object.prototype.toString.call(value).slice(8, -1)
  7708. }`,
  7709. vm
  7710. );
  7711. return
  7712. }
  7713. let selected, option;
  7714. for (let i = 0, l = el.options.length; i < l; i++) {
  7715. option = el.options[i];
  7716. if (isMultiple) {
  7717. selected = looseIndexOf(value, getValue(option)) > -1;
  7718. if (option.selected !== selected) {
  7719. option.selected = selected;
  7720. }
  7721. } else {
  7722. if (looseEqual(getValue(option), value)) {
  7723. if (el.selectedIndex !== i) {
  7724. el.selectedIndex = i;
  7725. }
  7726. return
  7727. }
  7728. }
  7729. }
  7730. if (!isMultiple) {
  7731. el.selectedIndex = -1;
  7732. }
  7733. }
  7734. function hasNoMatchingOption (value, options) {
  7735. return options.every(o => !looseEqual(o, value))
  7736. }
  7737. function getValue (option) {
  7738. return '_value' in option
  7739. ? option._value
  7740. : option.value
  7741. }
  7742. function onCompositionStart (e) {
  7743. e.target.composing = true;
  7744. }
  7745. function onCompositionEnd (e) {
  7746. // prevent triggering an input event for no reason
  7747. if (!e.target.composing) return
  7748. e.target.composing = false;
  7749. trigger(e.target, 'input');
  7750. }
  7751. function trigger (el, type) {
  7752. const e = document.createEvent('HTMLEvents');
  7753. e.initEvent(type, true, true);
  7754. el.dispatchEvent(e);
  7755. }
  7756. /* */
  7757. // recursively search for possible transition defined inside the component root
  7758. function locateNode (vnode) {
  7759. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  7760. ? locateNode(vnode.componentInstance._vnode)
  7761. : vnode
  7762. }
  7763. var show = {
  7764. bind (el, { value }, vnode) {
  7765. vnode = locateNode(vnode);
  7766. const transition$$1 = vnode.data && vnode.data.transition;
  7767. const originalDisplay = el.__vOriginalDisplay =
  7768. el.style.display === 'none' ? '' : el.style.display;
  7769. if (value && transition$$1) {
  7770. vnode.data.show = true;
  7771. enter(vnode, () => {
  7772. el.style.display = originalDisplay;
  7773. });
  7774. } else {
  7775. el.style.display = value ? originalDisplay : 'none';
  7776. }
  7777. },
  7778. update (el, { value, oldValue }, vnode) {
  7779. /* istanbul ignore if */
  7780. if (!value === !oldValue) return
  7781. vnode = locateNode(vnode);
  7782. const transition$$1 = vnode.data && vnode.data.transition;
  7783. if (transition$$1) {
  7784. vnode.data.show = true;
  7785. if (value) {
  7786. enter(vnode, () => {
  7787. el.style.display = el.__vOriginalDisplay;
  7788. });
  7789. } else {
  7790. leave(vnode, () => {
  7791. el.style.display = 'none';
  7792. });
  7793. }
  7794. } else {
  7795. el.style.display = value ? el.__vOriginalDisplay : 'none';
  7796. }
  7797. },
  7798. unbind (
  7799. el,
  7800. binding,
  7801. vnode,
  7802. oldVnode,
  7803. isDestroy
  7804. ) {
  7805. if (!isDestroy) {
  7806. el.style.display = el.__vOriginalDisplay;
  7807. }
  7808. }
  7809. };
  7810. var platformDirectives = {
  7811. model: directive,
  7812. show
  7813. };
  7814. /* */
  7815. const transitionProps = {
  7816. name: String,
  7817. appear: Boolean,
  7818. css: Boolean,
  7819. mode: String,
  7820. type: String,
  7821. enterClass: String,
  7822. leaveClass: String,
  7823. enterToClass: String,
  7824. leaveToClass: String,
  7825. enterActiveClass: String,
  7826. leaveActiveClass: String,
  7827. appearClass: String,
  7828. appearActiveClass: String,
  7829. appearToClass: String,
  7830. duration: [Number, String, Object]
  7831. };
  7832. // in case the child is also an abstract component, e.g. <keep-alive>
  7833. // we want to recursively retrieve the real component to be rendered
  7834. function getRealChild (vnode) {
  7835. const compOptions = vnode && vnode.componentOptions;
  7836. if (compOptions && compOptions.Ctor.options.abstract) {
  7837. return getRealChild(getFirstComponentChild(compOptions.children))
  7838. } else {
  7839. return vnode
  7840. }
  7841. }
  7842. function extractTransitionData (comp) {
  7843. const data = {};
  7844. const options = comp.$options;
  7845. // props
  7846. for (const key in options.propsData) {
  7847. data[key] = comp[key];
  7848. }
  7849. // events.
  7850. // extract listeners and pass them directly to the transition methods
  7851. const listeners = options._parentListeners;
  7852. for (const key in listeners) {
  7853. data[camelize(key)] = listeners[key];
  7854. }
  7855. return data
  7856. }
  7857. function placeholder (h, rawChild) {
  7858. if (/\d-keep-alive$/.test(rawChild.tag)) {
  7859. return h('keep-alive', {
  7860. props: rawChild.componentOptions.propsData
  7861. })
  7862. }
  7863. }
  7864. function hasParentTransition (vnode) {
  7865. while ((vnode = vnode.parent)) {
  7866. if (vnode.data.transition) {
  7867. return true
  7868. }
  7869. }
  7870. }
  7871. function isSameChild (child, oldChild) {
  7872. return oldChild.key === child.key && oldChild.tag === child.tag
  7873. }
  7874. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  7875. const isVShowDirective = d => d.name === 'show';
  7876. var Transition = {
  7877. name: 'transition',
  7878. props: transitionProps,
  7879. abstract: true,
  7880. render (h) {
  7881. let children = this.$slots.default;
  7882. if (!children) {
  7883. return
  7884. }
  7885. // filter out text nodes (possible whitespaces)
  7886. children = children.filter(isNotTextNode);
  7887. /* istanbul ignore if */
  7888. if (!children.length) {
  7889. return
  7890. }
  7891. // warn multiple elements
  7892. if (children.length > 1) {
  7893. warn(
  7894. '<transition> can only be used on a single element. Use ' +
  7895. '<transition-group> for lists.',
  7896. this.$parent
  7897. );
  7898. }
  7899. const mode = this.mode;
  7900. // warn invalid mode
  7901. if (mode && mode !== 'in-out' && mode !== 'out-in'
  7902. ) {
  7903. warn(
  7904. 'invalid <transition> mode: ' + mode,
  7905. this.$parent
  7906. );
  7907. }
  7908. const rawChild = children[0];
  7909. // if this is a component root node and the component's
  7910. // parent container node also has transition, skip.
  7911. if (hasParentTransition(this.$vnode)) {
  7912. return rawChild
  7913. }
  7914. // apply transition data to child
  7915. // use getRealChild() to ignore abstract components e.g. keep-alive
  7916. const child = getRealChild(rawChild);
  7917. /* istanbul ignore if */
  7918. if (!child) {
  7919. return rawChild
  7920. }
  7921. if (this._leaving) {
  7922. return placeholder(h, rawChild)
  7923. }
  7924. // ensure a key that is unique to the vnode type and to this transition
  7925. // component instance. This key will be used to remove pending leaving nodes
  7926. // during entering.
  7927. const id = `__transition-${this._uid}-`;
  7928. child.key = child.key == null
  7929. ? child.isComment
  7930. ? id + 'comment'
  7931. : id + child.tag
  7932. : isPrimitive(child.key)
  7933. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  7934. : child.key;
  7935. const data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  7936. const oldRawChild = this._vnode;
  7937. const oldChild = getRealChild(oldRawChild);
  7938. // mark v-show
  7939. // so that the transition module can hand over the control to the directive
  7940. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  7941. child.data.show = true;
  7942. }
  7943. if (
  7944. oldChild &&
  7945. oldChild.data &&
  7946. !isSameChild(child, oldChild) &&
  7947. !isAsyncPlaceholder(oldChild) &&
  7948. // #6687 component root is a comment node
  7949. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  7950. ) {
  7951. // replace old child transition data with fresh one
  7952. // important for dynamic transitions!
  7953. const oldData = oldChild.data.transition = extend({}, data);
  7954. // handle transition mode
  7955. if (mode === 'out-in') {
  7956. // return placeholder node and queue update when leave finishes
  7957. this._leaving = true;
  7958. mergeVNodeHook(oldData, 'afterLeave', () => {
  7959. this._leaving = false;
  7960. this.$forceUpdate();
  7961. });
  7962. return placeholder(h, rawChild)
  7963. } else if (mode === 'in-out') {
  7964. if (isAsyncPlaceholder(child)) {
  7965. return oldRawChild
  7966. }
  7967. let delayedLeave;
  7968. const performLeave = () => { delayedLeave(); };
  7969. mergeVNodeHook(data, 'afterEnter', performLeave);
  7970. mergeVNodeHook(data, 'enterCancelled', performLeave);
  7971. mergeVNodeHook(oldData, 'delayLeave', leave => { delayedLeave = leave; });
  7972. }
  7973. }
  7974. return rawChild
  7975. }
  7976. };
  7977. /* */
  7978. const props = extend({
  7979. tag: String,
  7980. moveClass: String
  7981. }, transitionProps);
  7982. delete props.mode;
  7983. var TransitionGroup = {
  7984. props,
  7985. beforeMount () {
  7986. const update = this._update;
  7987. this._update = (vnode, hydrating) => {
  7988. const restoreActiveInstance = setActiveInstance(this);
  7989. // force removing pass
  7990. this.__patch__(
  7991. this._vnode,
  7992. this.kept,
  7993. false, // hydrating
  7994. true // removeOnly (!important, avoids unnecessary moves)
  7995. );
  7996. this._vnode = this.kept;
  7997. restoreActiveInstance();
  7998. update.call(this, vnode, hydrating);
  7999. };
  8000. },
  8001. render (h) {
  8002. const tag = this.tag || this.$vnode.data.tag || 'span';
  8003. const map = Object.create(null);
  8004. const prevChildren = this.prevChildren = this.children;
  8005. const rawChildren = this.$slots.default || [];
  8006. const children = this.children = [];
  8007. const transitionData = extractTransitionData(this);
  8008. for (let i = 0; i < rawChildren.length; i++) {
  8009. const c = rawChildren[i];
  8010. if (c.tag) {
  8011. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8012. children.push(c);
  8013. map[c.key] = c
  8014. ;(c.data || (c.data = {})).transition = transitionData;
  8015. } else {
  8016. const opts = c.componentOptions;
  8017. const name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  8018. warn(`<transition-group> children must be keyed: <${name}>`);
  8019. }
  8020. }
  8021. }
  8022. if (prevChildren) {
  8023. const kept = [];
  8024. const removed = [];
  8025. for (let i = 0; i < prevChildren.length; i++) {
  8026. const c = prevChildren[i];
  8027. c.data.transition = transitionData;
  8028. c.data.pos = c.elm.getBoundingClientRect();
  8029. if (map[c.key]) {
  8030. kept.push(c);
  8031. } else {
  8032. removed.push(c);
  8033. }
  8034. }
  8035. this.kept = h(tag, null, kept);
  8036. this.removed = removed;
  8037. }
  8038. return h(tag, null, children)
  8039. },
  8040. updated () {
  8041. const children = this.prevChildren;
  8042. const moveClass = this.moveClass || ((this.name || 'v') + '-move');
  8043. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8044. return
  8045. }
  8046. // we divide the work into three loops to avoid mixing DOM reads and writes
  8047. // in each iteration - which helps prevent layout thrashing.
  8048. children.forEach(callPendingCbs);
  8049. children.forEach(recordPosition);
  8050. children.forEach(applyTranslation);
  8051. // force reflow to put everything in position
  8052. // assign to this to avoid being removed in tree-shaking
  8053. // $flow-disable-line
  8054. this._reflow = document.body.offsetHeight;
  8055. children.forEach((c) => {
  8056. if (c.data.moved) {
  8057. const el = c.elm;
  8058. const s = el.style;
  8059. addTransitionClass(el, moveClass);
  8060. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8061. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  8062. if (e && e.target !== el) {
  8063. return
  8064. }
  8065. if (!e || /transform$/.test(e.propertyName)) {
  8066. el.removeEventListener(transitionEndEvent, cb);
  8067. el._moveCb = null;
  8068. removeTransitionClass(el, moveClass);
  8069. }
  8070. });
  8071. }
  8072. });
  8073. },
  8074. methods: {
  8075. hasMove (el, moveClass) {
  8076. /* istanbul ignore if */
  8077. if (!hasTransition) {
  8078. return false
  8079. }
  8080. /* istanbul ignore if */
  8081. if (this._hasMove) {
  8082. return this._hasMove
  8083. }
  8084. // Detect whether an element with the move class applied has
  8085. // CSS transitions. Since the element may be inside an entering
  8086. // transition at this very moment, we make a clone of it and remove
  8087. // all other transition classes applied to ensure only the move class
  8088. // is applied.
  8089. const clone = el.cloneNode();
  8090. if (el._transitionClasses) {
  8091. el._transitionClasses.forEach((cls) => { removeClass(clone, cls); });
  8092. }
  8093. addClass(clone, moveClass);
  8094. clone.style.display = 'none';
  8095. this.$el.appendChild(clone);
  8096. const info = getTransitionInfo(clone);
  8097. this.$el.removeChild(clone);
  8098. return (this._hasMove = info.hasTransform)
  8099. }
  8100. }
  8101. };
  8102. function callPendingCbs (c) {
  8103. /* istanbul ignore if */
  8104. if (c.elm._moveCb) {
  8105. c.elm._moveCb();
  8106. }
  8107. /* istanbul ignore if */
  8108. if (c.elm._enterCb) {
  8109. c.elm._enterCb();
  8110. }
  8111. }
  8112. function recordPosition (c) {
  8113. c.data.newPos = c.elm.getBoundingClientRect();
  8114. }
  8115. function applyTranslation (c) {
  8116. const oldPos = c.data.pos;
  8117. const newPos = c.data.newPos;
  8118. const dx = oldPos.left - newPos.left;
  8119. const dy = oldPos.top - newPos.top;
  8120. if (dx || dy) {
  8121. c.data.moved = true;
  8122. const s = c.elm.style;
  8123. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  8124. s.transitionDuration = '0s';
  8125. }
  8126. }
  8127. var platformComponents = {
  8128. Transition,
  8129. TransitionGroup
  8130. };
  8131. /* */
  8132. // install platform specific utils
  8133. Vue.config.mustUseProp = mustUseProp;
  8134. Vue.config.isReservedTag = isReservedTag;
  8135. Vue.config.isReservedAttr = isReservedAttr;
  8136. Vue.config.getTagNamespace = getTagNamespace;
  8137. Vue.config.isUnknownElement = isUnknownElement;
  8138. // install platform runtime directives & components
  8139. extend(Vue.options.directives, platformDirectives);
  8140. extend(Vue.options.components, platformComponents);
  8141. // install platform patch function
  8142. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  8143. // public mount method
  8144. Vue.prototype.$mount = function (
  8145. el,
  8146. hydrating
  8147. ) {
  8148. el = el && inBrowser ? query(el) : undefined;
  8149. return mountComponent(this, el, hydrating)
  8150. };
  8151. // devtools global hook
  8152. /* istanbul ignore next */
  8153. if (inBrowser) {
  8154. setTimeout(() => {
  8155. if (config.devtools) {
  8156. if (devtools) {
  8157. devtools.emit('init', Vue);
  8158. } else {
  8159. console[console.info ? 'info' : 'log'](
  8160. 'Download the Vue Devtools extension for a better development experience:\n' +
  8161. 'https://github.com/vuejs/vue-devtools'
  8162. );
  8163. }
  8164. }
  8165. if (config.productionTip !== false &&
  8166. typeof console !== 'undefined'
  8167. ) {
  8168. console[console.info ? 'info' : 'log'](
  8169. `You are running Vue in development mode.\n` +
  8170. `Make sure to turn on production mode when deploying for production.\n` +
  8171. `See more tips at https://vuejs.org/guide/deployment.html`
  8172. );
  8173. }
  8174. }, 0);
  8175. }
  8176. /* */
  8177. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  8178. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  8179. const buildRegex = cached(delimiters => {
  8180. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  8181. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  8182. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  8183. });
  8184. function parseText (
  8185. text,
  8186. delimiters
  8187. ) {
  8188. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  8189. if (!tagRE.test(text)) {
  8190. return
  8191. }
  8192. const tokens = [];
  8193. const rawTokens = [];
  8194. let lastIndex = tagRE.lastIndex = 0;
  8195. let match, index, tokenValue;
  8196. while ((match = tagRE.exec(text))) {
  8197. index = match.index;
  8198. // push text token
  8199. if (index > lastIndex) {
  8200. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  8201. tokens.push(JSON.stringify(tokenValue));
  8202. }
  8203. // tag token
  8204. const exp = parseFilters(match[1].trim());
  8205. tokens.push(`_s(${exp})`);
  8206. rawTokens.push({ '@binding': exp });
  8207. lastIndex = index + match[0].length;
  8208. }
  8209. if (lastIndex < text.length) {
  8210. rawTokens.push(tokenValue = text.slice(lastIndex));
  8211. tokens.push(JSON.stringify(tokenValue));
  8212. }
  8213. return {
  8214. expression: tokens.join('+'),
  8215. tokens: rawTokens
  8216. }
  8217. }
  8218. /* */
  8219. function transformNode (el, options) {
  8220. const warn = options.warn || baseWarn;
  8221. const staticClass = getAndRemoveAttr(el, 'class');
  8222. if (staticClass) {
  8223. const res = parseText(staticClass, options.delimiters);
  8224. if (res) {
  8225. warn(
  8226. `class="${staticClass}": ` +
  8227. 'Interpolation inside attributes has been removed. ' +
  8228. 'Use v-bind or the colon shorthand instead. For example, ' +
  8229. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  8230. el.rawAttrsMap['class']
  8231. );
  8232. }
  8233. }
  8234. if (staticClass) {
  8235. el.staticClass = JSON.stringify(staticClass);
  8236. }
  8237. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  8238. if (classBinding) {
  8239. el.classBinding = classBinding;
  8240. }
  8241. }
  8242. function genData (el) {
  8243. let data = '';
  8244. if (el.staticClass) {
  8245. data += `staticClass:${el.staticClass},`;
  8246. }
  8247. if (el.classBinding) {
  8248. data += `class:${el.classBinding},`;
  8249. }
  8250. return data
  8251. }
  8252. var klass$1 = {
  8253. staticKeys: ['staticClass'],
  8254. transformNode,
  8255. genData
  8256. };
  8257. /* */
  8258. function transformNode$1 (el, options) {
  8259. const warn = options.warn || baseWarn;
  8260. const staticStyle = getAndRemoveAttr(el, 'style');
  8261. if (staticStyle) {
  8262. /* istanbul ignore if */
  8263. {
  8264. const res = parseText(staticStyle, options.delimiters);
  8265. if (res) {
  8266. warn(
  8267. `style="${staticStyle}": ` +
  8268. 'Interpolation inside attributes has been removed. ' +
  8269. 'Use v-bind or the colon shorthand instead. For example, ' +
  8270. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  8271. el.rawAttrsMap['style']
  8272. );
  8273. }
  8274. }
  8275. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  8276. }
  8277. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  8278. if (styleBinding) {
  8279. el.styleBinding = styleBinding;
  8280. }
  8281. }
  8282. function genData$1 (el) {
  8283. let data = '';
  8284. if (el.staticStyle) {
  8285. data += `staticStyle:${el.staticStyle},`;
  8286. }
  8287. if (el.styleBinding) {
  8288. data += `style:(${el.styleBinding}),`;
  8289. }
  8290. return data
  8291. }
  8292. var style$1 = {
  8293. staticKeys: ['staticStyle'],
  8294. transformNode: transformNode$1,
  8295. genData: genData$1
  8296. };
  8297. /* */
  8298. let decoder;
  8299. var he = {
  8300. decode (html) {
  8301. decoder = decoder || document.createElement('div');
  8302. decoder.innerHTML = html;
  8303. return decoder.textContent
  8304. }
  8305. };
  8306. /* */
  8307. const isUnaryTag = makeMap(
  8308. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  8309. 'link,meta,param,source,track,wbr'
  8310. );
  8311. // Elements that you can, intentionally, leave open
  8312. // (and which close themselves)
  8313. const canBeLeftOpenTag = makeMap(
  8314. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  8315. );
  8316. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  8317. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  8318. const isNonPhrasingTag = makeMap(
  8319. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  8320. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  8321. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  8322. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  8323. 'title,tr,track'
  8324. );
  8325. /**
  8326. * Not type-checking this file because it's mostly vendor code.
  8327. */
  8328. // Regular Expressions for parsing tags and attributes
  8329. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8330. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8331. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  8332. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  8333. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  8334. const startTagClose = /^\s*(\/?)>/;
  8335. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  8336. const doctype = /^<!DOCTYPE [^>]+>/i;
  8337. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  8338. const comment = /^<!\--/;
  8339. const conditionalComment = /^<!\[/;
  8340. // Special Elements (can contain anything)
  8341. const isPlainTextElement = makeMap('script,style,textarea', true);
  8342. const reCache = {};
  8343. const decodingMap = {
  8344. '&lt;': '<',
  8345. '&gt;': '>',
  8346. '&quot;': '"',
  8347. '&amp;': '&',
  8348. '&#10;': '\n',
  8349. '&#9;': '\t',
  8350. '&#39;': "'"
  8351. };
  8352. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  8353. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  8354. // #5992
  8355. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  8356. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  8357. function decodeAttr (value, shouldDecodeNewlines) {
  8358. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  8359. return value.replace(re, match => decodingMap[match])
  8360. }
  8361. function parseHTML (html, options) {
  8362. const stack = [];
  8363. const expectHTML = options.expectHTML;
  8364. const isUnaryTag$$1 = options.isUnaryTag || no;
  8365. const canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  8366. let index = 0;
  8367. let last, lastTag;
  8368. while (html) {
  8369. last = html;
  8370. // Make sure we're not in a plaintext content element like script/style
  8371. if (!lastTag || !isPlainTextElement(lastTag)) {
  8372. let textEnd = html.indexOf('<');
  8373. if (textEnd === 0) {
  8374. // Comment:
  8375. if (comment.test(html)) {
  8376. const commentEnd = html.indexOf('-->');
  8377. if (commentEnd >= 0) {
  8378. if (options.shouldKeepComment) {
  8379. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  8380. }
  8381. advance(commentEnd + 3);
  8382. continue
  8383. }
  8384. }
  8385. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  8386. if (conditionalComment.test(html)) {
  8387. const conditionalEnd = html.indexOf(']>');
  8388. if (conditionalEnd >= 0) {
  8389. advance(conditionalEnd + 2);
  8390. continue
  8391. }
  8392. }
  8393. // Doctype:
  8394. const doctypeMatch = html.match(doctype);
  8395. if (doctypeMatch) {
  8396. advance(doctypeMatch[0].length);
  8397. continue
  8398. }
  8399. // End tag:
  8400. const endTagMatch = html.match(endTag);
  8401. if (endTagMatch) {
  8402. const curIndex = index;
  8403. advance(endTagMatch[0].length);
  8404. parseEndTag(endTagMatch[1], curIndex, index);
  8405. continue
  8406. }
  8407. // Start tag:
  8408. const startTagMatch = parseStartTag();
  8409. if (startTagMatch) {
  8410. handleStartTag(startTagMatch);
  8411. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  8412. advance(1);
  8413. }
  8414. continue
  8415. }
  8416. }
  8417. let text, rest, next;
  8418. if (textEnd >= 0) {
  8419. rest = html.slice(textEnd);
  8420. while (
  8421. !endTag.test(rest) &&
  8422. !startTagOpen.test(rest) &&
  8423. !comment.test(rest) &&
  8424. !conditionalComment.test(rest)
  8425. ) {
  8426. // < in plain text, be forgiving and treat it as text
  8427. next = rest.indexOf('<', 1);
  8428. if (next < 0) break
  8429. textEnd += next;
  8430. rest = html.slice(textEnd);
  8431. }
  8432. text = html.substring(0, textEnd);
  8433. }
  8434. if (textEnd < 0) {
  8435. text = html;
  8436. }
  8437. if (text) {
  8438. advance(text.length);
  8439. }
  8440. if (options.chars && text) {
  8441. options.chars(text, index - text.length, index);
  8442. }
  8443. } else {
  8444. let endTagLength = 0;
  8445. const stackedTag = lastTag.toLowerCase();
  8446. const reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  8447. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  8448. endTagLength = endTag.length;
  8449. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  8450. text = text
  8451. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  8452. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  8453. }
  8454. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  8455. text = text.slice(1);
  8456. }
  8457. if (options.chars) {
  8458. options.chars(text);
  8459. }
  8460. return ''
  8461. });
  8462. index += html.length - rest.length;
  8463. html = rest;
  8464. parseEndTag(stackedTag, index - endTagLength, index);
  8465. }
  8466. if (html === last) {
  8467. options.chars && options.chars(html);
  8468. if (!stack.length && options.warn) {
  8469. options.warn(`Mal-formatted tag at end of template: "${html}"`, { start: index + html.length });
  8470. }
  8471. break
  8472. }
  8473. }
  8474. // Clean up any remaining tags
  8475. parseEndTag();
  8476. function advance (n) {
  8477. index += n;
  8478. html = html.substring(n);
  8479. }
  8480. function parseStartTag () {
  8481. const start = html.match(startTagOpen);
  8482. if (start) {
  8483. const match = {
  8484. tagName: start[1],
  8485. attrs: [],
  8486. start: index
  8487. };
  8488. advance(start[0].length);
  8489. let end, attr;
  8490. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  8491. attr.start = index;
  8492. advance(attr[0].length);
  8493. attr.end = index;
  8494. match.attrs.push(attr);
  8495. }
  8496. if (end) {
  8497. match.unarySlash = end[1];
  8498. advance(end[0].length);
  8499. match.end = index;
  8500. return match
  8501. }
  8502. }
  8503. }
  8504. function handleStartTag (match) {
  8505. const tagName = match.tagName;
  8506. const unarySlash = match.unarySlash;
  8507. if (expectHTML) {
  8508. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  8509. parseEndTag(lastTag);
  8510. }
  8511. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  8512. parseEndTag(tagName);
  8513. }
  8514. }
  8515. const unary = isUnaryTag$$1(tagName) || !!unarySlash;
  8516. const l = match.attrs.length;
  8517. const attrs = new Array(l);
  8518. for (let i = 0; i < l; i++) {
  8519. const args = match.attrs[i];
  8520. const value = args[3] || args[4] || args[5] || '';
  8521. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  8522. ? options.shouldDecodeNewlinesForHref
  8523. : options.shouldDecodeNewlines;
  8524. attrs[i] = {
  8525. name: args[1],
  8526. value: decodeAttr(value, shouldDecodeNewlines)
  8527. };
  8528. if (options.outputSourceRange) {
  8529. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  8530. attrs[i].end = args.end;
  8531. }
  8532. }
  8533. if (!unary) {
  8534. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  8535. lastTag = tagName;
  8536. }
  8537. if (options.start) {
  8538. options.start(tagName, attrs, unary, match.start, match.end);
  8539. }
  8540. }
  8541. function parseEndTag (tagName, start, end) {
  8542. let pos, lowerCasedTagName;
  8543. if (start == null) start = index;
  8544. if (end == null) end = index;
  8545. // Find the closest opened tag of the same type
  8546. if (tagName) {
  8547. lowerCasedTagName = tagName.toLowerCase();
  8548. for (pos = stack.length - 1; pos >= 0; pos--) {
  8549. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  8550. break
  8551. }
  8552. }
  8553. } else {
  8554. // If no tag name is provided, clean shop
  8555. pos = 0;
  8556. }
  8557. if (pos >= 0) {
  8558. // Close all the open elements, up the stack
  8559. for (let i = stack.length - 1; i >= pos; i--) {
  8560. if (i > pos || !tagName &&
  8561. options.warn
  8562. ) {
  8563. options.warn(
  8564. `tag <${stack[i].tag}> has no matching end tag.`,
  8565. { start: stack[i].start, end: stack[i].end }
  8566. );
  8567. }
  8568. if (options.end) {
  8569. options.end(stack[i].tag, start, end);
  8570. }
  8571. }
  8572. // Remove the open elements from the stack
  8573. stack.length = pos;
  8574. lastTag = pos && stack[pos - 1].tag;
  8575. } else if (lowerCasedTagName === 'br') {
  8576. if (options.start) {
  8577. options.start(tagName, [], true, start, end);
  8578. }
  8579. } else if (lowerCasedTagName === 'p') {
  8580. if (options.start) {
  8581. options.start(tagName, [], false, start, end);
  8582. }
  8583. if (options.end) {
  8584. options.end(tagName, start, end);
  8585. }
  8586. }
  8587. }
  8588. }
  8589. /* */
  8590. const onRE = /^@|^v-on:/;
  8591. const dirRE = /^v-|^@|^:|^#/;
  8592. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  8593. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  8594. const stripParensRE = /^\(|\)$/g;
  8595. const dynamicArgRE = /^\[.*\]$/;
  8596. const argRE = /:(.*)$/;
  8597. const bindRE = /^:|^\.|^v-bind:/;
  8598. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  8599. const slotRE = /^v-slot(:|$)|^#/;
  8600. const lineBreakRE = /[\r\n]/;
  8601. const whitespaceRE$1 = /\s+/g;
  8602. const invalidAttributeRE = /[\s"'<>\/=]/;
  8603. const decodeHTMLCached = cached(he.decode);
  8604. const emptySlotScopeToken = `_empty_`;
  8605. // configurable state
  8606. let warn$2;
  8607. let delimiters;
  8608. let transforms;
  8609. let preTransforms;
  8610. let postTransforms;
  8611. let platformIsPreTag;
  8612. let platformMustUseProp;
  8613. let platformGetTagNamespace;
  8614. let maybeComponent;
  8615. function createASTElement (
  8616. tag,
  8617. attrs,
  8618. parent
  8619. ) {
  8620. return {
  8621. type: 1,
  8622. tag,
  8623. attrsList: attrs,
  8624. attrsMap: makeAttrsMap(attrs),
  8625. rawAttrsMap: {},
  8626. parent,
  8627. children: []
  8628. }
  8629. }
  8630. /**
  8631. * Convert HTML string to AST.
  8632. */
  8633. function parse (
  8634. template,
  8635. options
  8636. ) {
  8637. warn$2 = options.warn || baseWarn;
  8638. platformIsPreTag = options.isPreTag || no;
  8639. platformMustUseProp = options.mustUseProp || no;
  8640. platformGetTagNamespace = options.getTagNamespace || no;
  8641. const isReservedTag = options.isReservedTag || no;
  8642. maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  8643. transforms = pluckModuleFunction(options.modules, 'transformNode');
  8644. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  8645. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  8646. delimiters = options.delimiters;
  8647. const stack = [];
  8648. const preserveWhitespace = options.preserveWhitespace !== false;
  8649. const whitespaceOption = options.whitespace;
  8650. let root;
  8651. let currentParent;
  8652. let inVPre = false;
  8653. let inPre = false;
  8654. let warned = false;
  8655. function warnOnce (msg, range) {
  8656. if (!warned) {
  8657. warned = true;
  8658. warn$2(msg, range);
  8659. }
  8660. }
  8661. function closeElement (element) {
  8662. trimEndingWhitespace(element);
  8663. if (!inVPre && !element.processed) {
  8664. element = processElement(element, options);
  8665. }
  8666. // tree management
  8667. if (!stack.length && element !== root) {
  8668. // allow root elements with v-if, v-else-if and v-else
  8669. if (root.if && (element.elseif || element.else)) {
  8670. {
  8671. checkRootConstraints(element);
  8672. }
  8673. addIfCondition(root, {
  8674. exp: element.elseif,
  8675. block: element
  8676. });
  8677. } else {
  8678. warnOnce(
  8679. `Component template should contain exactly one root element. ` +
  8680. `If you are using v-if on multiple elements, ` +
  8681. `use v-else-if to chain them instead.`,
  8682. { start: element.start }
  8683. );
  8684. }
  8685. }
  8686. if (currentParent && !element.forbidden) {
  8687. if (element.elseif || element.else) {
  8688. processIfConditions(element, currentParent);
  8689. } else {
  8690. if (element.slotScope) {
  8691. // scoped slot
  8692. // keep it in the children list so that v-else(-if) conditions can
  8693. // find it as the prev node.
  8694. const name = element.slotTarget || '"default"'
  8695. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  8696. }
  8697. currentParent.children.push(element);
  8698. element.parent = currentParent;
  8699. }
  8700. }
  8701. // final children cleanup
  8702. // filter out scoped slots
  8703. element.children = element.children.filter(c => !(c).slotScope);
  8704. // remove trailing whitespace node again
  8705. trimEndingWhitespace(element);
  8706. // check pre state
  8707. if (element.pre) {
  8708. inVPre = false;
  8709. }
  8710. if (platformIsPreTag(element.tag)) {
  8711. inPre = false;
  8712. }
  8713. // apply post-transforms
  8714. for (let i = 0; i < postTransforms.length; i++) {
  8715. postTransforms[i](element, options);
  8716. }
  8717. }
  8718. function trimEndingWhitespace (el) {
  8719. // remove trailing whitespace node
  8720. if (!inPre) {
  8721. let lastNode;
  8722. while (
  8723. (lastNode = el.children[el.children.length - 1]) &&
  8724. lastNode.type === 3 &&
  8725. lastNode.text === ' '
  8726. ) {
  8727. el.children.pop();
  8728. }
  8729. }
  8730. }
  8731. function checkRootConstraints (el) {
  8732. if (el.tag === 'slot' || el.tag === 'template') {
  8733. warnOnce(
  8734. `Cannot use <${el.tag}> as component root element because it may ` +
  8735. 'contain multiple nodes.',
  8736. { start: el.start }
  8737. );
  8738. }
  8739. if (el.attrsMap.hasOwnProperty('v-for')) {
  8740. warnOnce(
  8741. 'Cannot use v-for on stateful component root element because ' +
  8742. 'it renders multiple elements.',
  8743. el.rawAttrsMap['v-for']
  8744. );
  8745. }
  8746. }
  8747. parseHTML(template, {
  8748. warn: warn$2,
  8749. expectHTML: options.expectHTML,
  8750. isUnaryTag: options.isUnaryTag,
  8751. canBeLeftOpenTag: options.canBeLeftOpenTag,
  8752. shouldDecodeNewlines: options.shouldDecodeNewlines,
  8753. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  8754. shouldKeepComment: options.comments,
  8755. outputSourceRange: options.outputSourceRange,
  8756. start (tag, attrs, unary, start, end) {
  8757. // check namespace.
  8758. // inherit parent ns if there is one
  8759. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  8760. // handle IE svg bug
  8761. /* istanbul ignore if */
  8762. if (isIE && ns === 'svg') {
  8763. attrs = guardIESVGBug(attrs);
  8764. }
  8765. let element = createASTElement(tag, attrs, currentParent);
  8766. if (ns) {
  8767. element.ns = ns;
  8768. }
  8769. {
  8770. if (options.outputSourceRange) {
  8771. element.start = start;
  8772. element.end = end;
  8773. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  8774. cumulated[attr.name] = attr;
  8775. return cumulated
  8776. }, {});
  8777. }
  8778. attrs.forEach(attr => {
  8779. if (invalidAttributeRE.test(attr.name)) {
  8780. warn$2(
  8781. `Invalid dynamic argument expression: attribute names cannot contain ` +
  8782. `spaces, quotes, <, >, / or =.`,
  8783. {
  8784. start: attr.start + attr.name.indexOf(`[`),
  8785. end: attr.start + attr.name.length
  8786. }
  8787. );
  8788. }
  8789. });
  8790. }
  8791. if (isForbiddenTag(element) && !isServerRendering()) {
  8792. element.forbidden = true;
  8793. warn$2(
  8794. 'Templates should only be responsible for mapping the state to the ' +
  8795. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  8796. `<${tag}>` + ', as they will not be parsed.',
  8797. { start: element.start }
  8798. );
  8799. }
  8800. // apply pre-transforms
  8801. for (let i = 0; i < preTransforms.length; i++) {
  8802. element = preTransforms[i](element, options) || element;
  8803. }
  8804. if (!inVPre) {
  8805. processPre(element);
  8806. if (element.pre) {
  8807. inVPre = true;
  8808. }
  8809. }
  8810. if (platformIsPreTag(element.tag)) {
  8811. inPre = true;
  8812. }
  8813. if (inVPre) {
  8814. processRawAttrs(element);
  8815. } else if (!element.processed) {
  8816. // structural directives
  8817. processFor(element);
  8818. processIf(element);
  8819. processOnce(element);
  8820. }
  8821. if (!root) {
  8822. root = element;
  8823. {
  8824. checkRootConstraints(root);
  8825. }
  8826. }
  8827. if (!unary) {
  8828. currentParent = element;
  8829. stack.push(element);
  8830. } else {
  8831. closeElement(element);
  8832. }
  8833. },
  8834. end (tag, start, end) {
  8835. const element = stack[stack.length - 1];
  8836. // pop stack
  8837. stack.length -= 1;
  8838. currentParent = stack[stack.length - 1];
  8839. if (options.outputSourceRange) {
  8840. element.end = end;
  8841. }
  8842. closeElement(element);
  8843. },
  8844. chars (text, start, end) {
  8845. if (!currentParent) {
  8846. {
  8847. if (text === template) {
  8848. warnOnce(
  8849. 'Component template requires a root element, rather than just text.',
  8850. { start }
  8851. );
  8852. } else if ((text = text.trim())) {
  8853. warnOnce(
  8854. `text "${text}" outside root element will be ignored.`,
  8855. { start }
  8856. );
  8857. }
  8858. }
  8859. return
  8860. }
  8861. // IE textarea placeholder bug
  8862. /* istanbul ignore if */
  8863. if (isIE &&
  8864. currentParent.tag === 'textarea' &&
  8865. currentParent.attrsMap.placeholder === text
  8866. ) {
  8867. return
  8868. }
  8869. const children = currentParent.children;
  8870. if (inPre || text.trim()) {
  8871. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  8872. } else if (!children.length) {
  8873. // remove the whitespace-only node right after an opening tag
  8874. text = '';
  8875. } else if (whitespaceOption) {
  8876. if (whitespaceOption === 'condense') {
  8877. // in condense mode, remove the whitespace node if it contains
  8878. // line break, otherwise condense to a single space
  8879. text = lineBreakRE.test(text) ? '' : ' ';
  8880. } else {
  8881. text = ' ';
  8882. }
  8883. } else {
  8884. text = preserveWhitespace ? ' ' : '';
  8885. }
  8886. if (text) {
  8887. if (!inPre && whitespaceOption === 'condense') {
  8888. // condense consecutive whitespaces into single space
  8889. text = text.replace(whitespaceRE$1, ' ');
  8890. }
  8891. let res;
  8892. let child;
  8893. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  8894. child = {
  8895. type: 2,
  8896. expression: res.expression,
  8897. tokens: res.tokens,
  8898. text
  8899. };
  8900. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  8901. child = {
  8902. type: 3,
  8903. text
  8904. };
  8905. }
  8906. if (child) {
  8907. if (options.outputSourceRange) {
  8908. child.start = start;
  8909. child.end = end;
  8910. }
  8911. children.push(child);
  8912. }
  8913. }
  8914. },
  8915. comment (text, start, end) {
  8916. // adding anything as a sibling to the root node is forbidden
  8917. // comments should still be allowed, but ignored
  8918. if (currentParent) {
  8919. const child = {
  8920. type: 3,
  8921. text,
  8922. isComment: true
  8923. };
  8924. if (options.outputSourceRange) {
  8925. child.start = start;
  8926. child.end = end;
  8927. }
  8928. currentParent.children.push(child);
  8929. }
  8930. }
  8931. });
  8932. return root
  8933. }
  8934. function processPre (el) {
  8935. if (getAndRemoveAttr(el, 'v-pre') != null) {
  8936. el.pre = true;
  8937. }
  8938. }
  8939. function processRawAttrs (el) {
  8940. const list = el.attrsList;
  8941. const len = list.length;
  8942. if (len) {
  8943. const attrs = el.attrs = new Array(len);
  8944. for (let i = 0; i < len; i++) {
  8945. attrs[i] = {
  8946. name: list[i].name,
  8947. value: JSON.stringify(list[i].value)
  8948. };
  8949. if (list[i].start != null) {
  8950. attrs[i].start = list[i].start;
  8951. attrs[i].end = list[i].end;
  8952. }
  8953. }
  8954. } else if (!el.pre) {
  8955. // non root node in pre blocks with no attributes
  8956. el.plain = true;
  8957. }
  8958. }
  8959. function processElement (
  8960. element,
  8961. options
  8962. ) {
  8963. processKey(element);
  8964. // determine whether this is a plain element after
  8965. // removing structural attributes
  8966. element.plain = (
  8967. !element.key &&
  8968. !element.scopedSlots &&
  8969. !element.attrsList.length
  8970. );
  8971. processRef(element);
  8972. processSlotContent(element);
  8973. processSlotOutlet(element);
  8974. processComponent(element);
  8975. for (let i = 0; i < transforms.length; i++) {
  8976. element = transforms[i](element, options) || element;
  8977. }
  8978. processAttrs(element);
  8979. return element
  8980. }
  8981. function processKey (el) {
  8982. const exp = getBindingAttr(el, 'key');
  8983. if (exp) {
  8984. {
  8985. if (el.tag === 'template') {
  8986. warn$2(
  8987. `<template> cannot be keyed. Place the key on real elements instead.`,
  8988. getRawBindingAttr(el, 'key')
  8989. );
  8990. }
  8991. if (el.for) {
  8992. const iterator = el.iterator2 || el.iterator1;
  8993. const parent = el.parent;
  8994. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  8995. warn$2(
  8996. `Do not use v-for index as key on <transition-group> children, ` +
  8997. `this is the same as not using keys.`,
  8998. getRawBindingAttr(el, 'key'),
  8999. true /* tip */
  9000. );
  9001. }
  9002. }
  9003. }
  9004. el.key = exp;
  9005. }
  9006. }
  9007. function processRef (el) {
  9008. const ref = getBindingAttr(el, 'ref');
  9009. if (ref) {
  9010. el.ref = ref;
  9011. el.refInFor = checkInFor(el);
  9012. }
  9013. }
  9014. function processFor (el) {
  9015. let exp;
  9016. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9017. const res = parseFor(exp);
  9018. if (res) {
  9019. extend(el, res);
  9020. } else {
  9021. warn$2(
  9022. `Invalid v-for expression: ${exp}`,
  9023. el.rawAttrsMap['v-for']
  9024. );
  9025. }
  9026. }
  9027. }
  9028. function parseFor (exp) {
  9029. const inMatch = exp.match(forAliasRE);
  9030. if (!inMatch) return
  9031. const res = {};
  9032. res.for = inMatch[2].trim();
  9033. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9034. const iteratorMatch = alias.match(forIteratorRE);
  9035. if (iteratorMatch) {
  9036. res.alias = alias.replace(forIteratorRE, '').trim();
  9037. res.iterator1 = iteratorMatch[1].trim();
  9038. if (iteratorMatch[2]) {
  9039. res.iterator2 = iteratorMatch[2].trim();
  9040. }
  9041. } else {
  9042. res.alias = alias;
  9043. }
  9044. return res
  9045. }
  9046. function processIf (el) {
  9047. const exp = getAndRemoveAttr(el, 'v-if');
  9048. if (exp) {
  9049. el.if = exp;
  9050. addIfCondition(el, {
  9051. exp: exp,
  9052. block: el
  9053. });
  9054. } else {
  9055. if (getAndRemoveAttr(el, 'v-else') != null) {
  9056. el.else = true;
  9057. }
  9058. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9059. if (elseif) {
  9060. el.elseif = elseif;
  9061. }
  9062. }
  9063. }
  9064. function processIfConditions (el, parent) {
  9065. const prev = findPrevElement(parent.children);
  9066. if (prev && prev.if) {
  9067. addIfCondition(prev, {
  9068. exp: el.elseif,
  9069. block: el
  9070. });
  9071. } else {
  9072. warn$2(
  9073. `v-${el.elseif ? ('else-if="' + el.elseif + '"') : 'else'} ` +
  9074. `used on element <${el.tag}> without corresponding v-if.`,
  9075. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  9076. );
  9077. }
  9078. }
  9079. function findPrevElement (children) {
  9080. let i = children.length;
  9081. while (i--) {
  9082. if (children[i].type === 1) {
  9083. return children[i]
  9084. } else {
  9085. if (children[i].text !== ' ') {
  9086. warn$2(
  9087. `text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  9088. `will be ignored.`,
  9089. children[i]
  9090. );
  9091. }
  9092. children.pop();
  9093. }
  9094. }
  9095. }
  9096. function addIfCondition (el, condition) {
  9097. if (!el.ifConditions) {
  9098. el.ifConditions = [];
  9099. }
  9100. el.ifConditions.push(condition);
  9101. }
  9102. function processOnce (el) {
  9103. const once$$1 = getAndRemoveAttr(el, 'v-once');
  9104. if (once$$1 != null) {
  9105. el.once = true;
  9106. }
  9107. }
  9108. // handle content being passed to a component as slot,
  9109. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  9110. function processSlotContent (el) {
  9111. let slotScope;
  9112. if (el.tag === 'template') {
  9113. slotScope = getAndRemoveAttr(el, 'scope');
  9114. /* istanbul ignore if */
  9115. if (slotScope) {
  9116. warn$2(
  9117. `the "scope" attribute for scoped slots have been deprecated and ` +
  9118. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  9119. `can also be used on plain elements in addition to <template> to ` +
  9120. `denote scoped slots.`,
  9121. el.rawAttrsMap['scope'],
  9122. true
  9123. );
  9124. }
  9125. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  9126. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  9127. /* istanbul ignore if */
  9128. if (el.attrsMap['v-for']) {
  9129. warn$2(
  9130. `Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  9131. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  9132. `scoped slot to make it clearer.`,
  9133. el.rawAttrsMap['slot-scope'],
  9134. true
  9135. );
  9136. }
  9137. el.slotScope = slotScope;
  9138. }
  9139. // slot="xxx"
  9140. const slotTarget = getBindingAttr(el, 'slot');
  9141. if (slotTarget) {
  9142. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  9143. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  9144. // preserve slot as an attribute for native shadow DOM compat
  9145. // only for non-scoped slots.
  9146. if (el.tag !== 'template' && !el.slotScope) {
  9147. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  9148. }
  9149. }
  9150. // 2.6 v-slot syntax
  9151. {
  9152. if (el.tag === 'template') {
  9153. // v-slot on <template>
  9154. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  9155. if (slotBinding) {
  9156. {
  9157. if (el.slotTarget || el.slotScope) {
  9158. warn$2(
  9159. `Unexpected mixed usage of different slot syntaxes.`,
  9160. el
  9161. );
  9162. }
  9163. if (el.parent && !maybeComponent(el.parent)) {
  9164. warn$2(
  9165. `<template v-slot> can only appear at the root level inside ` +
  9166. `the receiving component`,
  9167. el
  9168. );
  9169. }
  9170. }
  9171. const { name, dynamic } = getSlotName(slotBinding);
  9172. el.slotTarget = name;
  9173. el.slotTargetDynamic = dynamic;
  9174. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  9175. }
  9176. } else {
  9177. // v-slot on component, denotes default slot
  9178. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  9179. if (slotBinding) {
  9180. {
  9181. if (!maybeComponent(el)) {
  9182. warn$2(
  9183. `v-slot can only be used on components or <template>.`,
  9184. slotBinding
  9185. );
  9186. }
  9187. if (el.slotScope || el.slotTarget) {
  9188. warn$2(
  9189. `Unexpected mixed usage of different slot syntaxes.`,
  9190. el
  9191. );
  9192. }
  9193. if (el.scopedSlots) {
  9194. warn$2(
  9195. `To avoid scope ambiguity, the default slot should also use ` +
  9196. `<template> syntax when there are other named slots.`,
  9197. slotBinding
  9198. );
  9199. }
  9200. }
  9201. // add the component's children to its default slot
  9202. const slots = el.scopedSlots || (el.scopedSlots = {});
  9203. const { name, dynamic } = getSlotName(slotBinding);
  9204. const slotContainer = slots[name] = createASTElement('template', [], el);
  9205. slotContainer.slotTarget = name;
  9206. slotContainer.slotTargetDynamic = dynamic;
  9207. slotContainer.children = el.children.filter((c) => {
  9208. if (!c.slotScope) {
  9209. c.parent = slotContainer;
  9210. return true
  9211. }
  9212. });
  9213. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  9214. // remove children as they are returned from scopedSlots now
  9215. el.children = [];
  9216. // mark el non-plain so data gets generated
  9217. el.plain = false;
  9218. }
  9219. }
  9220. }
  9221. }
  9222. function getSlotName (binding) {
  9223. let name = binding.name.replace(slotRE, '');
  9224. if (!name) {
  9225. if (binding.name[0] !== '#') {
  9226. name = 'default';
  9227. } else {
  9228. warn$2(
  9229. `v-slot shorthand syntax requires a slot name.`,
  9230. binding
  9231. );
  9232. }
  9233. }
  9234. return dynamicArgRE.test(name)
  9235. // dynamic [name]
  9236. ? { name: name.slice(1, -1), dynamic: true }
  9237. // static name
  9238. : { name: `"${name}"`, dynamic: false }
  9239. }
  9240. // handle <slot/> outlets
  9241. function processSlotOutlet (el) {
  9242. if (el.tag === 'slot') {
  9243. el.slotName = getBindingAttr(el, 'name');
  9244. if (el.key) {
  9245. warn$2(
  9246. `\`key\` does not work on <slot> because slots are abstract outlets ` +
  9247. `and can possibly expand into multiple elements. ` +
  9248. `Use the key on a wrapping element instead.`,
  9249. getRawBindingAttr(el, 'key')
  9250. );
  9251. }
  9252. }
  9253. }
  9254. function processComponent (el) {
  9255. let binding;
  9256. if ((binding = getBindingAttr(el, 'is'))) {
  9257. el.component = binding;
  9258. }
  9259. if (getAndRemoveAttr(el, 'inline-template') != null) {
  9260. el.inlineTemplate = true;
  9261. }
  9262. }
  9263. function processAttrs (el) {
  9264. const list = el.attrsList;
  9265. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  9266. for (i = 0, l = list.length; i < l; i++) {
  9267. name = rawName = list[i].name;
  9268. value = list[i].value;
  9269. if (dirRE.test(name)) {
  9270. // mark element as dynamic
  9271. el.hasBindings = true;
  9272. // modifiers
  9273. modifiers = parseModifiers(name.replace(dirRE, ''));
  9274. // support .foo shorthand syntax for the .prop modifier
  9275. if (modifiers) {
  9276. name = name.replace(modifierRE, '');
  9277. }
  9278. if (bindRE.test(name)) { // v-bind
  9279. name = name.replace(bindRE, '');
  9280. value = parseFilters(value);
  9281. isDynamic = dynamicArgRE.test(name);
  9282. if (isDynamic) {
  9283. name = name.slice(1, -1);
  9284. }
  9285. if (
  9286. value.trim().length === 0
  9287. ) {
  9288. warn$2(
  9289. `The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`
  9290. );
  9291. }
  9292. if (modifiers) {
  9293. if (modifiers.prop && !isDynamic) {
  9294. name = camelize(name);
  9295. if (name === 'innerHtml') name = 'innerHTML';
  9296. }
  9297. if (modifiers.camel && !isDynamic) {
  9298. name = camelize(name);
  9299. }
  9300. if (modifiers.sync) {
  9301. syncGen = genAssignmentCode(value, `$event`);
  9302. if (!isDynamic) {
  9303. addHandler(
  9304. el,
  9305. `update:${camelize(name)}`,
  9306. syncGen,
  9307. null,
  9308. false,
  9309. warn$2,
  9310. list[i]
  9311. );
  9312. if (hyphenate(name) !== camelize(name)) {
  9313. addHandler(
  9314. el,
  9315. `update:${hyphenate(name)}`,
  9316. syncGen,
  9317. null,
  9318. false,
  9319. warn$2,
  9320. list[i]
  9321. );
  9322. }
  9323. } else {
  9324. // handler w/ dynamic event name
  9325. addHandler(
  9326. el,
  9327. `"update:"+(${name})`,
  9328. syncGen,
  9329. null,
  9330. false,
  9331. warn$2,
  9332. list[i],
  9333. true // dynamic
  9334. );
  9335. }
  9336. }
  9337. }
  9338. if ((modifiers && modifiers.prop) || (
  9339. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  9340. )) {
  9341. addProp(el, name, value, list[i], isDynamic);
  9342. } else {
  9343. addAttr(el, name, value, list[i], isDynamic);
  9344. }
  9345. } else if (onRE.test(name)) { // v-on
  9346. name = name.replace(onRE, '');
  9347. isDynamic = dynamicArgRE.test(name);
  9348. if (isDynamic) {
  9349. name = name.slice(1, -1);
  9350. }
  9351. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  9352. } else { // normal directives
  9353. name = name.replace(dirRE, '');
  9354. // parse arg
  9355. const argMatch = name.match(argRE);
  9356. let arg = argMatch && argMatch[1];
  9357. isDynamic = false;
  9358. if (arg) {
  9359. name = name.slice(0, -(arg.length + 1));
  9360. if (dynamicArgRE.test(arg)) {
  9361. arg = arg.slice(1, -1);
  9362. isDynamic = true;
  9363. }
  9364. }
  9365. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  9366. if (name === 'model') {
  9367. checkForAliasModel(el, value);
  9368. }
  9369. }
  9370. } else {
  9371. // literal attribute
  9372. {
  9373. const res = parseText(value, delimiters);
  9374. if (res) {
  9375. warn$2(
  9376. `${name}="${value}": ` +
  9377. 'Interpolation inside attributes has been removed. ' +
  9378. 'Use v-bind or the colon shorthand instead. For example, ' +
  9379. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  9380. list[i]
  9381. );
  9382. }
  9383. }
  9384. addAttr(el, name, JSON.stringify(value), list[i]);
  9385. // #6887 firefox doesn't update muted state if set via attribute
  9386. // even immediately after element creation
  9387. if (!el.component &&
  9388. name === 'muted' &&
  9389. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  9390. addProp(el, name, 'true', list[i]);
  9391. }
  9392. }
  9393. }
  9394. }
  9395. function checkInFor (el) {
  9396. let parent = el;
  9397. while (parent) {
  9398. if (parent.for !== undefined) {
  9399. return true
  9400. }
  9401. parent = parent.parent;
  9402. }
  9403. return false
  9404. }
  9405. function parseModifiers (name) {
  9406. const match = name.match(modifierRE);
  9407. if (match) {
  9408. const ret = {};
  9409. match.forEach(m => { ret[m.slice(1)] = true; });
  9410. return ret
  9411. }
  9412. }
  9413. function makeAttrsMap (attrs) {
  9414. const map = {};
  9415. for (let i = 0, l = attrs.length; i < l; i++) {
  9416. if (
  9417. map[attrs[i].name] && !isIE && !isEdge
  9418. ) {
  9419. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  9420. }
  9421. map[attrs[i].name] = attrs[i].value;
  9422. }
  9423. return map
  9424. }
  9425. // for script (e.g. type="x/template") or style, do not decode content
  9426. function isTextTag (el) {
  9427. return el.tag === 'script' || el.tag === 'style'
  9428. }
  9429. function isForbiddenTag (el) {
  9430. return (
  9431. el.tag === 'style' ||
  9432. (el.tag === 'script' && (
  9433. !el.attrsMap.type ||
  9434. el.attrsMap.type === 'text/javascript'
  9435. ))
  9436. )
  9437. }
  9438. const ieNSBug = /^xmlns:NS\d+/;
  9439. const ieNSPrefix = /^NS\d+:/;
  9440. /* istanbul ignore next */
  9441. function guardIESVGBug (attrs) {
  9442. const res = [];
  9443. for (let i = 0; i < attrs.length; i++) {
  9444. const attr = attrs[i];
  9445. if (!ieNSBug.test(attr.name)) {
  9446. attr.name = attr.name.replace(ieNSPrefix, '');
  9447. res.push(attr);
  9448. }
  9449. }
  9450. return res
  9451. }
  9452. function checkForAliasModel (el, value) {
  9453. let _el = el;
  9454. while (_el) {
  9455. if (_el.for && _el.alias === value) {
  9456. warn$2(
  9457. `<${el.tag} v-model="${value}">: ` +
  9458. `You are binding v-model directly to a v-for iteration alias. ` +
  9459. `This will not be able to modify the v-for source array because ` +
  9460. `writing to the alias is like modifying a function local variable. ` +
  9461. `Consider using an array of objects and use v-model on an object property instead.`,
  9462. el.rawAttrsMap['v-model']
  9463. );
  9464. }
  9465. _el = _el.parent;
  9466. }
  9467. }
  9468. /* */
  9469. function preTransformNode (el, options) {
  9470. if (el.tag === 'input') {
  9471. const map = el.attrsMap;
  9472. if (!map['v-model']) {
  9473. return
  9474. }
  9475. let typeBinding;
  9476. if (map[':type'] || map['v-bind:type']) {
  9477. typeBinding = getBindingAttr(el, 'type');
  9478. }
  9479. if (!map.type && !typeBinding && map['v-bind']) {
  9480. typeBinding = `(${map['v-bind']}).type`;
  9481. }
  9482. if (typeBinding) {
  9483. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  9484. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  9485. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  9486. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  9487. // 1. checkbox
  9488. const branch0 = cloneASTElement(el);
  9489. // process for on the main node
  9490. processFor(branch0);
  9491. addRawAttr(branch0, 'type', 'checkbox');
  9492. processElement(branch0, options);
  9493. branch0.processed = true; // prevent it from double-processed
  9494. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  9495. addIfCondition(branch0, {
  9496. exp: branch0.if,
  9497. block: branch0
  9498. });
  9499. // 2. add radio else-if condition
  9500. const branch1 = cloneASTElement(el);
  9501. getAndRemoveAttr(branch1, 'v-for', true);
  9502. addRawAttr(branch1, 'type', 'radio');
  9503. processElement(branch1, options);
  9504. addIfCondition(branch0, {
  9505. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  9506. block: branch1
  9507. });
  9508. // 3. other
  9509. const branch2 = cloneASTElement(el);
  9510. getAndRemoveAttr(branch2, 'v-for', true);
  9511. addRawAttr(branch2, ':type', typeBinding);
  9512. processElement(branch2, options);
  9513. addIfCondition(branch0, {
  9514. exp: ifCondition,
  9515. block: branch2
  9516. });
  9517. if (hasElse) {
  9518. branch0.else = true;
  9519. } else if (elseIfCondition) {
  9520. branch0.elseif = elseIfCondition;
  9521. }
  9522. return branch0
  9523. }
  9524. }
  9525. }
  9526. function cloneASTElement (el) {
  9527. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  9528. }
  9529. var model$1 = {
  9530. preTransformNode
  9531. };
  9532. var modules$1 = [
  9533. klass$1,
  9534. style$1,
  9535. model$1
  9536. ];
  9537. /* */
  9538. function text (el, dir) {
  9539. if (dir.value) {
  9540. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  9541. }
  9542. }
  9543. /* */
  9544. function html (el, dir) {
  9545. if (dir.value) {
  9546. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  9547. }
  9548. }
  9549. var directives$1 = {
  9550. model,
  9551. text,
  9552. html
  9553. };
  9554. /* */
  9555. const baseOptions = {
  9556. expectHTML: true,
  9557. modules: modules$1,
  9558. directives: directives$1,
  9559. isPreTag,
  9560. isUnaryTag,
  9561. mustUseProp,
  9562. canBeLeftOpenTag,
  9563. isReservedTag,
  9564. getTagNamespace,
  9565. staticKeys: genStaticKeys(modules$1)
  9566. };
  9567. /* */
  9568. let isStaticKey;
  9569. let isPlatformReservedTag;
  9570. const genStaticKeysCached = cached(genStaticKeys$1);
  9571. /**
  9572. * Goal of the optimizer: walk the generated template AST tree
  9573. * and detect sub-trees that are purely static, i.e. parts of
  9574. * the DOM that never needs to change.
  9575. *
  9576. * Once we detect these sub-trees, we can:
  9577. *
  9578. * 1. Hoist them into constants, so that we no longer need to
  9579. * create fresh nodes for them on each re-render;
  9580. * 2. Completely skip them in the patching process.
  9581. */
  9582. function optimize (root, options) {
  9583. if (!root) return
  9584. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  9585. isPlatformReservedTag = options.isReservedTag || no;
  9586. // first pass: mark all non-static nodes.
  9587. markStatic$1(root);
  9588. // second pass: mark static roots.
  9589. markStaticRoots(root, false);
  9590. }
  9591. function genStaticKeys$1 (keys) {
  9592. return makeMap(
  9593. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  9594. (keys ? ',' + keys : '')
  9595. )
  9596. }
  9597. function markStatic$1 (node) {
  9598. node.static = isStatic(node);
  9599. if (node.type === 1) {
  9600. // do not make component slot content static. this avoids
  9601. // 1. components not able to mutate slot nodes
  9602. // 2. static slot content fails for hot-reloading
  9603. if (
  9604. !isPlatformReservedTag(node.tag) &&
  9605. node.tag !== 'slot' &&
  9606. node.attrsMap['inline-template'] == null
  9607. ) {
  9608. return
  9609. }
  9610. for (let i = 0, l = node.children.length; i < l; i++) {
  9611. const child = node.children[i];
  9612. markStatic$1(child);
  9613. if (!child.static) {
  9614. node.static = false;
  9615. }
  9616. }
  9617. if (node.ifConditions) {
  9618. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  9619. const block = node.ifConditions[i].block;
  9620. markStatic$1(block);
  9621. if (!block.static) {
  9622. node.static = false;
  9623. }
  9624. }
  9625. }
  9626. }
  9627. }
  9628. function markStaticRoots (node, isInFor) {
  9629. if (node.type === 1) {
  9630. if (node.static || node.once) {
  9631. node.staticInFor = isInFor;
  9632. }
  9633. // For a node to qualify as a static root, it should have children that
  9634. // are not just static text. Otherwise the cost of hoisting out will
  9635. // outweigh the benefits and it's better off to just always render it fresh.
  9636. if (node.static && node.children.length && !(
  9637. node.children.length === 1 &&
  9638. node.children[0].type === 3
  9639. )) {
  9640. node.staticRoot = true;
  9641. return
  9642. } else {
  9643. node.staticRoot = false;
  9644. }
  9645. if (node.children) {
  9646. for (let i = 0, l = node.children.length; i < l; i++) {
  9647. markStaticRoots(node.children[i], isInFor || !!node.for);
  9648. }
  9649. }
  9650. if (node.ifConditions) {
  9651. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  9652. markStaticRoots(node.ifConditions[i].block, isInFor);
  9653. }
  9654. }
  9655. }
  9656. }
  9657. function isStatic (node) {
  9658. if (node.type === 2) { // expression
  9659. return false
  9660. }
  9661. if (node.type === 3) { // text
  9662. return true
  9663. }
  9664. return !!(node.pre || (
  9665. !node.hasBindings && // no dynamic bindings
  9666. !node.if && !node.for && // not v-if or v-for or v-else
  9667. !isBuiltInTag(node.tag) && // not a built-in
  9668. isPlatformReservedTag(node.tag) && // not a component
  9669. !isDirectChildOfTemplateFor(node) &&
  9670. Object.keys(node).every(isStaticKey)
  9671. ))
  9672. }
  9673. function isDirectChildOfTemplateFor (node) {
  9674. while (node.parent) {
  9675. node = node.parent;
  9676. if (node.tag !== 'template') {
  9677. return false
  9678. }
  9679. if (node.for) {
  9680. return true
  9681. }
  9682. }
  9683. return false
  9684. }
  9685. /* */
  9686. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  9687. const fnInvokeRE = /\([^)]*?\);*$/;
  9688. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  9689. // KeyboardEvent.keyCode aliases
  9690. const keyCodes = {
  9691. esc: 27,
  9692. tab: 9,
  9693. enter: 13,
  9694. space: 32,
  9695. up: 38,
  9696. left: 37,
  9697. right: 39,
  9698. down: 40,
  9699. 'delete': [8, 46]
  9700. };
  9701. // KeyboardEvent.key aliases
  9702. const keyNames = {
  9703. // #7880: IE11 and Edge use `Esc` for Escape key name.
  9704. esc: ['Esc', 'Escape'],
  9705. tab: 'Tab',
  9706. enter: 'Enter',
  9707. // #9112: IE11 uses `Spacebar` for Space key name.
  9708. space: [' ', 'Spacebar'],
  9709. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  9710. up: ['Up', 'ArrowUp'],
  9711. left: ['Left', 'ArrowLeft'],
  9712. right: ['Right', 'ArrowRight'],
  9713. down: ['Down', 'ArrowDown'],
  9714. // #9112: IE11 uses `Del` for Delete key name.
  9715. 'delete': ['Backspace', 'Delete', 'Del']
  9716. };
  9717. // #4868: modifiers that prevent the execution of the listener
  9718. // need to explicitly return null so that we can determine whether to remove
  9719. // the listener for .once
  9720. const genGuard = condition => `if(${condition})return null;`;
  9721. const modifierCode = {
  9722. stop: '$event.stopPropagation();',
  9723. prevent: '$event.preventDefault();',
  9724. self: genGuard(`$event.target !== $event.currentTarget`),
  9725. ctrl: genGuard(`!$event.ctrlKey`),
  9726. shift: genGuard(`!$event.shiftKey`),
  9727. alt: genGuard(`!$event.altKey`),
  9728. meta: genGuard(`!$event.metaKey`),
  9729. left: genGuard(`'button' in $event && $event.button !== 0`),
  9730. middle: genGuard(`'button' in $event && $event.button !== 1`),
  9731. right: genGuard(`'button' in $event && $event.button !== 2`)
  9732. };
  9733. function genHandlers (
  9734. events,
  9735. isNative
  9736. ) {
  9737. const prefix = isNative ? 'nativeOn:' : 'on:';
  9738. let staticHandlers = ``;
  9739. let dynamicHandlers = ``;
  9740. for (const name in events) {
  9741. const handlerCode = genHandler(events[name]);
  9742. if (events[name] && events[name].dynamic) {
  9743. dynamicHandlers += `${name},${handlerCode},`;
  9744. } else {
  9745. staticHandlers += `"${name}":${handlerCode},`;
  9746. }
  9747. }
  9748. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  9749. if (dynamicHandlers) {
  9750. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`
  9751. } else {
  9752. return prefix + staticHandlers
  9753. }
  9754. }
  9755. function genHandler (handler) {
  9756. if (!handler) {
  9757. return 'function(){}'
  9758. }
  9759. if (Array.isArray(handler)) {
  9760. return `[${handler.map(handler => genHandler(handler)).join(',')}]`
  9761. }
  9762. const isMethodPath = simplePathRE.test(handler.value);
  9763. const isFunctionExpression = fnExpRE.test(handler.value);
  9764. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  9765. if (!handler.modifiers) {
  9766. if (isMethodPath || isFunctionExpression) {
  9767. return handler.value
  9768. }
  9769. return `function($event){${
  9770. isFunctionInvocation ? `return ${handler.value}` : handler.value
  9771. }}` // inline statement
  9772. } else {
  9773. let code = '';
  9774. let genModifierCode = '';
  9775. const keys = [];
  9776. for (const key in handler.modifiers) {
  9777. if (modifierCode[key]) {
  9778. genModifierCode += modifierCode[key];
  9779. // left/right
  9780. if (keyCodes[key]) {
  9781. keys.push(key);
  9782. }
  9783. } else if (key === 'exact') {
  9784. const modifiers = (handler.modifiers);
  9785. genModifierCode += genGuard(
  9786. ['ctrl', 'shift', 'alt', 'meta']
  9787. .filter(keyModifier => !modifiers[keyModifier])
  9788. .map(keyModifier => `$event.${keyModifier}Key`)
  9789. .join('||')
  9790. );
  9791. } else {
  9792. keys.push(key);
  9793. }
  9794. }
  9795. if (keys.length) {
  9796. code += genKeyFilter(keys);
  9797. }
  9798. // Make sure modifiers like prevent and stop get executed after key filtering
  9799. if (genModifierCode) {
  9800. code += genModifierCode;
  9801. }
  9802. const handlerCode = isMethodPath
  9803. ? `return ${handler.value}($event)`
  9804. : isFunctionExpression
  9805. ? `return (${handler.value})($event)`
  9806. : isFunctionInvocation
  9807. ? `return ${handler.value}`
  9808. : handler.value;
  9809. return `function($event){${code}${handlerCode}}`
  9810. }
  9811. }
  9812. function genKeyFilter (keys) {
  9813. return (
  9814. // make sure the key filters only apply to KeyboardEvents
  9815. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  9816. // key events that do not have keyCode property...
  9817. `if(!$event.type.indexOf('key')&&` +
  9818. `${keys.map(genFilterCode).join('&&')})return null;`
  9819. )
  9820. }
  9821. function genFilterCode (key) {
  9822. const keyVal = parseInt(key, 10);
  9823. if (keyVal) {
  9824. return `$event.keyCode!==${keyVal}`
  9825. }
  9826. const keyCode = keyCodes[key];
  9827. const keyName = keyNames[key];
  9828. return (
  9829. `_k($event.keyCode,` +
  9830. `${JSON.stringify(key)},` +
  9831. `${JSON.stringify(keyCode)},` +
  9832. `$event.key,` +
  9833. `${JSON.stringify(keyName)}` +
  9834. `)`
  9835. )
  9836. }
  9837. /* */
  9838. function on (el, dir) {
  9839. if (dir.modifiers) {
  9840. warn(`v-on without argument does not support modifiers.`);
  9841. }
  9842. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  9843. }
  9844. /* */
  9845. function bind$1 (el, dir) {
  9846. el.wrapData = (code) => {
  9847. return `_b(${code},'${el.tag}',${dir.value},${
  9848. dir.modifiers && dir.modifiers.prop ? 'true' : 'false'
  9849. }${
  9850. dir.modifiers && dir.modifiers.sync ? ',true' : ''
  9851. })`
  9852. };
  9853. }
  9854. /* */
  9855. var baseDirectives = {
  9856. on,
  9857. bind: bind$1,
  9858. cloak: noop
  9859. };
  9860. /* */
  9861. class CodegenState {
  9862. constructor (options) {
  9863. this.options = options;
  9864. this.warn = options.warn || baseWarn;
  9865. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  9866. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  9867. this.directives = extend(extend({}, baseDirectives), options.directives);
  9868. const isReservedTag = options.isReservedTag || no;
  9869. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  9870. this.onceId = 0;
  9871. this.staticRenderFns = [];
  9872. this.pre = false;
  9873. }
  9874. }
  9875. function generate (
  9876. ast,
  9877. options
  9878. ) {
  9879. const state = new CodegenState(options);
  9880. const code = ast ? genElement(ast, state) : '_c("div")';
  9881. return {
  9882. render: `with(this){return ${code}}`,
  9883. staticRenderFns: state.staticRenderFns
  9884. }
  9885. }
  9886. function genElement (el, state) {
  9887. if (el.parent) {
  9888. el.pre = el.pre || el.parent.pre;
  9889. }
  9890. if (el.staticRoot && !el.staticProcessed) {
  9891. return genStatic(el, state)
  9892. } else if (el.once && !el.onceProcessed) {
  9893. return genOnce(el, state)
  9894. } else if (el.for && !el.forProcessed) {
  9895. return genFor(el, state)
  9896. } else if (el.if && !el.ifProcessed) {
  9897. return genIf(el, state)
  9898. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  9899. return genChildren(el, state) || 'void 0'
  9900. } else if (el.tag === 'slot') {
  9901. return genSlot(el, state)
  9902. } else {
  9903. // component or element
  9904. let code;
  9905. if (el.component) {
  9906. code = genComponent(el.component, el, state);
  9907. } else {
  9908. let data;
  9909. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  9910. data = genData$2(el, state);
  9911. }
  9912. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  9913. code = `_c('${el.tag}'${
  9914. data ? `,${data}` : '' // data
  9915. }${
  9916. children ? `,${children}` : '' // children
  9917. })`;
  9918. }
  9919. // module transforms
  9920. for (let i = 0; i < state.transforms.length; i++) {
  9921. code = state.transforms[i](el, code);
  9922. }
  9923. return code
  9924. }
  9925. }
  9926. // hoist static sub-trees out
  9927. function genStatic (el, state) {
  9928. el.staticProcessed = true;
  9929. // Some elements (templates) need to behave differently inside of a v-pre
  9930. // node. All pre nodes are static roots, so we can use this as a location to
  9931. // wrap a state change and reset it upon exiting the pre node.
  9932. const originalPreState = state.pre;
  9933. if (el.pre) {
  9934. state.pre = el.pre;
  9935. }
  9936. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  9937. state.pre = originalPreState;
  9938. return `_m(${
  9939. state.staticRenderFns.length - 1
  9940. }${
  9941. el.staticInFor ? ',true' : ''
  9942. })`
  9943. }
  9944. // v-once
  9945. function genOnce (el, state) {
  9946. el.onceProcessed = true;
  9947. if (el.if && !el.ifProcessed) {
  9948. return genIf(el, state)
  9949. } else if (el.staticInFor) {
  9950. let key = '';
  9951. let parent = el.parent;
  9952. while (parent) {
  9953. if (parent.for) {
  9954. key = parent.key;
  9955. break
  9956. }
  9957. parent = parent.parent;
  9958. }
  9959. if (!key) {
  9960. state.warn(
  9961. `v-once can only be used inside v-for that is keyed. `,
  9962. el.rawAttrsMap['v-once']
  9963. );
  9964. return genElement(el, state)
  9965. }
  9966. return `_o(${genElement(el, state)},${state.onceId++},${key})`
  9967. } else {
  9968. return genStatic(el, state)
  9969. }
  9970. }
  9971. function genIf (
  9972. el,
  9973. state,
  9974. altGen,
  9975. altEmpty
  9976. ) {
  9977. el.ifProcessed = true; // avoid recursion
  9978. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  9979. }
  9980. function genIfConditions (
  9981. conditions,
  9982. state,
  9983. altGen,
  9984. altEmpty
  9985. ) {
  9986. if (!conditions.length) {
  9987. return altEmpty || '_e()'
  9988. }
  9989. const condition = conditions.shift();
  9990. if (condition.exp) {
  9991. return `(${condition.exp})?${
  9992. genTernaryExp(condition.block)
  9993. }:${
  9994. genIfConditions(conditions, state, altGen, altEmpty)
  9995. }`
  9996. } else {
  9997. return `${genTernaryExp(condition.block)}`
  9998. }
  9999. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10000. function genTernaryExp (el) {
  10001. return altGen
  10002. ? altGen(el, state)
  10003. : el.once
  10004. ? genOnce(el, state)
  10005. : genElement(el, state)
  10006. }
  10007. }
  10008. function genFor (
  10009. el,
  10010. state,
  10011. altGen,
  10012. altHelper
  10013. ) {
  10014. const exp = el.for;
  10015. const alias = el.alias;
  10016. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10017. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10018. if (state.maybeComponent(el) &&
  10019. el.tag !== 'slot' &&
  10020. el.tag !== 'template' &&
  10021. !el.key
  10022. ) {
  10023. state.warn(
  10024. `<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10025. `v-for should have explicit keys. ` +
  10026. `See https://vuejs.org/guide/list.html#key for more info.`,
  10027. el.rawAttrsMap['v-for'],
  10028. true /* tip */
  10029. );
  10030. }
  10031. el.forProcessed = true; // avoid recursion
  10032. return `${altHelper || '_l'}((${exp}),` +
  10033. `function(${alias}${iterator1}${iterator2}){` +
  10034. `return ${(altGen || genElement)(el, state)}` +
  10035. '})'
  10036. }
  10037. function genData$2 (el, state) {
  10038. let data = '{';
  10039. // directives first.
  10040. // directives may mutate the el's other properties before they are generated.
  10041. const dirs = genDirectives(el, state);
  10042. if (dirs) data += dirs + ',';
  10043. // key
  10044. if (el.key) {
  10045. data += `key:${el.key},`;
  10046. }
  10047. // ref
  10048. if (el.ref) {
  10049. data += `ref:${el.ref},`;
  10050. }
  10051. if (el.refInFor) {
  10052. data += `refInFor:true,`;
  10053. }
  10054. // pre
  10055. if (el.pre) {
  10056. data += `pre:true,`;
  10057. }
  10058. // record original tag name for components using "is" attribute
  10059. if (el.component) {
  10060. data += `tag:"${el.tag}",`;
  10061. }
  10062. // module data generation functions
  10063. for (let i = 0; i < state.dataGenFns.length; i++) {
  10064. data += state.dataGenFns[i](el);
  10065. }
  10066. // attributes
  10067. if (el.attrs) {
  10068. data += `attrs:${genProps(el.attrs)},`;
  10069. }
  10070. // DOM props
  10071. if (el.props) {
  10072. data += `domProps:${genProps(el.props)},`;
  10073. }
  10074. // event handlers
  10075. if (el.events) {
  10076. data += `${genHandlers(el.events, false)},`;
  10077. }
  10078. if (el.nativeEvents) {
  10079. data += `${genHandlers(el.nativeEvents, true)},`;
  10080. }
  10081. // slot target
  10082. // only for non-scoped slots
  10083. if (el.slotTarget && !el.slotScope) {
  10084. data += `slot:${el.slotTarget},`;
  10085. }
  10086. // scoped slots
  10087. if (el.scopedSlots) {
  10088. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10089. }
  10090. // component v-model
  10091. if (el.model) {
  10092. data += `model:{value:${
  10093. el.model.value
  10094. },callback:${
  10095. el.model.callback
  10096. },expression:${
  10097. el.model.expression
  10098. }},`;
  10099. }
  10100. // inline-template
  10101. if (el.inlineTemplate) {
  10102. const inlineTemplate = genInlineTemplate(el, state);
  10103. if (inlineTemplate) {
  10104. data += `${inlineTemplate},`;
  10105. }
  10106. }
  10107. data = data.replace(/,$/, '') + '}';
  10108. // v-bind dynamic argument wrap
  10109. // v-bind with dynamic arguments must be applied using the same v-bind object
  10110. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10111. if (el.dynamicAttrs) {
  10112. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10113. }
  10114. // v-bind data wrap
  10115. if (el.wrapData) {
  10116. data = el.wrapData(data);
  10117. }
  10118. // v-on data wrap
  10119. if (el.wrapListeners) {
  10120. data = el.wrapListeners(data);
  10121. }
  10122. return data
  10123. }
  10124. function genDirectives (el, state) {
  10125. const dirs = el.directives;
  10126. if (!dirs) return
  10127. let res = 'directives:[';
  10128. let hasRuntime = false;
  10129. let i, l, dir, needRuntime;
  10130. for (i = 0, l = dirs.length; i < l; i++) {
  10131. dir = dirs[i];
  10132. needRuntime = true;
  10133. const gen = state.directives[dir.name];
  10134. if (gen) {
  10135. // compile-time directive that manipulates AST.
  10136. // returns true if it also needs a runtime counterpart.
  10137. needRuntime = !!gen(el, dir, state.warn);
  10138. }
  10139. if (needRuntime) {
  10140. hasRuntime = true;
  10141. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${
  10142. dir.value ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}` : ''
  10143. }${
  10144. dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''
  10145. }${
  10146. dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''
  10147. }},`;
  10148. }
  10149. }
  10150. if (hasRuntime) {
  10151. return res.slice(0, -1) + ']'
  10152. }
  10153. }
  10154. function genInlineTemplate (el, state) {
  10155. const ast = el.children[0];
  10156. if (el.children.length !== 1 || ast.type !== 1) {
  10157. state.warn(
  10158. 'Inline-template components must have exactly one child element.',
  10159. { start: el.start }
  10160. );
  10161. }
  10162. if (ast && ast.type === 1) {
  10163. const inlineRenderFns = generate(ast, state.options);
  10164. return `inlineTemplate:{render:function(){${
  10165. inlineRenderFns.render
  10166. }},staticRenderFns:[${
  10167. inlineRenderFns.staticRenderFns.map(code => `function(){${code}}`).join(',')
  10168. }]}`
  10169. }
  10170. }
  10171. function genScopedSlots (
  10172. el,
  10173. slots,
  10174. state
  10175. ) {
  10176. // by default scoped slots are considered "stable", this allows child
  10177. // components with only scoped slots to skip forced updates from parent.
  10178. // but in some cases we have to bail-out of this optimization
  10179. // for example if the slot contains dynamic names, has v-if or v-for on them...
  10180. let needsForceUpdate = el.for || Object.keys(slots).some(key => {
  10181. const slot = slots[key];
  10182. return (
  10183. slot.slotTargetDynamic ||
  10184. slot.if ||
  10185. slot.for ||
  10186. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  10187. )
  10188. });
  10189. // #9534: if a component with scoped slots is inside a conditional branch,
  10190. // it's possible for the same component to be reused but with different
  10191. // compiled slot content. To avoid that, we generate a unique key based on
  10192. // the generated code of all the slot contents.
  10193. let needsKey = !!el.if;
  10194. // OR when it is inside another scoped slot or v-for (the reactivity may be
  10195. // disconnected due to the intermediate scope variable)
  10196. // #9438, #9506
  10197. // TODO: this can be further optimized by properly analyzing in-scope bindings
  10198. // and skip force updating ones that do not actually use scope variables.
  10199. if (!needsForceUpdate) {
  10200. let parent = el.parent;
  10201. while (parent) {
  10202. if (
  10203. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  10204. parent.for
  10205. ) {
  10206. needsForceUpdate = true;
  10207. break
  10208. }
  10209. if (parent.if) {
  10210. needsKey = true;
  10211. }
  10212. parent = parent.parent;
  10213. }
  10214. }
  10215. const generatedSlots = Object.keys(slots)
  10216. .map(key => genScopedSlot(slots[key], state))
  10217. .join(',');
  10218. return `scopedSlots:_u([${generatedSlots}]${
  10219. needsForceUpdate ? `,null,true` : ``
  10220. }${
  10221. !needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``
  10222. })`
  10223. }
  10224. function hash(str) {
  10225. let hash = 5381;
  10226. let i = str.length;
  10227. while(i) {
  10228. hash = (hash * 33) ^ str.charCodeAt(--i);
  10229. }
  10230. return hash >>> 0
  10231. }
  10232. function containsSlotChild (el) {
  10233. if (el.type === 1) {
  10234. if (el.tag === 'slot') {
  10235. return true
  10236. }
  10237. return el.children.some(containsSlotChild)
  10238. }
  10239. return false
  10240. }
  10241. function genScopedSlot (
  10242. el,
  10243. state
  10244. ) {
  10245. const isLegacySyntax = el.attrsMap['slot-scope'];
  10246. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  10247. return genIf(el, state, genScopedSlot, `null`)
  10248. }
  10249. if (el.for && !el.forProcessed) {
  10250. return genFor(el, state, genScopedSlot)
  10251. }
  10252. const slotScope = el.slotScope === emptySlotScopeToken
  10253. ? ``
  10254. : String(el.slotScope);
  10255. const fn = `function(${slotScope}){` +
  10256. `return ${el.tag === 'template'
  10257. ? el.if && isLegacySyntax
  10258. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  10259. : genChildren(el, state) || 'undefined'
  10260. : genElement(el, state)
  10261. }}`;
  10262. // reverse proxy v-slot without scope on this.$slots
  10263. const reverseProxy = slotScope ? `` : `,proxy:true`;
  10264. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`
  10265. }
  10266. function genChildren (
  10267. el,
  10268. state,
  10269. checkSkip,
  10270. altGenElement,
  10271. altGenNode
  10272. ) {
  10273. const children = el.children;
  10274. if (children.length) {
  10275. const el = children[0];
  10276. // optimize single v-for
  10277. if (children.length === 1 &&
  10278. el.for &&
  10279. el.tag !== 'template' &&
  10280. el.tag !== 'slot'
  10281. ) {
  10282. const normalizationType = checkSkip
  10283. ? state.maybeComponent(el) ? `,1` : `,0`
  10284. : ``;
  10285. return `${(altGenElement || genElement)(el, state)}${normalizationType}`
  10286. }
  10287. const normalizationType = checkSkip
  10288. ? getNormalizationType(children, state.maybeComponent)
  10289. : 0;
  10290. const gen = altGenNode || genNode;
  10291. return `[${children.map(c => gen(c, state)).join(',')}]${
  10292. normalizationType ? `,${normalizationType}` : ''
  10293. }`
  10294. }
  10295. }
  10296. // determine the normalization needed for the children array.
  10297. // 0: no normalization needed
  10298. // 1: simple normalization needed (possible 1-level deep nested array)
  10299. // 2: full normalization needed
  10300. function getNormalizationType (
  10301. children,
  10302. maybeComponent
  10303. ) {
  10304. let res = 0;
  10305. for (let i = 0; i < children.length; i++) {
  10306. const el = children[i];
  10307. if (el.type !== 1) {
  10308. continue
  10309. }
  10310. if (needsNormalization(el) ||
  10311. (el.ifConditions && el.ifConditions.some(c => needsNormalization(c.block)))) {
  10312. res = 2;
  10313. break
  10314. }
  10315. if (maybeComponent(el) ||
  10316. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  10317. res = 1;
  10318. }
  10319. }
  10320. return res
  10321. }
  10322. function needsNormalization (el) {
  10323. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  10324. }
  10325. function genNode (node, state) {
  10326. if (node.type === 1) {
  10327. return genElement(node, state)
  10328. } else if (node.type === 3 && node.isComment) {
  10329. return genComment(node)
  10330. } else {
  10331. return genText(node)
  10332. }
  10333. }
  10334. function genText (text) {
  10335. return `_v(${text.type === 2
  10336. ? text.expression // no need for () because already wrapped in _s()
  10337. : transformSpecialNewlines(JSON.stringify(text.text))
  10338. })`
  10339. }
  10340. function genComment (comment) {
  10341. return `_e(${JSON.stringify(comment.text)})`
  10342. }
  10343. function genSlot (el, state) {
  10344. const slotName = el.slotName || '"default"';
  10345. const children = genChildren(el, state);
  10346. let res = `_t(${slotName}${children ? `,${children}` : ''}`;
  10347. const attrs = el.attrs || el.dynamicAttrs
  10348. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  10349. // slot props are camelized
  10350. name: camelize(attr.name),
  10351. value: attr.value,
  10352. dynamic: attr.dynamic
  10353. })))
  10354. : null;
  10355. const bind$$1 = el.attrsMap['v-bind'];
  10356. if ((attrs || bind$$1) && !children) {
  10357. res += `,null`;
  10358. }
  10359. if (attrs) {
  10360. res += `,${attrs}`;
  10361. }
  10362. if (bind$$1) {
  10363. res += `${attrs ? '' : ',null'},${bind$$1}`;
  10364. }
  10365. return res + ')'
  10366. }
  10367. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  10368. function genComponent (
  10369. componentName,
  10370. el,
  10371. state
  10372. ) {
  10373. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10374. return `_c(${componentName},${genData$2(el, state)}${
  10375. children ? `,${children}` : ''
  10376. })`
  10377. }
  10378. function genProps (props) {
  10379. let staticProps = ``;
  10380. let dynamicProps = ``;
  10381. for (let i = 0; i < props.length; i++) {
  10382. const prop = props[i];
  10383. const value = transformSpecialNewlines(prop.value);
  10384. if (prop.dynamic) {
  10385. dynamicProps += `${prop.name},${value},`;
  10386. } else {
  10387. staticProps += `"${prop.name}":${value},`;
  10388. }
  10389. }
  10390. staticProps = `{${staticProps.slice(0, -1)}}`;
  10391. if (dynamicProps) {
  10392. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`
  10393. } else {
  10394. return staticProps
  10395. }
  10396. }
  10397. // #3895, #4268
  10398. function transformSpecialNewlines (text) {
  10399. return text
  10400. .replace(/\u2028/g, '\\u2028')
  10401. .replace(/\u2029/g, '\\u2029')
  10402. }
  10403. /* */
  10404. // these keywords should not appear inside expressions, but operators like
  10405. // typeof, instanceof and in are allowed
  10406. const prohibitedKeywordRE = new RegExp('\\b' + (
  10407. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  10408. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  10409. 'extends,finally,continue,debugger,function,arguments'
  10410. ).split(',').join('\\b|\\b') + '\\b');
  10411. // these unary operators should not be used as property/method names
  10412. const unaryOperatorsRE = new RegExp('\\b' + (
  10413. 'delete,typeof,void'
  10414. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  10415. // strip strings in expressions
  10416. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  10417. // detect problematic expressions in a template
  10418. function detectErrors (ast, warn) {
  10419. if (ast) {
  10420. checkNode(ast, warn);
  10421. }
  10422. }
  10423. function checkNode (node, warn) {
  10424. if (node.type === 1) {
  10425. for (const name in node.attrsMap) {
  10426. if (dirRE.test(name)) {
  10427. const value = node.attrsMap[name];
  10428. if (value) {
  10429. const range = node.rawAttrsMap[name];
  10430. if (name === 'v-for') {
  10431. checkFor(node, `v-for="${value}"`, warn, range);
  10432. } else if (name === 'v-slot' || name[0] === '#') {
  10433. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  10434. } else if (onRE.test(name)) {
  10435. checkEvent(value, `${name}="${value}"`, warn, range);
  10436. } else {
  10437. checkExpression(value, `${name}="${value}"`, warn, range);
  10438. }
  10439. }
  10440. }
  10441. }
  10442. if (node.children) {
  10443. for (let i = 0; i < node.children.length; i++) {
  10444. checkNode(node.children[i], warn);
  10445. }
  10446. }
  10447. } else if (node.type === 2) {
  10448. checkExpression(node.expression, node.text, warn, node);
  10449. }
  10450. }
  10451. function checkEvent (exp, text, warn, range) {
  10452. const stripped = exp.replace(stripStringRE, '');
  10453. const keywordMatch = stripped.match(unaryOperatorsRE);
  10454. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  10455. warn(
  10456. `avoid using JavaScript unary operator as property name: ` +
  10457. `"${keywordMatch[0]}" in expression ${text.trim()}`,
  10458. range
  10459. );
  10460. }
  10461. checkExpression(exp, text, warn, range);
  10462. }
  10463. function checkFor (node, text, warn, range) {
  10464. checkExpression(node.for || '', text, warn, range);
  10465. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  10466. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  10467. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  10468. }
  10469. function checkIdentifier (
  10470. ident,
  10471. type,
  10472. text,
  10473. warn,
  10474. range
  10475. ) {
  10476. if (typeof ident === 'string') {
  10477. try {
  10478. new Function(`var ${ident}=_`);
  10479. } catch (e) {
  10480. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  10481. }
  10482. }
  10483. }
  10484. function checkExpression (exp, text, warn, range) {
  10485. try {
  10486. new Function(`return ${exp}`);
  10487. } catch (e) {
  10488. const keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  10489. if (keywordMatch) {
  10490. warn(
  10491. `avoid using JavaScript keyword as property name: ` +
  10492. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`,
  10493. range
  10494. );
  10495. } else {
  10496. warn(
  10497. `invalid expression: ${e.message} in\n\n` +
  10498. ` ${exp}\n\n` +
  10499. ` Raw expression: ${text.trim()}\n`,
  10500. range
  10501. );
  10502. }
  10503. }
  10504. }
  10505. function checkFunctionParameterExpression (exp, text, warn, range) {
  10506. try {
  10507. new Function(exp, '');
  10508. } catch (e) {
  10509. warn(
  10510. `invalid function parameter expression: ${e.message} in\n\n` +
  10511. ` ${exp}\n\n` +
  10512. ` Raw expression: ${text.trim()}\n`,
  10513. range
  10514. );
  10515. }
  10516. }
  10517. /* */
  10518. const range = 2;
  10519. function generateCodeFrame (
  10520. source,
  10521. start = 0,
  10522. end = source.length
  10523. ) {
  10524. const lines = source.split(/\r?\n/);
  10525. let count = 0;
  10526. const res = [];
  10527. for (let i = 0; i < lines.length; i++) {
  10528. count += lines[i].length + 1;
  10529. if (count >= start) {
  10530. for (let j = i - range; j <= i + range || end > count; j++) {
  10531. if (j < 0 || j >= lines.length) continue
  10532. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  10533. const lineLength = lines[j].length;
  10534. if (j === i) {
  10535. // push underline
  10536. const pad = start - (count - lineLength) + 1;
  10537. const length = end > count ? lineLength - pad : end - start;
  10538. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  10539. } else if (j > i) {
  10540. if (end > count) {
  10541. const length = Math.min(end - count, lineLength);
  10542. res.push(` | ` + repeat(`^`, length));
  10543. }
  10544. count += lineLength + 1;
  10545. }
  10546. }
  10547. break
  10548. }
  10549. }
  10550. return res.join('\n')
  10551. }
  10552. function repeat (str, n) {
  10553. let result = '';
  10554. if (n > 0) {
  10555. while (true) { // eslint-disable-line
  10556. if (n & 1) result += str;
  10557. n >>>= 1;
  10558. if (n <= 0) break
  10559. str += str;
  10560. }
  10561. }
  10562. return result
  10563. }
  10564. /* */
  10565. function createFunction (code, errors) {
  10566. try {
  10567. return new Function(code)
  10568. } catch (err) {
  10569. errors.push({ err, code });
  10570. return noop
  10571. }
  10572. }
  10573. function createCompileToFunctionFn (compile) {
  10574. const cache = Object.create(null);
  10575. return function compileToFunctions (
  10576. template,
  10577. options,
  10578. vm
  10579. ) {
  10580. options = extend({}, options);
  10581. const warn$$1 = options.warn || warn;
  10582. delete options.warn;
  10583. /* istanbul ignore if */
  10584. {
  10585. // detect possible CSP restriction
  10586. try {
  10587. new Function('return 1');
  10588. } catch (e) {
  10589. if (e.toString().match(/unsafe-eval|CSP/)) {
  10590. warn$$1(
  10591. 'It seems you are using the standalone build of Vue.js in an ' +
  10592. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  10593. 'The template compiler cannot work in this environment. Consider ' +
  10594. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  10595. 'templates into render functions.'
  10596. );
  10597. }
  10598. }
  10599. }
  10600. // check cache
  10601. const key = options.delimiters
  10602. ? String(options.delimiters) + template
  10603. : template;
  10604. if (cache[key]) {
  10605. return cache[key]
  10606. }
  10607. // compile
  10608. const compiled = compile(template, options);
  10609. // check compilation errors/tips
  10610. {
  10611. if (compiled.errors && compiled.errors.length) {
  10612. if (options.outputSourceRange) {
  10613. compiled.errors.forEach(e => {
  10614. warn$$1(
  10615. `Error compiling template:\n\n${e.msg}\n\n` +
  10616. generateCodeFrame(template, e.start, e.end),
  10617. vm
  10618. );
  10619. });
  10620. } else {
  10621. warn$$1(
  10622. `Error compiling template:\n\n${template}\n\n` +
  10623. compiled.errors.map(e => `- ${e}`).join('\n') + '\n',
  10624. vm
  10625. );
  10626. }
  10627. }
  10628. if (compiled.tips && compiled.tips.length) {
  10629. if (options.outputSourceRange) {
  10630. compiled.tips.forEach(e => tip(e.msg, vm));
  10631. } else {
  10632. compiled.tips.forEach(msg => tip(msg, vm));
  10633. }
  10634. }
  10635. }
  10636. // turn code into functions
  10637. const res = {};
  10638. const fnGenErrors = [];
  10639. res.render = createFunction(compiled.render, fnGenErrors);
  10640. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  10641. return createFunction(code, fnGenErrors)
  10642. });
  10643. // check function generation errors.
  10644. // this should only happen if there is a bug in the compiler itself.
  10645. // mostly for codegen development use
  10646. /* istanbul ignore if */
  10647. {
  10648. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  10649. warn$$1(
  10650. `Failed to generate render function:\n\n` +
  10651. fnGenErrors.map(({ err, code }) => `${err.toString()} in\n\n${code}\n`).join('\n'),
  10652. vm
  10653. );
  10654. }
  10655. }
  10656. return (cache[key] = res)
  10657. }
  10658. }
  10659. /* */
  10660. function createCompilerCreator (baseCompile) {
  10661. return function createCompiler (baseOptions) {
  10662. function compile (
  10663. template,
  10664. options
  10665. ) {
  10666. const finalOptions = Object.create(baseOptions);
  10667. const errors = [];
  10668. const tips = [];
  10669. let warn = (msg, range, tip) => {
  10670. (tip ? tips : errors).push(msg);
  10671. };
  10672. if (options) {
  10673. if (options.outputSourceRange) {
  10674. // $flow-disable-line
  10675. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  10676. warn = (msg, range, tip) => {
  10677. const data = { msg };
  10678. if (range) {
  10679. if (range.start != null) {
  10680. data.start = range.start + leadingSpaceLength;
  10681. }
  10682. if (range.end != null) {
  10683. data.end = range.end + leadingSpaceLength;
  10684. }
  10685. }
  10686. (tip ? tips : errors).push(data);
  10687. };
  10688. }
  10689. // merge custom modules
  10690. if (options.modules) {
  10691. finalOptions.modules =
  10692. (baseOptions.modules || []).concat(options.modules);
  10693. }
  10694. // merge custom directives
  10695. if (options.directives) {
  10696. finalOptions.directives = extend(
  10697. Object.create(baseOptions.directives || null),
  10698. options.directives
  10699. );
  10700. }
  10701. // copy other options
  10702. for (const key in options) {
  10703. if (key !== 'modules' && key !== 'directives') {
  10704. finalOptions[key] = options[key];
  10705. }
  10706. }
  10707. }
  10708. finalOptions.warn = warn;
  10709. const compiled = baseCompile(template.trim(), finalOptions);
  10710. {
  10711. detectErrors(compiled.ast, warn);
  10712. }
  10713. compiled.errors = errors;
  10714. compiled.tips = tips;
  10715. return compiled
  10716. }
  10717. return {
  10718. compile,
  10719. compileToFunctions: createCompileToFunctionFn(compile)
  10720. }
  10721. }
  10722. }
  10723. /* */
  10724. // `createCompilerCreator` allows creating compilers that use alternative
  10725. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  10726. // Here we just export a default compiler using the default parts.
  10727. const createCompiler = createCompilerCreator(function baseCompile (
  10728. template,
  10729. options
  10730. ) {
  10731. const ast = parse(template.trim(), options);
  10732. if (options.optimize !== false) {
  10733. optimize(ast, options);
  10734. }
  10735. const code = generate(ast, options);
  10736. return {
  10737. ast,
  10738. render: code.render,
  10739. staticRenderFns: code.staticRenderFns
  10740. }
  10741. });
  10742. /* */
  10743. const { compile, compileToFunctions } = createCompiler(baseOptions);
  10744. /* */
  10745. // check whether current browser encodes a char inside attribute values
  10746. let div;
  10747. function getShouldDecode (href) {
  10748. div = div || document.createElement('div');
  10749. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  10750. return div.innerHTML.indexOf('&#10;') > 0
  10751. }
  10752. // #3663: IE encodes newlines inside attribute values while other browsers don't
  10753. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  10754. // #6828: chrome encodes content in a[href]
  10755. const shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  10756. /* */
  10757. const idToTemplate = cached(id => {
  10758. const el = query(id);
  10759. return el && el.innerHTML
  10760. });
  10761. const mount = Vue.prototype.$mount;
  10762. Vue.prototype.$mount = function (
  10763. el,
  10764. hydrating
  10765. ) {
  10766. el = el && query(el);
  10767. /* istanbul ignore if */
  10768. if (el === document.body || el === document.documentElement) {
  10769. warn(
  10770. `Do not mount Vue to <html> or <body> - mount to normal elements instead.`
  10771. );
  10772. return this
  10773. }
  10774. const options = this.$options;
  10775. // resolve template/el and convert to render function
  10776. if (!options.render) {
  10777. let template = options.template;
  10778. if (template) {
  10779. if (typeof template === 'string') {
  10780. if (template.charAt(0) === '#') {
  10781. template = idToTemplate(template);
  10782. /* istanbul ignore if */
  10783. if (!template) {
  10784. warn(
  10785. `Template element not found or is empty: ${options.template}`,
  10786. this
  10787. );
  10788. }
  10789. }
  10790. } else if (template.nodeType) {
  10791. template = template.innerHTML;
  10792. } else {
  10793. {
  10794. warn('invalid template option:' + template, this);
  10795. }
  10796. return this
  10797. }
  10798. } else if (el) {
  10799. template = getOuterHTML(el);
  10800. }
  10801. if (template) {
  10802. /* istanbul ignore if */
  10803. if (config.performance && mark) {
  10804. mark('compile');
  10805. }
  10806. const { render, staticRenderFns } = compileToFunctions(template, {
  10807. outputSourceRange: "development" !== 'production',
  10808. shouldDecodeNewlines,
  10809. shouldDecodeNewlinesForHref,
  10810. delimiters: options.delimiters,
  10811. comments: options.comments
  10812. }, this);
  10813. options.render = render;
  10814. options.staticRenderFns = staticRenderFns;
  10815. /* istanbul ignore if */
  10816. if (config.performance && mark) {
  10817. mark('compile end');
  10818. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  10819. }
  10820. }
  10821. }
  10822. return mount.call(this, el, hydrating)
  10823. };
  10824. /**
  10825. * Get outerHTML of elements, taking care
  10826. * of SVG elements in IE as well.
  10827. */
  10828. function getOuterHTML (el) {
  10829. if (el.outerHTML) {
  10830. return el.outerHTML
  10831. } else {
  10832. const container = document.createElement('div');
  10833. container.appendChild(el.cloneNode(true));
  10834. return container.innerHTML
  10835. }
  10836. }
  10837. Vue.compile = compileToFunctions;
  10838. export default Vue;