Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vue.esm.browser.js 307KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995
  1. /*!
  2. * Vue.js v2.6.10
  3. * (c) 2014-2019 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. // Techinically 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 speical 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. vnode = new VNode(
  3108. config.parsePlatformTagName(tag), data, children,
  3109. undefined, undefined, context
  3110. );
  3111. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  3112. // component
  3113. vnode = createComponent(Ctor, data, context, children, tag);
  3114. } else {
  3115. // unknown or unlisted namespaced elements
  3116. // check at runtime because it may get assigned a namespace when its
  3117. // parent normalizes children
  3118. vnode = new VNode(
  3119. tag, data, children,
  3120. undefined, undefined, context
  3121. );
  3122. }
  3123. } else {
  3124. // direct component options / constructor
  3125. vnode = createComponent(tag, data, context, children);
  3126. }
  3127. if (Array.isArray(vnode)) {
  3128. return vnode
  3129. } else if (isDef(vnode)) {
  3130. if (isDef(ns)) applyNS(vnode, ns);
  3131. if (isDef(data)) registerDeepBindings(data);
  3132. return vnode
  3133. } else {
  3134. return createEmptyVNode()
  3135. }
  3136. }
  3137. function applyNS (vnode, ns, force) {
  3138. vnode.ns = ns;
  3139. if (vnode.tag === 'foreignObject') {
  3140. // use default namespace inside foreignObject
  3141. ns = undefined;
  3142. force = true;
  3143. }
  3144. if (isDef(vnode.children)) {
  3145. for (let i = 0, l = vnode.children.length; i < l; i++) {
  3146. const child = vnode.children[i];
  3147. if (isDef(child.tag) && (
  3148. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  3149. applyNS(child, ns, force);
  3150. }
  3151. }
  3152. }
  3153. }
  3154. // ref #5318
  3155. // necessary to ensure parent re-render when deep bindings like :style and
  3156. // :class are used on slot nodes
  3157. function registerDeepBindings (data) {
  3158. if (isObject(data.style)) {
  3159. traverse(data.style);
  3160. }
  3161. if (isObject(data.class)) {
  3162. traverse(data.class);
  3163. }
  3164. }
  3165. /* */
  3166. function initRender (vm) {
  3167. vm._vnode = null; // the root of the child tree
  3168. vm._staticTrees = null; // v-once cached trees
  3169. const options = vm.$options;
  3170. const parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  3171. const renderContext = parentVnode && parentVnode.context;
  3172. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  3173. vm.$scopedSlots = emptyObject;
  3174. // bind the createElement fn to this instance
  3175. // so that we get proper render context inside it.
  3176. // args order: tag, data, children, normalizationType, alwaysNormalize
  3177. // internal version is used by render functions compiled from templates
  3178. vm._c = (a, b, c, d) => createElement(vm, a, b, c, d, false);
  3179. // normalization is always applied for the public version, used in
  3180. // user-written render functions.
  3181. vm.$createElement = (a, b, c, d) => createElement(vm, a, b, c, d, true);
  3182. // $attrs & $listeners are exposed for easier HOC creation.
  3183. // they need to be reactive so that HOCs using them are always updated
  3184. const parentData = parentVnode && parentVnode.data;
  3185. /* istanbul ignore else */
  3186. {
  3187. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, () => {
  3188. !isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
  3189. }, true);
  3190. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, () => {
  3191. !isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
  3192. }, true);
  3193. }
  3194. }
  3195. let currentRenderingInstance = null;
  3196. function renderMixin (Vue) {
  3197. // install runtime convenience helpers
  3198. installRenderHelpers(Vue.prototype);
  3199. Vue.prototype.$nextTick = function (fn) {
  3200. return nextTick(fn, this)
  3201. };
  3202. Vue.prototype._render = function () {
  3203. const vm = this;
  3204. const { render, _parentVnode } = vm.$options;
  3205. if (_parentVnode) {
  3206. vm.$scopedSlots = normalizeScopedSlots(
  3207. _parentVnode.data.scopedSlots,
  3208. vm.$slots,
  3209. vm.$scopedSlots
  3210. );
  3211. }
  3212. // set parent vnode. this allows render functions to have access
  3213. // to the data on the placeholder node.
  3214. vm.$vnode = _parentVnode;
  3215. // render self
  3216. let vnode;
  3217. try {
  3218. // There's no need to maintain a stack becaues all render fns are called
  3219. // separately from one another. Nested component's render fns are called
  3220. // when parent component is patched.
  3221. currentRenderingInstance = vm;
  3222. vnode = render.call(vm._renderProxy, vm.$createElement);
  3223. } catch (e) {
  3224. handleError(e, vm, `render`);
  3225. // return error render result,
  3226. // or previous vnode to prevent render error causing blank component
  3227. /* istanbul ignore else */
  3228. if (vm.$options.renderError) {
  3229. try {
  3230. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  3231. } catch (e) {
  3232. handleError(e, vm, `renderError`);
  3233. vnode = vm._vnode;
  3234. }
  3235. } else {
  3236. vnode = vm._vnode;
  3237. }
  3238. } finally {
  3239. currentRenderingInstance = null;
  3240. }
  3241. // if the returned array contains only a single node, allow it
  3242. if (Array.isArray(vnode) && vnode.length === 1) {
  3243. vnode = vnode[0];
  3244. }
  3245. // return empty vnode in case the render function errored out
  3246. if (!(vnode instanceof VNode)) {
  3247. if (Array.isArray(vnode)) {
  3248. warn(
  3249. 'Multiple root nodes returned from render function. Render function ' +
  3250. 'should return a single root node.',
  3251. vm
  3252. );
  3253. }
  3254. vnode = createEmptyVNode();
  3255. }
  3256. // set parent
  3257. vnode.parent = _parentVnode;
  3258. return vnode
  3259. };
  3260. }
  3261. /* */
  3262. function ensureCtor (comp, base) {
  3263. if (
  3264. comp.__esModule ||
  3265. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  3266. ) {
  3267. comp = comp.default;
  3268. }
  3269. return isObject(comp)
  3270. ? base.extend(comp)
  3271. : comp
  3272. }
  3273. function createAsyncPlaceholder (
  3274. factory,
  3275. data,
  3276. context,
  3277. children,
  3278. tag
  3279. ) {
  3280. const node = createEmptyVNode();
  3281. node.asyncFactory = factory;
  3282. node.asyncMeta = { data, context, children, tag };
  3283. return node
  3284. }
  3285. function resolveAsyncComponent (
  3286. factory,
  3287. baseCtor
  3288. ) {
  3289. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  3290. return factory.errorComp
  3291. }
  3292. if (isDef(factory.resolved)) {
  3293. return factory.resolved
  3294. }
  3295. const owner = currentRenderingInstance;
  3296. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  3297. // already pending
  3298. factory.owners.push(owner);
  3299. }
  3300. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  3301. return factory.loadingComp
  3302. }
  3303. if (owner && !isDef(factory.owners)) {
  3304. const owners = factory.owners = [owner];
  3305. let sync = true;
  3306. let timerLoading = null;
  3307. let timerTimeout = null
  3308. ;(owner).$on('hook:destroyed', () => remove(owners, owner));
  3309. const forceRender = (renderCompleted) => {
  3310. for (let i = 0, l = owners.length; i < l; i++) {
  3311. (owners[i]).$forceUpdate();
  3312. }
  3313. if (renderCompleted) {
  3314. owners.length = 0;
  3315. if (timerLoading !== null) {
  3316. clearTimeout(timerLoading);
  3317. timerLoading = null;
  3318. }
  3319. if (timerTimeout !== null) {
  3320. clearTimeout(timerTimeout);
  3321. timerTimeout = null;
  3322. }
  3323. }
  3324. };
  3325. const resolve = once((res) => {
  3326. // cache resolved
  3327. factory.resolved = ensureCtor(res, baseCtor);
  3328. // invoke callbacks only if this is not a synchronous resolve
  3329. // (async resolves are shimmed as synchronous during SSR)
  3330. if (!sync) {
  3331. forceRender(true);
  3332. } else {
  3333. owners.length = 0;
  3334. }
  3335. });
  3336. const reject = once(reason => {
  3337. warn(
  3338. `Failed to resolve async component: ${String(factory)}` +
  3339. (reason ? `\nReason: ${reason}` : '')
  3340. );
  3341. if (isDef(factory.errorComp)) {
  3342. factory.error = true;
  3343. forceRender(true);
  3344. }
  3345. });
  3346. const res = factory(resolve, reject);
  3347. if (isObject(res)) {
  3348. if (isPromise(res)) {
  3349. // () => Promise
  3350. if (isUndef(factory.resolved)) {
  3351. res.then(resolve, reject);
  3352. }
  3353. } else if (isPromise(res.component)) {
  3354. res.component.then(resolve, reject);
  3355. if (isDef(res.error)) {
  3356. factory.errorComp = ensureCtor(res.error, baseCtor);
  3357. }
  3358. if (isDef(res.loading)) {
  3359. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  3360. if (res.delay === 0) {
  3361. factory.loading = true;
  3362. } else {
  3363. timerLoading = setTimeout(() => {
  3364. timerLoading = null;
  3365. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  3366. factory.loading = true;
  3367. forceRender(false);
  3368. }
  3369. }, res.delay || 200);
  3370. }
  3371. }
  3372. if (isDef(res.timeout)) {
  3373. timerTimeout = setTimeout(() => {
  3374. timerTimeout = null;
  3375. if (isUndef(factory.resolved)) {
  3376. reject(
  3377. `timeout (${res.timeout}ms)`
  3378. );
  3379. }
  3380. }, res.timeout);
  3381. }
  3382. }
  3383. }
  3384. sync = false;
  3385. // return in case resolved synchronously
  3386. return factory.loading
  3387. ? factory.loadingComp
  3388. : factory.resolved
  3389. }
  3390. }
  3391. /* */
  3392. function isAsyncPlaceholder (node) {
  3393. return node.isComment && node.asyncFactory
  3394. }
  3395. /* */
  3396. function getFirstComponentChild (children) {
  3397. if (Array.isArray(children)) {
  3398. for (let i = 0; i < children.length; i++) {
  3399. const c = children[i];
  3400. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  3401. return c
  3402. }
  3403. }
  3404. }
  3405. }
  3406. /* */
  3407. /* */
  3408. function initEvents (vm) {
  3409. vm._events = Object.create(null);
  3410. vm._hasHookEvent = false;
  3411. // init parent attached events
  3412. const listeners = vm.$options._parentListeners;
  3413. if (listeners) {
  3414. updateComponentListeners(vm, listeners);
  3415. }
  3416. }
  3417. let target;
  3418. function add (event, fn) {
  3419. target.$on(event, fn);
  3420. }
  3421. function remove$1 (event, fn) {
  3422. target.$off(event, fn);
  3423. }
  3424. function createOnceHandler (event, fn) {
  3425. const _target = target;
  3426. return function onceHandler () {
  3427. const res = fn.apply(null, arguments);
  3428. if (res !== null) {
  3429. _target.$off(event, onceHandler);
  3430. }
  3431. }
  3432. }
  3433. function updateComponentListeners (
  3434. vm,
  3435. listeners,
  3436. oldListeners
  3437. ) {
  3438. target = vm;
  3439. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  3440. target = undefined;
  3441. }
  3442. function eventsMixin (Vue) {
  3443. const hookRE = /^hook:/;
  3444. Vue.prototype.$on = function (event, fn) {
  3445. const vm = this;
  3446. if (Array.isArray(event)) {
  3447. for (let i = 0, l = event.length; i < l; i++) {
  3448. vm.$on(event[i], fn);
  3449. }
  3450. } else {
  3451. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3452. // optimize hook:event cost by using a boolean flag marked at registration
  3453. // instead of a hash lookup
  3454. if (hookRE.test(event)) {
  3455. vm._hasHookEvent = true;
  3456. }
  3457. }
  3458. return vm
  3459. };
  3460. Vue.prototype.$once = function (event, fn) {
  3461. const vm = this;
  3462. function on () {
  3463. vm.$off(event, on);
  3464. fn.apply(vm, arguments);
  3465. }
  3466. on.fn = fn;
  3467. vm.$on(event, on);
  3468. return vm
  3469. };
  3470. Vue.prototype.$off = function (event, fn) {
  3471. const vm = this;
  3472. // all
  3473. if (!arguments.length) {
  3474. vm._events = Object.create(null);
  3475. return vm
  3476. }
  3477. // array of events
  3478. if (Array.isArray(event)) {
  3479. for (let i = 0, l = event.length; i < l; i++) {
  3480. vm.$off(event[i], fn);
  3481. }
  3482. return vm
  3483. }
  3484. // specific event
  3485. const cbs = vm._events[event];
  3486. if (!cbs) {
  3487. return vm
  3488. }
  3489. if (!fn) {
  3490. vm._events[event] = null;
  3491. return vm
  3492. }
  3493. // specific handler
  3494. let cb;
  3495. let i = cbs.length;
  3496. while (i--) {
  3497. cb = cbs[i];
  3498. if (cb === fn || cb.fn === fn) {
  3499. cbs.splice(i, 1);
  3500. break
  3501. }
  3502. }
  3503. return vm
  3504. };
  3505. Vue.prototype.$emit = function (event) {
  3506. const vm = this;
  3507. {
  3508. const lowerCaseEvent = event.toLowerCase();
  3509. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3510. tip(
  3511. `Event "${lowerCaseEvent}" is emitted in component ` +
  3512. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  3513. `Note that HTML attributes are case-insensitive and you cannot use ` +
  3514. `v-on to listen to camelCase events when using in-DOM templates. ` +
  3515. `You should probably use "${hyphenate(event)}" instead of "${event}".`
  3516. );
  3517. }
  3518. }
  3519. let cbs = vm._events[event];
  3520. if (cbs) {
  3521. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3522. const args = toArray(arguments, 1);
  3523. const info = `event handler for "${event}"`;
  3524. for (let i = 0, l = cbs.length; i < l; i++) {
  3525. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3526. }
  3527. }
  3528. return vm
  3529. };
  3530. }
  3531. /* */
  3532. let activeInstance = null;
  3533. let isUpdatingChildComponent = false;
  3534. function setActiveInstance(vm) {
  3535. const prevActiveInstance = activeInstance;
  3536. activeInstance = vm;
  3537. return () => {
  3538. activeInstance = prevActiveInstance;
  3539. }
  3540. }
  3541. function initLifecycle (vm) {
  3542. const options = vm.$options;
  3543. // locate first non-abstract parent
  3544. let parent = options.parent;
  3545. if (parent && !options.abstract) {
  3546. while (parent.$options.abstract && parent.$parent) {
  3547. parent = parent.$parent;
  3548. }
  3549. parent.$children.push(vm);
  3550. }
  3551. vm.$parent = parent;
  3552. vm.$root = parent ? parent.$root : vm;
  3553. vm.$children = [];
  3554. vm.$refs = {};
  3555. vm._watcher = null;
  3556. vm._inactive = null;
  3557. vm._directInactive = false;
  3558. vm._isMounted = false;
  3559. vm._isDestroyed = false;
  3560. vm._isBeingDestroyed = false;
  3561. }
  3562. function lifecycleMixin (Vue) {
  3563. Vue.prototype._update = function (vnode, hydrating) {
  3564. const vm = this;
  3565. const prevEl = vm.$el;
  3566. const prevVnode = vm._vnode;
  3567. const restoreActiveInstance = setActiveInstance(vm);
  3568. vm._vnode = vnode;
  3569. // Vue.prototype.__patch__ is injected in entry points
  3570. // based on the rendering backend used.
  3571. if (!prevVnode) {
  3572. // initial render
  3573. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3574. } else {
  3575. // updates
  3576. vm.$el = vm.__patch__(prevVnode, vnode);
  3577. }
  3578. restoreActiveInstance();
  3579. // update __vue__ reference
  3580. if (prevEl) {
  3581. prevEl.__vue__ = null;
  3582. }
  3583. if (vm.$el) {
  3584. vm.$el.__vue__ = vm;
  3585. }
  3586. // if parent is an HOC, update its $el as well
  3587. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  3588. vm.$parent.$el = vm.$el;
  3589. }
  3590. // updated hook is called by the scheduler to ensure that children are
  3591. // updated in a parent's updated hook.
  3592. };
  3593. Vue.prototype.$forceUpdate = function () {
  3594. const vm = this;
  3595. if (vm._watcher) {
  3596. vm._watcher.update();
  3597. }
  3598. };
  3599. Vue.prototype.$destroy = function () {
  3600. const vm = this;
  3601. if (vm._isBeingDestroyed) {
  3602. return
  3603. }
  3604. callHook(vm, 'beforeDestroy');
  3605. vm._isBeingDestroyed = true;
  3606. // remove self from parent
  3607. const parent = vm.$parent;
  3608. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3609. remove(parent.$children, vm);
  3610. }
  3611. // teardown watchers
  3612. if (vm._watcher) {
  3613. vm._watcher.teardown();
  3614. }
  3615. let i = vm._watchers.length;
  3616. while (i--) {
  3617. vm._watchers[i].teardown();
  3618. }
  3619. // remove reference from data ob
  3620. // frozen object may not have observer.
  3621. if (vm._data.__ob__) {
  3622. vm._data.__ob__.vmCount--;
  3623. }
  3624. // call the last hook...
  3625. vm._isDestroyed = true;
  3626. // invoke destroy hooks on current rendered tree
  3627. vm.__patch__(vm._vnode, null);
  3628. // fire destroyed hook
  3629. callHook(vm, 'destroyed');
  3630. // turn off all instance listeners.
  3631. vm.$off();
  3632. // remove __vue__ reference
  3633. if (vm.$el) {
  3634. vm.$el.__vue__ = null;
  3635. }
  3636. // release circular reference (#6759)
  3637. if (vm.$vnode) {
  3638. vm.$vnode.parent = null;
  3639. }
  3640. };
  3641. }
  3642. function mountComponent (
  3643. vm,
  3644. el,
  3645. hydrating
  3646. ) {
  3647. vm.$el = el;
  3648. if (!vm.$options.render) {
  3649. vm.$options.render = createEmptyVNode;
  3650. {
  3651. /* istanbul ignore if */
  3652. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3653. vm.$options.el || el) {
  3654. warn(
  3655. 'You are using the runtime-only build of Vue where the template ' +
  3656. 'compiler is not available. Either pre-compile the templates into ' +
  3657. 'render functions, or use the compiler-included build.',
  3658. vm
  3659. );
  3660. } else {
  3661. warn(
  3662. 'Failed to mount component: template or render function not defined.',
  3663. vm
  3664. );
  3665. }
  3666. }
  3667. }
  3668. callHook(vm, 'beforeMount');
  3669. let updateComponent;
  3670. /* istanbul ignore if */
  3671. if (config.performance && mark) {
  3672. updateComponent = () => {
  3673. const name = vm._name;
  3674. const id = vm._uid;
  3675. const startTag = `vue-perf-start:${id}`;
  3676. const endTag = `vue-perf-end:${id}`;
  3677. mark(startTag);
  3678. const vnode = vm._render();
  3679. mark(endTag);
  3680. measure(`vue ${name} render`, startTag, endTag);
  3681. mark(startTag);
  3682. vm._update(vnode, hydrating);
  3683. mark(endTag);
  3684. measure(`vue ${name} patch`, startTag, endTag);
  3685. };
  3686. } else {
  3687. updateComponent = () => {
  3688. vm._update(vm._render(), hydrating);
  3689. };
  3690. }
  3691. // we set this to vm._watcher inside the watcher's constructor
  3692. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3693. // component's mounted hook), which relies on vm._watcher being already defined
  3694. new Watcher(vm, updateComponent, noop, {
  3695. before () {
  3696. if (vm._isMounted && !vm._isDestroyed) {
  3697. callHook(vm, 'beforeUpdate');
  3698. }
  3699. }
  3700. }, true /* isRenderWatcher */);
  3701. hydrating = false;
  3702. // manually mounted instance, call mounted on self
  3703. // mounted is called for render-created child components in its inserted hook
  3704. if (vm.$vnode == null) {
  3705. vm._isMounted = true;
  3706. callHook(vm, 'mounted');
  3707. }
  3708. return vm
  3709. }
  3710. function updateChildComponent (
  3711. vm,
  3712. propsData,
  3713. listeners,
  3714. parentVnode,
  3715. renderChildren
  3716. ) {
  3717. {
  3718. isUpdatingChildComponent = true;
  3719. }
  3720. // determine whether component has slot children
  3721. // we need to do this before overwriting $options._renderChildren.
  3722. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3723. // dynamic slot names). Static scoped slots compiled from template has the
  3724. // "$stable" marker.
  3725. const newScopedSlots = parentVnode.data.scopedSlots;
  3726. const oldScopedSlots = vm.$scopedSlots;
  3727. const hasDynamicScopedSlot = !!(
  3728. (newScopedSlots && !newScopedSlots.$stable) ||
  3729. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3730. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  3731. );
  3732. // Any static slot children from the parent may have changed during parent's
  3733. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3734. // update is necessary to ensure correctness.
  3735. const needsForceUpdate = !!(
  3736. renderChildren || // has new static slots
  3737. vm.$options._renderChildren || // has old static slots
  3738. hasDynamicScopedSlot
  3739. );
  3740. vm.$options._parentVnode = parentVnode;
  3741. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3742. if (vm._vnode) { // update child tree's parent
  3743. vm._vnode.parent = parentVnode;
  3744. }
  3745. vm.$options._renderChildren = renderChildren;
  3746. // update $attrs and $listeners hash
  3747. // these are also reactive so they may trigger child update if the child
  3748. // used them during render
  3749. vm.$attrs = parentVnode.data.attrs || emptyObject;
  3750. vm.$listeners = listeners || emptyObject;
  3751. // update props
  3752. if (propsData && vm.$options.props) {
  3753. toggleObserving(false);
  3754. const props = vm._props;
  3755. const propKeys = vm.$options._propKeys || [];
  3756. for (let i = 0; i < propKeys.length; i++) {
  3757. const key = propKeys[i];
  3758. const propOptions = vm.$options.props; // wtf flow?
  3759. props[key] = validateProp(key, propOptions, propsData, vm);
  3760. }
  3761. toggleObserving(true);
  3762. // keep a copy of raw propsData
  3763. vm.$options.propsData = propsData;
  3764. }
  3765. // update listeners
  3766. listeners = listeners || emptyObject;
  3767. const oldListeners = vm.$options._parentListeners;
  3768. vm.$options._parentListeners = listeners;
  3769. updateComponentListeners(vm, listeners, oldListeners);
  3770. // resolve slots + force update if has children
  3771. if (needsForceUpdate) {
  3772. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3773. vm.$forceUpdate();
  3774. }
  3775. {
  3776. isUpdatingChildComponent = false;
  3777. }
  3778. }
  3779. function isInInactiveTree (vm) {
  3780. while (vm && (vm = vm.$parent)) {
  3781. if (vm._inactive) return true
  3782. }
  3783. return false
  3784. }
  3785. function activateChildComponent (vm, direct) {
  3786. if (direct) {
  3787. vm._directInactive = false;
  3788. if (isInInactiveTree(vm)) {
  3789. return
  3790. }
  3791. } else if (vm._directInactive) {
  3792. return
  3793. }
  3794. if (vm._inactive || vm._inactive === null) {
  3795. vm._inactive = false;
  3796. for (let i = 0; i < vm.$children.length; i++) {
  3797. activateChildComponent(vm.$children[i]);
  3798. }
  3799. callHook(vm, 'activated');
  3800. }
  3801. }
  3802. function deactivateChildComponent (vm, direct) {
  3803. if (direct) {
  3804. vm._directInactive = true;
  3805. if (isInInactiveTree(vm)) {
  3806. return
  3807. }
  3808. }
  3809. if (!vm._inactive) {
  3810. vm._inactive = true;
  3811. for (let i = 0; i < vm.$children.length; i++) {
  3812. deactivateChildComponent(vm.$children[i]);
  3813. }
  3814. callHook(vm, 'deactivated');
  3815. }
  3816. }
  3817. function callHook (vm, hook) {
  3818. // #7573 disable dep collection when invoking lifecycle hooks
  3819. pushTarget();
  3820. const handlers = vm.$options[hook];
  3821. const info = `${hook} hook`;
  3822. if (handlers) {
  3823. for (let i = 0, j = handlers.length; i < j; i++) {
  3824. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  3825. }
  3826. }
  3827. if (vm._hasHookEvent) {
  3828. vm.$emit('hook:' + hook);
  3829. }
  3830. popTarget();
  3831. }
  3832. /* */
  3833. const MAX_UPDATE_COUNT = 100;
  3834. const queue = [];
  3835. const activatedChildren = [];
  3836. let has = {};
  3837. let circular = {};
  3838. let waiting = false;
  3839. let flushing = false;
  3840. let index = 0;
  3841. /**
  3842. * Reset the scheduler's state.
  3843. */
  3844. function resetSchedulerState () {
  3845. index = queue.length = activatedChildren.length = 0;
  3846. has = {};
  3847. {
  3848. circular = {};
  3849. }
  3850. waiting = flushing = false;
  3851. }
  3852. // Async edge case #6566 requires saving the timestamp when event listeners are
  3853. // attached. However, calling performance.now() has a perf overhead especially
  3854. // if the page has thousands of event listeners. Instead, we take a timestamp
  3855. // every time the scheduler flushes and use that for all event listeners
  3856. // attached during that flush.
  3857. let currentFlushTimestamp = 0;
  3858. // Async edge case fix requires storing an event listener's attach timestamp.
  3859. let getNow = Date.now;
  3860. // Determine what event timestamp the browser is using. Annoyingly, the
  3861. // timestamp can either be hi-res (relative to page load) or low-res
  3862. // (relative to UNIX epoch), so in order to compare time we have to use the
  3863. // same timestamp type when saving the flush timestamp.
  3864. // All IE versions use low-res event timestamps, and have problematic clock
  3865. // implementations (#9632)
  3866. if (inBrowser && !isIE) {
  3867. const performance = window.performance;
  3868. if (
  3869. performance &&
  3870. typeof performance.now === 'function' &&
  3871. getNow() > document.createEvent('Event').timeStamp
  3872. ) {
  3873. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3874. // smaller than it, it means the event is using a hi-res timestamp,
  3875. // and we need to use the hi-res version for event listener timestamps as
  3876. // well.
  3877. getNow = () => performance.now();
  3878. }
  3879. }
  3880. /**
  3881. * Flush both queues and run the watchers.
  3882. */
  3883. function flushSchedulerQueue () {
  3884. currentFlushTimestamp = getNow();
  3885. flushing = true;
  3886. let watcher, id;
  3887. // Sort queue before flush.
  3888. // This ensures that:
  3889. // 1. Components are updated from parent to child. (because parent is always
  3890. // created before the child)
  3891. // 2. A component's user watchers are run before its render watcher (because
  3892. // user watchers are created before the render watcher)
  3893. // 3. If a component is destroyed during a parent component's watcher run,
  3894. // its watchers can be skipped.
  3895. queue.sort((a, b) => a.id - b.id);
  3896. // do not cache length because more watchers might be pushed
  3897. // as we run existing watchers
  3898. for (index = 0; index < queue.length; index++) {
  3899. watcher = queue[index];
  3900. if (watcher.before) {
  3901. watcher.before();
  3902. }
  3903. id = watcher.id;
  3904. has[id] = null;
  3905. watcher.run();
  3906. // in dev build, check and stop circular updates.
  3907. if (has[id] != null) {
  3908. circular[id] = (circular[id] || 0) + 1;
  3909. if (circular[id] > MAX_UPDATE_COUNT) {
  3910. warn(
  3911. 'You may have an infinite update loop ' + (
  3912. watcher.user
  3913. ? `in watcher with expression "${watcher.expression}"`
  3914. : `in a component render function.`
  3915. ),
  3916. watcher.vm
  3917. );
  3918. break
  3919. }
  3920. }
  3921. }
  3922. // keep copies of post queues before resetting state
  3923. const activatedQueue = activatedChildren.slice();
  3924. const updatedQueue = queue.slice();
  3925. resetSchedulerState();
  3926. // call component updated and activated hooks
  3927. callActivatedHooks(activatedQueue);
  3928. callUpdatedHooks(updatedQueue);
  3929. // devtool hook
  3930. /* istanbul ignore if */
  3931. if (devtools && config.devtools) {
  3932. devtools.emit('flush');
  3933. }
  3934. }
  3935. function callUpdatedHooks (queue) {
  3936. let i = queue.length;
  3937. while (i--) {
  3938. const watcher = queue[i];
  3939. const vm = watcher.vm;
  3940. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3941. callHook(vm, 'updated');
  3942. }
  3943. }
  3944. }
  3945. /**
  3946. * Queue a kept-alive component that was activated during patch.
  3947. * The queue will be processed after the entire tree has been patched.
  3948. */
  3949. function queueActivatedComponent (vm) {
  3950. // setting _inactive to false here so that a render function can
  3951. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3952. vm._inactive = false;
  3953. activatedChildren.push(vm);
  3954. }
  3955. function callActivatedHooks (queue) {
  3956. for (let i = 0; i < queue.length; i++) {
  3957. queue[i]._inactive = true;
  3958. activateChildComponent(queue[i], true /* true */);
  3959. }
  3960. }
  3961. /**
  3962. * Push a watcher into the watcher queue.
  3963. * Jobs with duplicate IDs will be skipped unless it's
  3964. * pushed when the queue is being flushed.
  3965. */
  3966. function queueWatcher (watcher) {
  3967. const id = watcher.id;
  3968. if (has[id] == null) {
  3969. has[id] = true;
  3970. if (!flushing) {
  3971. queue.push(watcher);
  3972. } else {
  3973. // if already flushing, splice the watcher based on its id
  3974. // if already past its id, it will be run next immediately.
  3975. let i = queue.length - 1;
  3976. while (i > index && queue[i].id > watcher.id) {
  3977. i--;
  3978. }
  3979. queue.splice(i + 1, 0, watcher);
  3980. }
  3981. // queue the flush
  3982. if (!waiting) {
  3983. waiting = true;
  3984. if (!config.async) {
  3985. flushSchedulerQueue();
  3986. return
  3987. }
  3988. nextTick(flushSchedulerQueue);
  3989. }
  3990. }
  3991. }
  3992. /* */
  3993. let uid$2 = 0;
  3994. /**
  3995. * A watcher parses an expression, collects dependencies,
  3996. * and fires callback when the expression value changes.
  3997. * This is used for both the $watch() api and directives.
  3998. */
  3999. class Watcher {
  4000. constructor (
  4001. vm,
  4002. expOrFn,
  4003. cb,
  4004. options,
  4005. isRenderWatcher
  4006. ) {
  4007. this.vm = vm;
  4008. if (isRenderWatcher) {
  4009. vm._watcher = this;
  4010. }
  4011. vm._watchers.push(this);
  4012. // options
  4013. if (options) {
  4014. this.deep = !!options.deep;
  4015. this.user = !!options.user;
  4016. this.lazy = !!options.lazy;
  4017. this.sync = !!options.sync;
  4018. this.before = options.before;
  4019. } else {
  4020. this.deep = this.user = this.lazy = this.sync = false;
  4021. }
  4022. this.cb = cb;
  4023. this.id = ++uid$2; // uid for batching
  4024. this.active = true;
  4025. this.dirty = this.lazy; // for lazy watchers
  4026. this.deps = [];
  4027. this.newDeps = [];
  4028. this.depIds = new _Set();
  4029. this.newDepIds = new _Set();
  4030. this.expression = expOrFn.toString();
  4031. // parse expression for getter
  4032. if (typeof expOrFn === 'function') {
  4033. this.getter = expOrFn;
  4034. } else {
  4035. this.getter = parsePath(expOrFn);
  4036. if (!this.getter) {
  4037. this.getter = noop;
  4038. warn(
  4039. `Failed watching path: "${expOrFn}" ` +
  4040. 'Watcher only accepts simple dot-delimited paths. ' +
  4041. 'For full control, use a function instead.',
  4042. vm
  4043. );
  4044. }
  4045. }
  4046. this.value = this.lazy
  4047. ? undefined
  4048. : this.get();
  4049. }
  4050. /**
  4051. * Evaluate the getter, and re-collect dependencies.
  4052. */
  4053. get () {
  4054. pushTarget(this);
  4055. let value;
  4056. const vm = this.vm;
  4057. try {
  4058. value = this.getter.call(vm, vm);
  4059. } catch (e) {
  4060. if (this.user) {
  4061. handleError(e, vm, `getter for watcher "${this.expression}"`);
  4062. } else {
  4063. throw e
  4064. }
  4065. } finally {
  4066. // "touch" every property so they are all tracked as
  4067. // dependencies for deep watching
  4068. if (this.deep) {
  4069. traverse(value);
  4070. }
  4071. popTarget();
  4072. this.cleanupDeps();
  4073. }
  4074. return value
  4075. }
  4076. /**
  4077. * Add a dependency to this directive.
  4078. */
  4079. addDep (dep) {
  4080. const id = dep.id;
  4081. if (!this.newDepIds.has(id)) {
  4082. this.newDepIds.add(id);
  4083. this.newDeps.push(dep);
  4084. if (!this.depIds.has(id)) {
  4085. dep.addSub(this);
  4086. }
  4087. }
  4088. }
  4089. /**
  4090. * Clean up for dependency collection.
  4091. */
  4092. cleanupDeps () {
  4093. let i = this.deps.length;
  4094. while (i--) {
  4095. const dep = this.deps[i];
  4096. if (!this.newDepIds.has(dep.id)) {
  4097. dep.removeSub(this);
  4098. }
  4099. }
  4100. let tmp = this.depIds;
  4101. this.depIds = this.newDepIds;
  4102. this.newDepIds = tmp;
  4103. this.newDepIds.clear();
  4104. tmp = this.deps;
  4105. this.deps = this.newDeps;
  4106. this.newDeps = tmp;
  4107. this.newDeps.length = 0;
  4108. }
  4109. /**
  4110. * Subscriber interface.
  4111. * Will be called when a dependency changes.
  4112. */
  4113. update () {
  4114. /* istanbul ignore else */
  4115. if (this.lazy) {
  4116. this.dirty = true;
  4117. } else if (this.sync) {
  4118. this.run();
  4119. } else {
  4120. queueWatcher(this);
  4121. }
  4122. }
  4123. /**
  4124. * Scheduler job interface.
  4125. * Will be called by the scheduler.
  4126. */
  4127. run () {
  4128. if (this.active) {
  4129. const value = this.get();
  4130. if (
  4131. value !== this.value ||
  4132. // Deep watchers and watchers on Object/Arrays should fire even
  4133. // when the value is the same, because the value may
  4134. // have mutated.
  4135. isObject(value) ||
  4136. this.deep
  4137. ) {
  4138. // set new value
  4139. const oldValue = this.value;
  4140. this.value = value;
  4141. if (this.user) {
  4142. try {
  4143. this.cb.call(this.vm, value, oldValue);
  4144. } catch (e) {
  4145. handleError(e, this.vm, `callback for watcher "${this.expression}"`);
  4146. }
  4147. } else {
  4148. this.cb.call(this.vm, value, oldValue);
  4149. }
  4150. }
  4151. }
  4152. }
  4153. /**
  4154. * Evaluate the value of the watcher.
  4155. * This only gets called for lazy watchers.
  4156. */
  4157. evaluate () {
  4158. this.value = this.get();
  4159. this.dirty = false;
  4160. }
  4161. /**
  4162. * Depend on all deps collected by this watcher.
  4163. */
  4164. depend () {
  4165. let i = this.deps.length;
  4166. while (i--) {
  4167. this.deps[i].depend();
  4168. }
  4169. }
  4170. /**
  4171. * Remove self from all dependencies' subscriber list.
  4172. */
  4173. teardown () {
  4174. if (this.active) {
  4175. // remove self from vm's watcher list
  4176. // this is a somewhat expensive operation so we skip it
  4177. // if the vm is being destroyed.
  4178. if (!this.vm._isBeingDestroyed) {
  4179. remove(this.vm._watchers, this);
  4180. }
  4181. let i = this.deps.length;
  4182. while (i--) {
  4183. this.deps[i].removeSub(this);
  4184. }
  4185. this.active = false;
  4186. }
  4187. }
  4188. }
  4189. /* */
  4190. const sharedPropertyDefinition = {
  4191. enumerable: true,
  4192. configurable: true,
  4193. get: noop,
  4194. set: noop
  4195. };
  4196. function proxy (target, sourceKey, key) {
  4197. sharedPropertyDefinition.get = function proxyGetter () {
  4198. return this[sourceKey][key]
  4199. };
  4200. sharedPropertyDefinition.set = function proxySetter (val) {
  4201. this[sourceKey][key] = val;
  4202. };
  4203. Object.defineProperty(target, key, sharedPropertyDefinition);
  4204. }
  4205. function initState (vm) {
  4206. vm._watchers = [];
  4207. const opts = vm.$options;
  4208. if (opts.props) initProps(vm, opts.props);
  4209. if (opts.methods) initMethods(vm, opts.methods);
  4210. if (opts.data) {
  4211. initData(vm);
  4212. } else {
  4213. observe(vm._data = {}, true /* asRootData */);
  4214. }
  4215. if (opts.computed) initComputed(vm, opts.computed);
  4216. if (opts.watch && opts.watch !== nativeWatch) {
  4217. initWatch(vm, opts.watch);
  4218. }
  4219. }
  4220. function initProps (vm, propsOptions) {
  4221. const propsData = vm.$options.propsData || {};
  4222. const props = vm._props = {};
  4223. // cache prop keys so that future props updates can iterate using Array
  4224. // instead of dynamic object key enumeration.
  4225. const keys = vm.$options._propKeys = [];
  4226. const isRoot = !vm.$parent;
  4227. // root instance props should be converted
  4228. if (!isRoot) {
  4229. toggleObserving(false);
  4230. }
  4231. for (const key in propsOptions) {
  4232. keys.push(key);
  4233. const value = validateProp(key, propsOptions, propsData, vm);
  4234. /* istanbul ignore else */
  4235. {
  4236. const hyphenatedKey = hyphenate(key);
  4237. if (isReservedAttribute(hyphenatedKey) ||
  4238. config.isReservedAttr(hyphenatedKey)) {
  4239. warn(
  4240. `"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`,
  4241. vm
  4242. );
  4243. }
  4244. defineReactive$$1(props, key, value, () => {
  4245. if (!isRoot && !isUpdatingChildComponent) {
  4246. warn(
  4247. `Avoid mutating a prop directly since the value will be ` +
  4248. `overwritten whenever the parent component re-renders. ` +
  4249. `Instead, use a data or computed property based on the prop's ` +
  4250. `value. Prop being mutated: "${key}"`,
  4251. vm
  4252. );
  4253. }
  4254. });
  4255. }
  4256. // static props are already proxied on the component's prototype
  4257. // during Vue.extend(). We only need to proxy props defined at
  4258. // instantiation here.
  4259. if (!(key in vm)) {
  4260. proxy(vm, `_props`, key);
  4261. }
  4262. }
  4263. toggleObserving(true);
  4264. }
  4265. function initData (vm) {
  4266. let data = vm.$options.data;
  4267. data = vm._data = typeof data === 'function'
  4268. ? getData(data, vm)
  4269. : data || {};
  4270. if (!isPlainObject(data)) {
  4271. data = {};
  4272. warn(
  4273. 'data functions should return an object:\n' +
  4274. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  4275. vm
  4276. );
  4277. }
  4278. // proxy data on instance
  4279. const keys = Object.keys(data);
  4280. const props = vm.$options.props;
  4281. const methods = vm.$options.methods;
  4282. let i = keys.length;
  4283. while (i--) {
  4284. const key = keys[i];
  4285. {
  4286. if (methods && hasOwn(methods, key)) {
  4287. warn(
  4288. `Method "${key}" has already been defined as a data property.`,
  4289. vm
  4290. );
  4291. }
  4292. }
  4293. if (props && hasOwn(props, key)) {
  4294. warn(
  4295. `The data property "${key}" is already declared as a prop. ` +
  4296. `Use prop default value instead.`,
  4297. vm
  4298. );
  4299. } else if (!isReserved(key)) {
  4300. proxy(vm, `_data`, key);
  4301. }
  4302. }
  4303. // observe data
  4304. observe(data, true /* asRootData */);
  4305. }
  4306. function getData (data, vm) {
  4307. // #7573 disable dep collection when invoking data getters
  4308. pushTarget();
  4309. try {
  4310. return data.call(vm, vm)
  4311. } catch (e) {
  4312. handleError(e, vm, `data()`);
  4313. return {}
  4314. } finally {
  4315. popTarget();
  4316. }
  4317. }
  4318. const computedWatcherOptions = { lazy: true };
  4319. function initComputed (vm, computed) {
  4320. // $flow-disable-line
  4321. const watchers = vm._computedWatchers = Object.create(null);
  4322. // computed properties are just getters during SSR
  4323. const isSSR = isServerRendering();
  4324. for (const key in computed) {
  4325. const userDef = computed[key];
  4326. const getter = typeof userDef === 'function' ? userDef : userDef.get;
  4327. if (getter == null) {
  4328. warn(
  4329. `Getter is missing for computed property "${key}".`,
  4330. vm
  4331. );
  4332. }
  4333. if (!isSSR) {
  4334. // create internal watcher for the computed property.
  4335. watchers[key] = new Watcher(
  4336. vm,
  4337. getter || noop,
  4338. noop,
  4339. computedWatcherOptions
  4340. );
  4341. }
  4342. // component-defined computed properties are already defined on the
  4343. // component prototype. We only need to define computed properties defined
  4344. // at instantiation here.
  4345. if (!(key in vm)) {
  4346. defineComputed(vm, key, userDef);
  4347. } else {
  4348. if (key in vm.$data) {
  4349. warn(`The computed property "${key}" is already defined in data.`, vm);
  4350. } else if (vm.$options.props && key in vm.$options.props) {
  4351. warn(`The computed property "${key}" is already defined as a prop.`, vm);
  4352. }
  4353. }
  4354. }
  4355. }
  4356. function defineComputed (
  4357. target,
  4358. key,
  4359. userDef
  4360. ) {
  4361. const shouldCache = !isServerRendering();
  4362. if (typeof userDef === 'function') {
  4363. sharedPropertyDefinition.get = shouldCache
  4364. ? createComputedGetter(key)
  4365. : createGetterInvoker(userDef);
  4366. sharedPropertyDefinition.set = noop;
  4367. } else {
  4368. sharedPropertyDefinition.get = userDef.get
  4369. ? shouldCache && userDef.cache !== false
  4370. ? createComputedGetter(key)
  4371. : createGetterInvoker(userDef.get)
  4372. : noop;
  4373. sharedPropertyDefinition.set = userDef.set || noop;
  4374. }
  4375. if (sharedPropertyDefinition.set === noop) {
  4376. sharedPropertyDefinition.set = function () {
  4377. warn(
  4378. `Computed property "${key}" was assigned to but it has no setter.`,
  4379. this
  4380. );
  4381. };
  4382. }
  4383. Object.defineProperty(target, key, sharedPropertyDefinition);
  4384. }
  4385. function createComputedGetter (key) {
  4386. return function computedGetter () {
  4387. const watcher = this._computedWatchers && this._computedWatchers[key];
  4388. if (watcher) {
  4389. if (watcher.dirty) {
  4390. watcher.evaluate();
  4391. }
  4392. if (Dep.target) {
  4393. watcher.depend();
  4394. }
  4395. return watcher.value
  4396. }
  4397. }
  4398. }
  4399. function createGetterInvoker(fn) {
  4400. return function computedGetter () {
  4401. return fn.call(this, this)
  4402. }
  4403. }
  4404. function initMethods (vm, methods) {
  4405. const props = vm.$options.props;
  4406. for (const key in methods) {
  4407. {
  4408. if (typeof methods[key] !== 'function') {
  4409. warn(
  4410. `Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  4411. `Did you reference the function correctly?`,
  4412. vm
  4413. );
  4414. }
  4415. if (props && hasOwn(props, key)) {
  4416. warn(
  4417. `Method "${key}" has already been defined as a prop.`,
  4418. vm
  4419. );
  4420. }
  4421. if ((key in vm) && isReserved(key)) {
  4422. warn(
  4423. `Method "${key}" conflicts with an existing Vue instance method. ` +
  4424. `Avoid defining component methods that start with _ or $.`
  4425. );
  4426. }
  4427. }
  4428. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  4429. }
  4430. }
  4431. function initWatch (vm, watch) {
  4432. for (const key in watch) {
  4433. const handler = watch[key];
  4434. if (Array.isArray(handler)) {
  4435. for (let i = 0; i < handler.length; i++) {
  4436. createWatcher(vm, key, handler[i]);
  4437. }
  4438. } else {
  4439. createWatcher(vm, key, handler);
  4440. }
  4441. }
  4442. }
  4443. function createWatcher (
  4444. vm,
  4445. expOrFn,
  4446. handler,
  4447. options
  4448. ) {
  4449. if (isPlainObject(handler)) {
  4450. options = handler;
  4451. handler = handler.handler;
  4452. }
  4453. if (typeof handler === 'string') {
  4454. handler = vm[handler];
  4455. }
  4456. return vm.$watch(expOrFn, handler, options)
  4457. }
  4458. function stateMixin (Vue) {
  4459. // flow somehow has problems with directly declared definition object
  4460. // when using Object.defineProperty, so we have to procedurally build up
  4461. // the object here.
  4462. const dataDef = {};
  4463. dataDef.get = function () { return this._data };
  4464. const propsDef = {};
  4465. propsDef.get = function () { return this._props };
  4466. {
  4467. dataDef.set = function () {
  4468. warn(
  4469. 'Avoid replacing instance root $data. ' +
  4470. 'Use nested data properties instead.',
  4471. this
  4472. );
  4473. };
  4474. propsDef.set = function () {
  4475. warn(`$props is readonly.`, this);
  4476. };
  4477. }
  4478. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4479. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4480. Vue.prototype.$set = set;
  4481. Vue.prototype.$delete = del;
  4482. Vue.prototype.$watch = function (
  4483. expOrFn,
  4484. cb,
  4485. options
  4486. ) {
  4487. const vm = this;
  4488. if (isPlainObject(cb)) {
  4489. return createWatcher(vm, expOrFn, cb, options)
  4490. }
  4491. options = options || {};
  4492. options.user = true;
  4493. const watcher = new Watcher(vm, expOrFn, cb, options);
  4494. if (options.immediate) {
  4495. try {
  4496. cb.call(vm, watcher.value);
  4497. } catch (error) {
  4498. handleError(error, vm, `callback for immediate watcher "${watcher.expression}"`);
  4499. }
  4500. }
  4501. return function unwatchFn () {
  4502. watcher.teardown();
  4503. }
  4504. };
  4505. }
  4506. /* */
  4507. let uid$3 = 0;
  4508. function initMixin (Vue) {
  4509. Vue.prototype._init = function (options) {
  4510. const vm = this;
  4511. // a uid
  4512. vm._uid = uid$3++;
  4513. let startTag, endTag;
  4514. /* istanbul ignore if */
  4515. if (config.performance && mark) {
  4516. startTag = `vue-perf-start:${vm._uid}`;
  4517. endTag = `vue-perf-end:${vm._uid}`;
  4518. mark(startTag);
  4519. }
  4520. // a flag to avoid this being observed
  4521. vm._isVue = true;
  4522. // merge options
  4523. if (options && options._isComponent) {
  4524. // optimize internal component instantiation
  4525. // since dynamic options merging is pretty slow, and none of the
  4526. // internal component options needs special treatment.
  4527. initInternalComponent(vm, options);
  4528. } else {
  4529. vm.$options = mergeOptions(
  4530. resolveConstructorOptions(vm.constructor),
  4531. options || {},
  4532. vm
  4533. );
  4534. }
  4535. /* istanbul ignore else */
  4536. {
  4537. initProxy(vm);
  4538. }
  4539. // expose real self
  4540. vm._self = vm;
  4541. initLifecycle(vm);
  4542. initEvents(vm);
  4543. initRender(vm);
  4544. callHook(vm, 'beforeCreate');
  4545. initInjections(vm); // resolve injections before data/props
  4546. initState(vm);
  4547. initProvide(vm); // resolve provide after data/props
  4548. callHook(vm, 'created');
  4549. /* istanbul ignore if */
  4550. if (config.performance && mark) {
  4551. vm._name = formatComponentName(vm, false);
  4552. mark(endTag);
  4553. measure(`vue ${vm._name} init`, startTag, endTag);
  4554. }
  4555. if (vm.$options.el) {
  4556. vm.$mount(vm.$options.el);
  4557. }
  4558. };
  4559. }
  4560. function initInternalComponent (vm, options) {
  4561. const opts = vm.$options = Object.create(vm.constructor.options);
  4562. // doing this because it's faster than dynamic enumeration.
  4563. const parentVnode = options._parentVnode;
  4564. opts.parent = options.parent;
  4565. opts._parentVnode = parentVnode;
  4566. const vnodeComponentOptions = parentVnode.componentOptions;
  4567. opts.propsData = vnodeComponentOptions.propsData;
  4568. opts._parentListeners = vnodeComponentOptions.listeners;
  4569. opts._renderChildren = vnodeComponentOptions.children;
  4570. opts._componentTag = vnodeComponentOptions.tag;
  4571. if (options.render) {
  4572. opts.render = options.render;
  4573. opts.staticRenderFns = options.staticRenderFns;
  4574. }
  4575. }
  4576. function resolveConstructorOptions (Ctor) {
  4577. let options = Ctor.options;
  4578. if (Ctor.super) {
  4579. const superOptions = resolveConstructorOptions(Ctor.super);
  4580. const cachedSuperOptions = Ctor.superOptions;
  4581. if (superOptions !== cachedSuperOptions) {
  4582. // super option changed,
  4583. // need to resolve new options.
  4584. Ctor.superOptions = superOptions;
  4585. // check if there are any late-modified/attached options (#4976)
  4586. const modifiedOptions = resolveModifiedOptions(Ctor);
  4587. // update base extend options
  4588. if (modifiedOptions) {
  4589. extend(Ctor.extendOptions, modifiedOptions);
  4590. }
  4591. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4592. if (options.name) {
  4593. options.components[options.name] = Ctor;
  4594. }
  4595. }
  4596. }
  4597. return options
  4598. }
  4599. function resolveModifiedOptions (Ctor) {
  4600. let modified;
  4601. const latest = Ctor.options;
  4602. const sealed = Ctor.sealedOptions;
  4603. for (const key in latest) {
  4604. if (latest[key] !== sealed[key]) {
  4605. if (!modified) modified = {};
  4606. modified[key] = latest[key];
  4607. }
  4608. }
  4609. return modified
  4610. }
  4611. function Vue (options) {
  4612. if (!(this instanceof Vue)
  4613. ) {
  4614. warn('Vue is a constructor and should be called with the `new` keyword');
  4615. }
  4616. this._init(options);
  4617. }
  4618. initMixin(Vue);
  4619. stateMixin(Vue);
  4620. eventsMixin(Vue);
  4621. lifecycleMixin(Vue);
  4622. renderMixin(Vue);
  4623. /* */
  4624. function initUse (Vue) {
  4625. Vue.use = function (plugin) {
  4626. const installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  4627. if (installedPlugins.indexOf(plugin) > -1) {
  4628. return this
  4629. }
  4630. // additional parameters
  4631. const args = toArray(arguments, 1);
  4632. args.unshift(this);
  4633. if (typeof plugin.install === 'function') {
  4634. plugin.install.apply(plugin, args);
  4635. } else if (typeof plugin === 'function') {
  4636. plugin.apply(null, args);
  4637. }
  4638. installedPlugins.push(plugin);
  4639. return this
  4640. };
  4641. }
  4642. /* */
  4643. function initMixin$1 (Vue) {
  4644. Vue.mixin = function (mixin) {
  4645. this.options = mergeOptions(this.options, mixin);
  4646. return this
  4647. };
  4648. }
  4649. /* */
  4650. function initExtend (Vue) {
  4651. /**
  4652. * Each instance constructor, including Vue, has a unique
  4653. * cid. This enables us to create wrapped "child
  4654. * constructors" for prototypal inheritance and cache them.
  4655. */
  4656. Vue.cid = 0;
  4657. let cid = 1;
  4658. /**
  4659. * Class inheritance
  4660. */
  4661. Vue.extend = function (extendOptions) {
  4662. extendOptions = extendOptions || {};
  4663. const Super = this;
  4664. const SuperId = Super.cid;
  4665. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  4666. if (cachedCtors[SuperId]) {
  4667. return cachedCtors[SuperId]
  4668. }
  4669. const name = extendOptions.name || Super.options.name;
  4670. if (name) {
  4671. validateComponentName(name);
  4672. }
  4673. const Sub = function VueComponent (options) {
  4674. this._init(options);
  4675. };
  4676. Sub.prototype = Object.create(Super.prototype);
  4677. Sub.prototype.constructor = Sub;
  4678. Sub.cid = cid++;
  4679. Sub.options = mergeOptions(
  4680. Super.options,
  4681. extendOptions
  4682. );
  4683. Sub['super'] = Super;
  4684. // For props and computed properties, we define the proxy getters on
  4685. // the Vue instances at extension time, on the extended prototype. This
  4686. // avoids Object.defineProperty calls for each instance created.
  4687. if (Sub.options.props) {
  4688. initProps$1(Sub);
  4689. }
  4690. if (Sub.options.computed) {
  4691. initComputed$1(Sub);
  4692. }
  4693. // allow further extension/mixin/plugin usage
  4694. Sub.extend = Super.extend;
  4695. Sub.mixin = Super.mixin;
  4696. Sub.use = Super.use;
  4697. // create asset registers, so extended classes
  4698. // can have their private assets too.
  4699. ASSET_TYPES.forEach(function (type) {
  4700. Sub[type] = Super[type];
  4701. });
  4702. // enable recursive self-lookup
  4703. if (name) {
  4704. Sub.options.components[name] = Sub;
  4705. }
  4706. // keep a reference to the super options at extension time.
  4707. // later at instantiation we can check if Super's options have
  4708. // been updated.
  4709. Sub.superOptions = Super.options;
  4710. Sub.extendOptions = extendOptions;
  4711. Sub.sealedOptions = extend({}, Sub.options);
  4712. // cache constructor
  4713. cachedCtors[SuperId] = Sub;
  4714. return Sub
  4715. };
  4716. }
  4717. function initProps$1 (Comp) {
  4718. const props = Comp.options.props;
  4719. for (const key in props) {
  4720. proxy(Comp.prototype, `_props`, key);
  4721. }
  4722. }
  4723. function initComputed$1 (Comp) {
  4724. const computed = Comp.options.computed;
  4725. for (const key in computed) {
  4726. defineComputed(Comp.prototype, key, computed[key]);
  4727. }
  4728. }
  4729. /* */
  4730. function initAssetRegisters (Vue) {
  4731. /**
  4732. * Create asset registration methods.
  4733. */
  4734. ASSET_TYPES.forEach(type => {
  4735. Vue[type] = function (
  4736. id,
  4737. definition
  4738. ) {
  4739. if (!definition) {
  4740. return this.options[type + 's'][id]
  4741. } else {
  4742. /* istanbul ignore if */
  4743. if (type === 'component') {
  4744. validateComponentName(id);
  4745. }
  4746. if (type === 'component' && isPlainObject(definition)) {
  4747. definition.name = definition.name || id;
  4748. definition = this.options._base.extend(definition);
  4749. }
  4750. if (type === 'directive' && typeof definition === 'function') {
  4751. definition = { bind: definition, update: definition };
  4752. }
  4753. this.options[type + 's'][id] = definition;
  4754. return definition
  4755. }
  4756. };
  4757. });
  4758. }
  4759. /* */
  4760. function getComponentName (opts) {
  4761. return opts && (opts.Ctor.options.name || opts.tag)
  4762. }
  4763. function matches (pattern, name) {
  4764. if (Array.isArray(pattern)) {
  4765. return pattern.indexOf(name) > -1
  4766. } else if (typeof pattern === 'string') {
  4767. return pattern.split(',').indexOf(name) > -1
  4768. } else if (isRegExp(pattern)) {
  4769. return pattern.test(name)
  4770. }
  4771. /* istanbul ignore next */
  4772. return false
  4773. }
  4774. function pruneCache (keepAliveInstance, filter) {
  4775. const { cache, keys, _vnode } = keepAliveInstance;
  4776. for (const key in cache) {
  4777. const cachedNode = cache[key];
  4778. if (cachedNode) {
  4779. const name = getComponentName(cachedNode.componentOptions);
  4780. if (name && !filter(name)) {
  4781. pruneCacheEntry(cache, key, keys, _vnode);
  4782. }
  4783. }
  4784. }
  4785. }
  4786. function pruneCacheEntry (
  4787. cache,
  4788. key,
  4789. keys,
  4790. current
  4791. ) {
  4792. const cached$$1 = cache[key];
  4793. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  4794. cached$$1.componentInstance.$destroy();
  4795. }
  4796. cache[key] = null;
  4797. remove(keys, key);
  4798. }
  4799. const patternTypes = [String, RegExp, Array];
  4800. var KeepAlive = {
  4801. name: 'keep-alive',
  4802. abstract: true,
  4803. props: {
  4804. include: patternTypes,
  4805. exclude: patternTypes,
  4806. max: [String, Number]
  4807. },
  4808. created () {
  4809. this.cache = Object.create(null);
  4810. this.keys = [];
  4811. },
  4812. destroyed () {
  4813. for (const key in this.cache) {
  4814. pruneCacheEntry(this.cache, key, this.keys);
  4815. }
  4816. },
  4817. mounted () {
  4818. this.$watch('include', val => {
  4819. pruneCache(this, name => matches(val, name));
  4820. });
  4821. this.$watch('exclude', val => {
  4822. pruneCache(this, name => !matches(val, name));
  4823. });
  4824. },
  4825. render () {
  4826. const slot = this.$slots.default;
  4827. const vnode = getFirstComponentChild(slot);
  4828. const componentOptions = vnode && vnode.componentOptions;
  4829. if (componentOptions) {
  4830. // check pattern
  4831. const name = getComponentName(componentOptions);
  4832. const { include, exclude } = this;
  4833. if (
  4834. // not included
  4835. (include && (!name || !matches(include, name))) ||
  4836. // excluded
  4837. (exclude && name && matches(exclude, name))
  4838. ) {
  4839. return vnode
  4840. }
  4841. const { cache, keys } = this;
  4842. const key = vnode.key == null
  4843. // same constructor may get registered as different local components
  4844. // so cid alone is not enough (#3269)
  4845. ? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
  4846. : vnode.key;
  4847. if (cache[key]) {
  4848. vnode.componentInstance = cache[key].componentInstance;
  4849. // make current key freshest
  4850. remove(keys, key);
  4851. keys.push(key);
  4852. } else {
  4853. cache[key] = vnode;
  4854. keys.push(key);
  4855. // prune oldest entry
  4856. if (this.max && keys.length > parseInt(this.max)) {
  4857. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  4858. }
  4859. }
  4860. vnode.data.keepAlive = true;
  4861. }
  4862. return vnode || (slot && slot[0])
  4863. }
  4864. };
  4865. var builtInComponents = {
  4866. KeepAlive
  4867. };
  4868. /* */
  4869. function initGlobalAPI (Vue) {
  4870. // config
  4871. const configDef = {};
  4872. configDef.get = () => config;
  4873. {
  4874. configDef.set = () => {
  4875. warn(
  4876. 'Do not replace the Vue.config object, set individual fields instead.'
  4877. );
  4878. };
  4879. }
  4880. Object.defineProperty(Vue, 'config', configDef);
  4881. // exposed util methods.
  4882. // NOTE: these are not considered part of the public API - avoid relying on
  4883. // them unless you are aware of the risk.
  4884. Vue.util = {
  4885. warn,
  4886. extend,
  4887. mergeOptions,
  4888. defineReactive: defineReactive$$1
  4889. };
  4890. Vue.set = set;
  4891. Vue.delete = del;
  4892. Vue.nextTick = nextTick;
  4893. // 2.6 explicit observable API
  4894. Vue.observable = (obj) => {
  4895. observe(obj);
  4896. return obj
  4897. };
  4898. Vue.options = Object.create(null);
  4899. ASSET_TYPES.forEach(type => {
  4900. Vue.options[type + 's'] = Object.create(null);
  4901. });
  4902. // this is used to identify the "base" constructor to extend all plain-object
  4903. // components with in Weex's multi-instance scenarios.
  4904. Vue.options._base = Vue;
  4905. extend(Vue.options.components, builtInComponents);
  4906. initUse(Vue);
  4907. initMixin$1(Vue);
  4908. initExtend(Vue);
  4909. initAssetRegisters(Vue);
  4910. }
  4911. initGlobalAPI(Vue);
  4912. Object.defineProperty(Vue.prototype, '$isServer', {
  4913. get: isServerRendering
  4914. });
  4915. Object.defineProperty(Vue.prototype, '$ssrContext', {
  4916. get () {
  4917. /* istanbul ignore next */
  4918. return this.$vnode && this.$vnode.ssrContext
  4919. }
  4920. });
  4921. // expose FunctionalRenderContext for ssr runtime helper installation
  4922. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  4923. value: FunctionalRenderContext
  4924. });
  4925. Vue.version = '2.6.10';
  4926. /* */
  4927. // these are reserved for web because they are directly compiled away
  4928. // during template compilation
  4929. const isReservedAttr = makeMap('style,class');
  4930. // attributes that should be using props for binding
  4931. const acceptValue = makeMap('input,textarea,option,select,progress');
  4932. const mustUseProp = (tag, type, attr) => {
  4933. return (
  4934. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  4935. (attr === 'selected' && tag === 'option') ||
  4936. (attr === 'checked' && tag === 'input') ||
  4937. (attr === 'muted' && tag === 'video')
  4938. )
  4939. };
  4940. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  4941. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  4942. const convertEnumeratedValue = (key, value) => {
  4943. return isFalsyAttrValue(value) || value === 'false'
  4944. ? 'false'
  4945. // allow arbitrary string value for contenteditable
  4946. : key === 'contenteditable' && isValidContentEditableValue(value)
  4947. ? value
  4948. : 'true'
  4949. };
  4950. const isBooleanAttr = makeMap(
  4951. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  4952. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  4953. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  4954. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  4955. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  4956. 'truespeed,typemustmatch,visible'
  4957. );
  4958. const xlinkNS = 'http://www.w3.org/1999/xlink';
  4959. const isXlink = (name) => {
  4960. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  4961. };
  4962. const getXlinkProp = (name) => {
  4963. return isXlink(name) ? name.slice(6, name.length) : ''
  4964. };
  4965. const isFalsyAttrValue = (val) => {
  4966. return val == null || val === false
  4967. };
  4968. /* */
  4969. function genClassForVnode (vnode) {
  4970. let data = vnode.data;
  4971. let parentNode = vnode;
  4972. let childNode = vnode;
  4973. while (isDef(childNode.componentInstance)) {
  4974. childNode = childNode.componentInstance._vnode;
  4975. if (childNode && childNode.data) {
  4976. data = mergeClassData(childNode.data, data);
  4977. }
  4978. }
  4979. while (isDef(parentNode = parentNode.parent)) {
  4980. if (parentNode && parentNode.data) {
  4981. data = mergeClassData(data, parentNode.data);
  4982. }
  4983. }
  4984. return renderClass(data.staticClass, data.class)
  4985. }
  4986. function mergeClassData (child, parent) {
  4987. return {
  4988. staticClass: concat(child.staticClass, parent.staticClass),
  4989. class: isDef(child.class)
  4990. ? [child.class, parent.class]
  4991. : parent.class
  4992. }
  4993. }
  4994. function renderClass (
  4995. staticClass,
  4996. dynamicClass
  4997. ) {
  4998. if (isDef(staticClass) || isDef(dynamicClass)) {
  4999. return concat(staticClass, stringifyClass(dynamicClass))
  5000. }
  5001. /* istanbul ignore next */
  5002. return ''
  5003. }
  5004. function concat (a, b) {
  5005. return a ? b ? (a + ' ' + b) : a : (b || '')
  5006. }
  5007. function stringifyClass (value) {
  5008. if (Array.isArray(value)) {
  5009. return stringifyArray(value)
  5010. }
  5011. if (isObject(value)) {
  5012. return stringifyObject(value)
  5013. }
  5014. if (typeof value === 'string') {
  5015. return value
  5016. }
  5017. /* istanbul ignore next */
  5018. return ''
  5019. }
  5020. function stringifyArray (value) {
  5021. let res = '';
  5022. let stringified;
  5023. for (let i = 0, l = value.length; i < l; i++) {
  5024. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  5025. if (res) res += ' ';
  5026. res += stringified;
  5027. }
  5028. }
  5029. return res
  5030. }
  5031. function stringifyObject (value) {
  5032. let res = '';
  5033. for (const key in value) {
  5034. if (value[key]) {
  5035. if (res) res += ' ';
  5036. res += key;
  5037. }
  5038. }
  5039. return res
  5040. }
  5041. /* */
  5042. const namespaceMap = {
  5043. svg: 'http://www.w3.org/2000/svg',
  5044. math: 'http://www.w3.org/1998/Math/MathML'
  5045. };
  5046. const isHTMLTag = makeMap(
  5047. 'html,body,base,head,link,meta,style,title,' +
  5048. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5049. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5050. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5051. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5052. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5053. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5054. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5055. 'output,progress,select,textarea,' +
  5056. 'details,dialog,menu,menuitem,summary,' +
  5057. 'content,element,shadow,template,blockquote,iframe,tfoot'
  5058. );
  5059. // this map is intentionally selective, only covering SVG elements that may
  5060. // contain child elements.
  5061. const isSVG = makeMap(
  5062. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5063. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5064. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  5065. true
  5066. );
  5067. const isPreTag = (tag) => tag === 'pre';
  5068. const isReservedTag = (tag) => {
  5069. return isHTMLTag(tag) || isSVG(tag)
  5070. };
  5071. function getTagNamespace (tag) {
  5072. if (isSVG(tag)) {
  5073. return 'svg'
  5074. }
  5075. // basic support for MathML
  5076. // note it doesn't support other MathML elements being component roots
  5077. if (tag === 'math') {
  5078. return 'math'
  5079. }
  5080. }
  5081. const unknownElementCache = Object.create(null);
  5082. function isUnknownElement (tag) {
  5083. /* istanbul ignore if */
  5084. if (!inBrowser) {
  5085. return true
  5086. }
  5087. if (isReservedTag(tag)) {
  5088. return false
  5089. }
  5090. tag = tag.toLowerCase();
  5091. /* istanbul ignore if */
  5092. if (unknownElementCache[tag] != null) {
  5093. return unknownElementCache[tag]
  5094. }
  5095. const el = document.createElement(tag);
  5096. if (tag.indexOf('-') > -1) {
  5097. // http://stackoverflow.com/a/28210364/1070244
  5098. return (unknownElementCache[tag] = (
  5099. el.constructor === window.HTMLUnknownElement ||
  5100. el.constructor === window.HTMLElement
  5101. ))
  5102. } else {
  5103. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  5104. }
  5105. }
  5106. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  5107. /* */
  5108. /**
  5109. * Query an element selector if it's not an element already.
  5110. */
  5111. function query (el) {
  5112. if (typeof el === 'string') {
  5113. const selected = document.querySelector(el);
  5114. if (!selected) {
  5115. warn(
  5116. 'Cannot find element: ' + el
  5117. );
  5118. return document.createElement('div')
  5119. }
  5120. return selected
  5121. } else {
  5122. return el
  5123. }
  5124. }
  5125. /* */
  5126. function createElement$1 (tagName, vnode) {
  5127. const elm = document.createElement(tagName);
  5128. if (tagName !== 'select') {
  5129. return elm
  5130. }
  5131. // false or null will remove the attribute but undefined will not
  5132. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  5133. elm.setAttribute('multiple', 'multiple');
  5134. }
  5135. return elm
  5136. }
  5137. function createElementNS (namespace, tagName) {
  5138. return document.createElementNS(namespaceMap[namespace], tagName)
  5139. }
  5140. function createTextNode (text) {
  5141. return document.createTextNode(text)
  5142. }
  5143. function createComment (text) {
  5144. return document.createComment(text)
  5145. }
  5146. function insertBefore (parentNode, newNode, referenceNode) {
  5147. parentNode.insertBefore(newNode, referenceNode);
  5148. }
  5149. function removeChild (node, child) {
  5150. node.removeChild(child);
  5151. }
  5152. function appendChild (node, child) {
  5153. node.appendChild(child);
  5154. }
  5155. function parentNode (node) {
  5156. return node.parentNode
  5157. }
  5158. function nextSibling (node) {
  5159. return node.nextSibling
  5160. }
  5161. function tagName (node) {
  5162. return node.tagName
  5163. }
  5164. function setTextContent (node, text) {
  5165. node.textContent = text;
  5166. }
  5167. function setStyleScope (node, scopeId) {
  5168. node.setAttribute(scopeId, '');
  5169. }
  5170. var nodeOps = /*#__PURE__*/Object.freeze({
  5171. createElement: createElement$1,
  5172. createElementNS: createElementNS,
  5173. createTextNode: createTextNode,
  5174. createComment: createComment,
  5175. insertBefore: insertBefore,
  5176. removeChild: removeChild,
  5177. appendChild: appendChild,
  5178. parentNode: parentNode,
  5179. nextSibling: nextSibling,
  5180. tagName: tagName,
  5181. setTextContent: setTextContent,
  5182. setStyleScope: setStyleScope
  5183. });
  5184. /* */
  5185. var ref = {
  5186. create (_, vnode) {
  5187. registerRef(vnode);
  5188. },
  5189. update (oldVnode, vnode) {
  5190. if (oldVnode.data.ref !== vnode.data.ref) {
  5191. registerRef(oldVnode, true);
  5192. registerRef(vnode);
  5193. }
  5194. },
  5195. destroy (vnode) {
  5196. registerRef(vnode, true);
  5197. }
  5198. };
  5199. function registerRef (vnode, isRemoval) {
  5200. const key = vnode.data.ref;
  5201. if (!isDef(key)) return
  5202. const vm = vnode.context;
  5203. const ref = vnode.componentInstance || vnode.elm;
  5204. const refs = vm.$refs;
  5205. if (isRemoval) {
  5206. if (Array.isArray(refs[key])) {
  5207. remove(refs[key], ref);
  5208. } else if (refs[key] === ref) {
  5209. refs[key] = undefined;
  5210. }
  5211. } else {
  5212. if (vnode.data.refInFor) {
  5213. if (!Array.isArray(refs[key])) {
  5214. refs[key] = [ref];
  5215. } else if (refs[key].indexOf(ref) < 0) {
  5216. // $flow-disable-line
  5217. refs[key].push(ref);
  5218. }
  5219. } else {
  5220. refs[key] = ref;
  5221. }
  5222. }
  5223. }
  5224. /**
  5225. * Virtual DOM patching algorithm based on Snabbdom by
  5226. * Simon Friis Vindum (@paldepind)
  5227. * Licensed under the MIT License
  5228. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  5229. *
  5230. * modified by Evan You (@yyx990803)
  5231. *
  5232. * Not type-checking this because this file is perf-critical and the cost
  5233. * of making flow understand it is not worth it.
  5234. */
  5235. const emptyNode = new VNode('', {}, []);
  5236. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  5237. function sameVnode (a, b) {
  5238. return (
  5239. a.key === b.key && (
  5240. (
  5241. a.tag === b.tag &&
  5242. a.isComment === b.isComment &&
  5243. isDef(a.data) === isDef(b.data) &&
  5244. sameInputType(a, b)
  5245. ) || (
  5246. isTrue(a.isAsyncPlaceholder) &&
  5247. a.asyncFactory === b.asyncFactory &&
  5248. isUndef(b.asyncFactory.error)
  5249. )
  5250. )
  5251. )
  5252. }
  5253. function sameInputType (a, b) {
  5254. if (a.tag !== 'input') return true
  5255. let i;
  5256. const typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  5257. const typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  5258. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  5259. }
  5260. function createKeyToOldIdx (children, beginIdx, endIdx) {
  5261. let i, key;
  5262. const map = {};
  5263. for (i = beginIdx; i <= endIdx; ++i) {
  5264. key = children[i].key;
  5265. if (isDef(key)) map[key] = i;
  5266. }
  5267. return map
  5268. }
  5269. function createPatchFunction (backend) {
  5270. let i, j;
  5271. const cbs = {};
  5272. const { modules, nodeOps } = backend;
  5273. for (i = 0; i < hooks.length; ++i) {
  5274. cbs[hooks[i]] = [];
  5275. for (j = 0; j < modules.length; ++j) {
  5276. if (isDef(modules[j][hooks[i]])) {
  5277. cbs[hooks[i]].push(modules[j][hooks[i]]);
  5278. }
  5279. }
  5280. }
  5281. function emptyNodeAt (elm) {
  5282. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  5283. }
  5284. function createRmCb (childElm, listeners) {
  5285. function remove$$1 () {
  5286. if (--remove$$1.listeners === 0) {
  5287. removeNode(childElm);
  5288. }
  5289. }
  5290. remove$$1.listeners = listeners;
  5291. return remove$$1
  5292. }
  5293. function removeNode (el) {
  5294. const parent = nodeOps.parentNode(el);
  5295. // element may have already been removed due to v-html / v-text
  5296. if (isDef(parent)) {
  5297. nodeOps.removeChild(parent, el);
  5298. }
  5299. }
  5300. function isUnknownElement$$1 (vnode, inVPre) {
  5301. return (
  5302. !inVPre &&
  5303. !vnode.ns &&
  5304. !(
  5305. config.ignoredElements.length &&
  5306. config.ignoredElements.some(ignore => {
  5307. return isRegExp(ignore)
  5308. ? ignore.test(vnode.tag)
  5309. : ignore === vnode.tag
  5310. })
  5311. ) &&
  5312. config.isUnknownElement(vnode.tag)
  5313. )
  5314. }
  5315. let creatingElmInVPre = 0;
  5316. function createElm (
  5317. vnode,
  5318. insertedVnodeQueue,
  5319. parentElm,
  5320. refElm,
  5321. nested,
  5322. ownerArray,
  5323. index
  5324. ) {
  5325. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5326. // This vnode was used in a previous render!
  5327. // now it's used as a new node, overwriting its elm would cause
  5328. // potential patch errors down the road when it's used as an insertion
  5329. // reference node. Instead, we clone the node on-demand before creating
  5330. // associated DOM element for it.
  5331. vnode = ownerArray[index] = cloneVNode(vnode);
  5332. }
  5333. vnode.isRootInsert = !nested; // for transition enter check
  5334. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  5335. return
  5336. }
  5337. const data = vnode.data;
  5338. const children = vnode.children;
  5339. const tag = vnode.tag;
  5340. if (isDef(tag)) {
  5341. {
  5342. if (data && data.pre) {
  5343. creatingElmInVPre++;
  5344. }
  5345. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  5346. warn(
  5347. 'Unknown custom element: <' + tag + '> - did you ' +
  5348. 'register the component correctly? For recursive components, ' +
  5349. 'make sure to provide the "name" option.',
  5350. vnode.context
  5351. );
  5352. }
  5353. }
  5354. vnode.elm = vnode.ns
  5355. ? nodeOps.createElementNS(vnode.ns, tag)
  5356. : nodeOps.createElement(tag, vnode);
  5357. setScope(vnode);
  5358. /* istanbul ignore if */
  5359. {
  5360. createChildren(vnode, children, insertedVnodeQueue);
  5361. if (isDef(data)) {
  5362. invokeCreateHooks(vnode, insertedVnodeQueue);
  5363. }
  5364. insert(parentElm, vnode.elm, refElm);
  5365. }
  5366. if (data && data.pre) {
  5367. creatingElmInVPre--;
  5368. }
  5369. } else if (isTrue(vnode.isComment)) {
  5370. vnode.elm = nodeOps.createComment(vnode.text);
  5371. insert(parentElm, vnode.elm, refElm);
  5372. } else {
  5373. vnode.elm = nodeOps.createTextNode(vnode.text);
  5374. insert(parentElm, vnode.elm, refElm);
  5375. }
  5376. }
  5377. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5378. let i = vnode.data;
  5379. if (isDef(i)) {
  5380. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  5381. if (isDef(i = i.hook) && isDef(i = i.init)) {
  5382. i(vnode, false /* hydrating */);
  5383. }
  5384. // after calling the init hook, if the vnode is a child component
  5385. // it should've created a child instance and mounted it. the child
  5386. // component also has set the placeholder vnode's elm.
  5387. // in that case we can just return the element and be done.
  5388. if (isDef(vnode.componentInstance)) {
  5389. initComponent(vnode, insertedVnodeQueue);
  5390. insert(parentElm, vnode.elm, refElm);
  5391. if (isTrue(isReactivated)) {
  5392. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  5393. }
  5394. return true
  5395. }
  5396. }
  5397. }
  5398. function initComponent (vnode, insertedVnodeQueue) {
  5399. if (isDef(vnode.data.pendingInsert)) {
  5400. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  5401. vnode.data.pendingInsert = null;
  5402. }
  5403. vnode.elm = vnode.componentInstance.$el;
  5404. if (isPatchable(vnode)) {
  5405. invokeCreateHooks(vnode, insertedVnodeQueue);
  5406. setScope(vnode);
  5407. } else {
  5408. // empty component root.
  5409. // skip all element-related modules except for ref (#3455)
  5410. registerRef(vnode);
  5411. // make sure to invoke the insert hook
  5412. insertedVnodeQueue.push(vnode);
  5413. }
  5414. }
  5415. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5416. let i;
  5417. // hack for #4339: a reactivated component with inner transition
  5418. // does not trigger because the inner node's created hooks are not called
  5419. // again. It's not ideal to involve module-specific logic in here but
  5420. // there doesn't seem to be a better way to do it.
  5421. let innerNode = vnode;
  5422. while (innerNode.componentInstance) {
  5423. innerNode = innerNode.componentInstance._vnode;
  5424. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  5425. for (i = 0; i < cbs.activate.length; ++i) {
  5426. cbs.activate[i](emptyNode, innerNode);
  5427. }
  5428. insertedVnodeQueue.push(innerNode);
  5429. break
  5430. }
  5431. }
  5432. // unlike a newly created component,
  5433. // a reactivated keep-alive component doesn't insert itself
  5434. insert(parentElm, vnode.elm, refElm);
  5435. }
  5436. function insert (parent, elm, ref$$1) {
  5437. if (isDef(parent)) {
  5438. if (isDef(ref$$1)) {
  5439. if (nodeOps.parentNode(ref$$1) === parent) {
  5440. nodeOps.insertBefore(parent, elm, ref$$1);
  5441. }
  5442. } else {
  5443. nodeOps.appendChild(parent, elm);
  5444. }
  5445. }
  5446. }
  5447. function createChildren (vnode, children, insertedVnodeQueue) {
  5448. if (Array.isArray(children)) {
  5449. {
  5450. checkDuplicateKeys(children);
  5451. }
  5452. for (let i = 0; i < children.length; ++i) {
  5453. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  5454. }
  5455. } else if (isPrimitive(vnode.text)) {
  5456. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  5457. }
  5458. }
  5459. function isPatchable (vnode) {
  5460. while (vnode.componentInstance) {
  5461. vnode = vnode.componentInstance._vnode;
  5462. }
  5463. return isDef(vnode.tag)
  5464. }
  5465. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  5466. for (let i = 0; i < cbs.create.length; ++i) {
  5467. cbs.create[i](emptyNode, vnode);
  5468. }
  5469. i = vnode.data.hook; // Reuse variable
  5470. if (isDef(i)) {
  5471. if (isDef(i.create)) i.create(emptyNode, vnode);
  5472. if (isDef(i.insert)) insertedVnodeQueue.push(vnode);
  5473. }
  5474. }
  5475. // set scope id attribute for scoped CSS.
  5476. // this is implemented as a special case to avoid the overhead
  5477. // of going through the normal attribute patching process.
  5478. function setScope (vnode) {
  5479. let i;
  5480. if (isDef(i = vnode.fnScopeId)) {
  5481. nodeOps.setStyleScope(vnode.elm, i);
  5482. } else {
  5483. let ancestor = vnode;
  5484. while (ancestor) {
  5485. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  5486. nodeOps.setStyleScope(vnode.elm, i);
  5487. }
  5488. ancestor = ancestor.parent;
  5489. }
  5490. }
  5491. // for slot content they should also get the scopeId from the host instance.
  5492. if (isDef(i = activeInstance) &&
  5493. i !== vnode.context &&
  5494. i !== vnode.fnContext &&
  5495. isDef(i = i.$options._scopeId)
  5496. ) {
  5497. nodeOps.setStyleScope(vnode.elm, i);
  5498. }
  5499. }
  5500. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  5501. for (; startIdx <= endIdx; ++startIdx) {
  5502. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  5503. }
  5504. }
  5505. function invokeDestroyHook (vnode) {
  5506. let i, j;
  5507. const data = vnode.data;
  5508. if (isDef(data)) {
  5509. if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode);
  5510. for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode);
  5511. }
  5512. if (isDef(i = vnode.children)) {
  5513. for (j = 0; j < vnode.children.length; ++j) {
  5514. invokeDestroyHook(vnode.children[j]);
  5515. }
  5516. }
  5517. }
  5518. function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
  5519. for (; startIdx <= endIdx; ++startIdx) {
  5520. const ch = vnodes[startIdx];
  5521. if (isDef(ch)) {
  5522. if (isDef(ch.tag)) {
  5523. removeAndInvokeRemoveHook(ch);
  5524. invokeDestroyHook(ch);
  5525. } else { // Text node
  5526. removeNode(ch.elm);
  5527. }
  5528. }
  5529. }
  5530. }
  5531. function removeAndInvokeRemoveHook (vnode, rm) {
  5532. if (isDef(rm) || isDef(vnode.data)) {
  5533. let i;
  5534. const listeners = cbs.remove.length + 1;
  5535. if (isDef(rm)) {
  5536. // we have a recursively passed down rm callback
  5537. // increase the listeners count
  5538. rm.listeners += listeners;
  5539. } else {
  5540. // directly removing
  5541. rm = createRmCb(vnode.elm, listeners);
  5542. }
  5543. // recursively invoke hooks on child component root node
  5544. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  5545. removeAndInvokeRemoveHook(i, rm);
  5546. }
  5547. for (i = 0; i < cbs.remove.length; ++i) {
  5548. cbs.remove[i](vnode, rm);
  5549. }
  5550. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  5551. i(vnode, rm);
  5552. } else {
  5553. rm();
  5554. }
  5555. } else {
  5556. removeNode(vnode.elm);
  5557. }
  5558. }
  5559. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  5560. let oldStartIdx = 0;
  5561. let newStartIdx = 0;
  5562. let oldEndIdx = oldCh.length - 1;
  5563. let oldStartVnode = oldCh[0];
  5564. let oldEndVnode = oldCh[oldEndIdx];
  5565. let newEndIdx = newCh.length - 1;
  5566. let newStartVnode = newCh[0];
  5567. let newEndVnode = newCh[newEndIdx];
  5568. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  5569. // removeOnly is a special flag used only by <transition-group>
  5570. // to ensure removed elements stay in correct relative positions
  5571. // during leaving transitions
  5572. const canMove = !removeOnly;
  5573. {
  5574. checkDuplicateKeys(newCh);
  5575. }
  5576. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  5577. if (isUndef(oldStartVnode)) {
  5578. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  5579. } else if (isUndef(oldEndVnode)) {
  5580. oldEndVnode = oldCh[--oldEndIdx];
  5581. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  5582. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5583. oldStartVnode = oldCh[++oldStartIdx];
  5584. newStartVnode = newCh[++newStartIdx];
  5585. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  5586. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5587. oldEndVnode = oldCh[--oldEndIdx];
  5588. newEndVnode = newCh[--newEndIdx];
  5589. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  5590. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5591. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  5592. oldStartVnode = oldCh[++oldStartIdx];
  5593. newEndVnode = newCh[--newEndIdx];
  5594. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  5595. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5596. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  5597. oldEndVnode = oldCh[--oldEndIdx];
  5598. newStartVnode = newCh[++newStartIdx];
  5599. } else {
  5600. if (isUndef(oldKeyToIdx)) oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  5601. idxInOld = isDef(newStartVnode.key)
  5602. ? oldKeyToIdx[newStartVnode.key]
  5603. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  5604. if (isUndef(idxInOld)) { // New element
  5605. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5606. } else {
  5607. vnodeToMove = oldCh[idxInOld];
  5608. if (sameVnode(vnodeToMove, newStartVnode)) {
  5609. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5610. oldCh[idxInOld] = undefined;
  5611. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  5612. } else {
  5613. // same key but different element. treat as new element
  5614. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5615. }
  5616. }
  5617. newStartVnode = newCh[++newStartIdx];
  5618. }
  5619. }
  5620. if (oldStartIdx > oldEndIdx) {
  5621. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  5622. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  5623. } else if (newStartIdx > newEndIdx) {
  5624. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  5625. }
  5626. }
  5627. function checkDuplicateKeys (children) {
  5628. const seenKeys = {};
  5629. for (let i = 0; i < children.length; i++) {
  5630. const vnode = children[i];
  5631. const key = vnode.key;
  5632. if (isDef(key)) {
  5633. if (seenKeys[key]) {
  5634. warn(
  5635. `Duplicate keys detected: '${key}'. This may cause an update error.`,
  5636. vnode.context
  5637. );
  5638. } else {
  5639. seenKeys[key] = true;
  5640. }
  5641. }
  5642. }
  5643. }
  5644. function findIdxInOld (node, oldCh, start, end) {
  5645. for (let i = start; i < end; i++) {
  5646. const c = oldCh[i];
  5647. if (isDef(c) && sameVnode(node, c)) return i
  5648. }
  5649. }
  5650. function patchVnode (
  5651. oldVnode,
  5652. vnode,
  5653. insertedVnodeQueue,
  5654. ownerArray,
  5655. index,
  5656. removeOnly
  5657. ) {
  5658. if (oldVnode === vnode) {
  5659. return
  5660. }
  5661. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5662. // clone reused vnode
  5663. vnode = ownerArray[index] = cloneVNode(vnode);
  5664. }
  5665. const elm = vnode.elm = oldVnode.elm;
  5666. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  5667. if (isDef(vnode.asyncFactory.resolved)) {
  5668. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  5669. } else {
  5670. vnode.isAsyncPlaceholder = true;
  5671. }
  5672. return
  5673. }
  5674. // reuse element for static trees.
  5675. // note we only do this if the vnode is cloned -
  5676. // if the new node is not cloned it means the render functions have been
  5677. // reset by the hot-reload-api and we need to do a proper re-render.
  5678. if (isTrue(vnode.isStatic) &&
  5679. isTrue(oldVnode.isStatic) &&
  5680. vnode.key === oldVnode.key &&
  5681. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  5682. ) {
  5683. vnode.componentInstance = oldVnode.componentInstance;
  5684. return
  5685. }
  5686. let i;
  5687. const data = vnode.data;
  5688. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  5689. i(oldVnode, vnode);
  5690. }
  5691. const oldCh = oldVnode.children;
  5692. const ch = vnode.children;
  5693. if (isDef(data) && isPatchable(vnode)) {
  5694. for (i = 0; i < cbs.update.length; ++i) cbs.update[i](oldVnode, vnode);
  5695. if (isDef(i = data.hook) && isDef(i = i.update)) i(oldVnode, vnode);
  5696. }
  5697. if (isUndef(vnode.text)) {
  5698. if (isDef(oldCh) && isDef(ch)) {
  5699. if (oldCh !== ch) updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  5700. } else if (isDef(ch)) {
  5701. {
  5702. checkDuplicateKeys(ch);
  5703. }
  5704. if (isDef(oldVnode.text)) nodeOps.setTextContent(elm, '');
  5705. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  5706. } else if (isDef(oldCh)) {
  5707. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  5708. } else if (isDef(oldVnode.text)) {
  5709. nodeOps.setTextContent(elm, '');
  5710. }
  5711. } else if (oldVnode.text !== vnode.text) {
  5712. nodeOps.setTextContent(elm, vnode.text);
  5713. }
  5714. if (isDef(data)) {
  5715. if (isDef(i = data.hook) && isDef(i = i.postpatch)) i(oldVnode, vnode);
  5716. }
  5717. }
  5718. function invokeInsertHook (vnode, queue, initial) {
  5719. // delay insert hooks for component root nodes, invoke them after the
  5720. // element is really inserted
  5721. if (isTrue(initial) && isDef(vnode.parent)) {
  5722. vnode.parent.data.pendingInsert = queue;
  5723. } else {
  5724. for (let i = 0; i < queue.length; ++i) {
  5725. queue[i].data.hook.insert(queue[i]);
  5726. }
  5727. }
  5728. }
  5729. let hydrationBailed = false;
  5730. // list of modules that can skip create hook during hydration because they
  5731. // are already rendered on the client or has no need for initialization
  5732. // Note: style is excluded because it relies on initial clone for future
  5733. // deep updates (#7063).
  5734. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  5735. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  5736. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  5737. let i;
  5738. const { tag, data, children } = vnode;
  5739. inVPre = inVPre || (data && data.pre);
  5740. vnode.elm = elm;
  5741. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  5742. vnode.isAsyncPlaceholder = true;
  5743. return true
  5744. }
  5745. // assert node match
  5746. {
  5747. if (!assertNodeMatch(elm, vnode, inVPre)) {
  5748. return false
  5749. }
  5750. }
  5751. if (isDef(data)) {
  5752. if (isDef(i = data.hook) && isDef(i = i.init)) i(vnode, true /* hydrating */);
  5753. if (isDef(i = vnode.componentInstance)) {
  5754. // child component. it should have hydrated its own tree.
  5755. initComponent(vnode, insertedVnodeQueue);
  5756. return true
  5757. }
  5758. }
  5759. if (isDef(tag)) {
  5760. if (isDef(children)) {
  5761. // empty element, allow client to pick up and populate children
  5762. if (!elm.hasChildNodes()) {
  5763. createChildren(vnode, children, insertedVnodeQueue);
  5764. } else {
  5765. // v-html and domProps: innerHTML
  5766. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  5767. if (i !== elm.innerHTML) {
  5768. /* istanbul ignore if */
  5769. if (typeof console !== 'undefined' &&
  5770. !hydrationBailed
  5771. ) {
  5772. hydrationBailed = true;
  5773. console.warn('Parent: ', elm);
  5774. console.warn('server innerHTML: ', i);
  5775. console.warn('client innerHTML: ', elm.innerHTML);
  5776. }
  5777. return false
  5778. }
  5779. } else {
  5780. // iterate and compare children lists
  5781. let childrenMatch = true;
  5782. let childNode = elm.firstChild;
  5783. for (let i = 0; i < children.length; i++) {
  5784. if (!childNode || !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  5785. childrenMatch = false;
  5786. break
  5787. }
  5788. childNode = childNode.nextSibling;
  5789. }
  5790. // if childNode is not null, it means the actual childNodes list is
  5791. // longer than the virtual children list.
  5792. if (!childrenMatch || childNode) {
  5793. /* istanbul ignore if */
  5794. if (typeof console !== 'undefined' &&
  5795. !hydrationBailed
  5796. ) {
  5797. hydrationBailed = true;
  5798. console.warn('Parent: ', elm);
  5799. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  5800. }
  5801. return false
  5802. }
  5803. }
  5804. }
  5805. }
  5806. if (isDef(data)) {
  5807. let fullInvoke = false;
  5808. for (const key in data) {
  5809. if (!isRenderedModule(key)) {
  5810. fullInvoke = true;
  5811. invokeCreateHooks(vnode, insertedVnodeQueue);
  5812. break
  5813. }
  5814. }
  5815. if (!fullInvoke && data['class']) {
  5816. // ensure collecting deps for deep class bindings for future updates
  5817. traverse(data['class']);
  5818. }
  5819. }
  5820. } else if (elm.data !== vnode.text) {
  5821. elm.data = vnode.text;
  5822. }
  5823. return true
  5824. }
  5825. function assertNodeMatch (node, vnode, inVPre) {
  5826. if (isDef(vnode.tag)) {
  5827. return vnode.tag.indexOf('vue-component') === 0 || (
  5828. !isUnknownElement$$1(vnode, inVPre) &&
  5829. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  5830. )
  5831. } else {
  5832. return node.nodeType === (vnode.isComment ? 8 : 3)
  5833. }
  5834. }
  5835. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  5836. if (isUndef(vnode)) {
  5837. if (isDef(oldVnode)) invokeDestroyHook(oldVnode);
  5838. return
  5839. }
  5840. let isInitialPatch = false;
  5841. const insertedVnodeQueue = [];
  5842. if (isUndef(oldVnode)) {
  5843. // empty mount (likely as component), create new root element
  5844. isInitialPatch = true;
  5845. createElm(vnode, insertedVnodeQueue);
  5846. } else {
  5847. const isRealElement = isDef(oldVnode.nodeType);
  5848. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  5849. // patch existing root node
  5850. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  5851. } else {
  5852. if (isRealElement) {
  5853. // mounting to a real element
  5854. // check if this is server-rendered content and if we can perform
  5855. // a successful hydration.
  5856. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  5857. oldVnode.removeAttribute(SSR_ATTR);
  5858. hydrating = true;
  5859. }
  5860. if (isTrue(hydrating)) {
  5861. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  5862. invokeInsertHook(vnode, insertedVnodeQueue, true);
  5863. return oldVnode
  5864. } else {
  5865. warn(
  5866. 'The client-side rendered virtual DOM tree is not matching ' +
  5867. 'server-rendered content. This is likely caused by incorrect ' +
  5868. 'HTML markup, for example nesting block-level elements inside ' +
  5869. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  5870. 'full client-side render.'
  5871. );
  5872. }
  5873. }
  5874. // either not server-rendered, or hydration failed.
  5875. // create an empty node and replace it
  5876. oldVnode = emptyNodeAt(oldVnode);
  5877. }
  5878. // replacing existing element
  5879. const oldElm = oldVnode.elm;
  5880. const parentElm = nodeOps.parentNode(oldElm);
  5881. // create new node
  5882. createElm(
  5883. vnode,
  5884. insertedVnodeQueue,
  5885. // extremely rare edge case: do not insert if old element is in a
  5886. // leaving transition. Only happens when combining transition +
  5887. // keep-alive + HOCs. (#4590)
  5888. oldElm._leaveCb ? null : parentElm,
  5889. nodeOps.nextSibling(oldElm)
  5890. );
  5891. // update parent placeholder node element, recursively
  5892. if (isDef(vnode.parent)) {
  5893. let ancestor = vnode.parent;
  5894. const patchable = isPatchable(vnode);
  5895. while (ancestor) {
  5896. for (let i = 0; i < cbs.destroy.length; ++i) {
  5897. cbs.destroy[i](ancestor);
  5898. }
  5899. ancestor.elm = vnode.elm;
  5900. if (patchable) {
  5901. for (let i = 0; i < cbs.create.length; ++i) {
  5902. cbs.create[i](emptyNode, ancestor);
  5903. }
  5904. // #6513
  5905. // invoke insert hooks that may have been merged by create hooks.
  5906. // e.g. for directives that uses the "inserted" hook.
  5907. const insert = ancestor.data.hook.insert;
  5908. if (insert.merged) {
  5909. // start at index 1 to avoid re-invoking component mounted hook
  5910. for (let i = 1; i < insert.fns.length; i++) {
  5911. insert.fns[i]();
  5912. }
  5913. }
  5914. } else {
  5915. registerRef(ancestor);
  5916. }
  5917. ancestor = ancestor.parent;
  5918. }
  5919. }
  5920. // destroy old node
  5921. if (isDef(parentElm)) {
  5922. removeVnodes(parentElm, [oldVnode], 0, 0);
  5923. } else if (isDef(oldVnode.tag)) {
  5924. invokeDestroyHook(oldVnode);
  5925. }
  5926. }
  5927. }
  5928. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  5929. return vnode.elm
  5930. }
  5931. }
  5932. /* */
  5933. var directives = {
  5934. create: updateDirectives,
  5935. update: updateDirectives,
  5936. destroy: function unbindDirectives (vnode) {
  5937. updateDirectives(vnode, emptyNode);
  5938. }
  5939. };
  5940. function updateDirectives (oldVnode, vnode) {
  5941. if (oldVnode.data.directives || vnode.data.directives) {
  5942. _update(oldVnode, vnode);
  5943. }
  5944. }
  5945. function _update (oldVnode, vnode) {
  5946. const isCreate = oldVnode === emptyNode;
  5947. const isDestroy = vnode === emptyNode;
  5948. const oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  5949. const newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  5950. const dirsWithInsert = [];
  5951. const dirsWithPostpatch = [];
  5952. let key, oldDir, dir;
  5953. for (key in newDirs) {
  5954. oldDir = oldDirs[key];
  5955. dir = newDirs[key];
  5956. if (!oldDir) {
  5957. // new directive, bind
  5958. callHook$1(dir, 'bind', vnode, oldVnode);
  5959. if (dir.def && dir.def.inserted) {
  5960. dirsWithInsert.push(dir);
  5961. }
  5962. } else {
  5963. // existing directive, update
  5964. dir.oldValue = oldDir.value;
  5965. dir.oldArg = oldDir.arg;
  5966. callHook$1(dir, 'update', vnode, oldVnode);
  5967. if (dir.def && dir.def.componentUpdated) {
  5968. dirsWithPostpatch.push(dir);
  5969. }
  5970. }
  5971. }
  5972. if (dirsWithInsert.length) {
  5973. const callInsert = () => {
  5974. for (let i = 0; i < dirsWithInsert.length; i++) {
  5975. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  5976. }
  5977. };
  5978. if (isCreate) {
  5979. mergeVNodeHook(vnode, 'insert', callInsert);
  5980. } else {
  5981. callInsert();
  5982. }
  5983. }
  5984. if (dirsWithPostpatch.length) {
  5985. mergeVNodeHook(vnode, 'postpatch', () => {
  5986. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  5987. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  5988. }
  5989. });
  5990. }
  5991. if (!isCreate) {
  5992. for (key in oldDirs) {
  5993. if (!newDirs[key]) {
  5994. // no longer present, unbind
  5995. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  5996. }
  5997. }
  5998. }
  5999. }
  6000. const emptyModifiers = Object.create(null);
  6001. function normalizeDirectives$1 (
  6002. dirs,
  6003. vm
  6004. ) {
  6005. const res = Object.create(null);
  6006. if (!dirs) {
  6007. // $flow-disable-line
  6008. return res
  6009. }
  6010. let i, dir;
  6011. for (i = 0; i < dirs.length; i++) {
  6012. dir = dirs[i];
  6013. if (!dir.modifiers) {
  6014. // $flow-disable-line
  6015. dir.modifiers = emptyModifiers;
  6016. }
  6017. res[getRawDirName(dir)] = dir;
  6018. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  6019. }
  6020. // $flow-disable-line
  6021. return res
  6022. }
  6023. function getRawDirName (dir) {
  6024. return dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`
  6025. }
  6026. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  6027. const fn = dir.def && dir.def[hook];
  6028. if (fn) {
  6029. try {
  6030. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  6031. } catch (e) {
  6032. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  6033. }
  6034. }
  6035. }
  6036. var baseModules = [
  6037. ref,
  6038. directives
  6039. ];
  6040. /* */
  6041. function updateAttrs (oldVnode, vnode) {
  6042. const opts = vnode.componentOptions;
  6043. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  6044. return
  6045. }
  6046. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  6047. return
  6048. }
  6049. let key, cur, old;
  6050. const elm = vnode.elm;
  6051. const oldAttrs = oldVnode.data.attrs || {};
  6052. let attrs = vnode.data.attrs || {};
  6053. // clone observed objects, as the user probably wants to mutate it
  6054. if (isDef(attrs.__ob__)) {
  6055. attrs = vnode.data.attrs = extend({}, attrs);
  6056. }
  6057. for (key in attrs) {
  6058. cur = attrs[key];
  6059. old = oldAttrs[key];
  6060. if (old !== cur) {
  6061. setAttr(elm, key, cur);
  6062. }
  6063. }
  6064. // #4391: in IE9, setting type can reset value for input[type=radio]
  6065. // #6666: IE/Edge forces progress value down to 1 before setting a max
  6066. /* istanbul ignore if */
  6067. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  6068. setAttr(elm, 'value', attrs.value);
  6069. }
  6070. for (key in oldAttrs) {
  6071. if (isUndef(attrs[key])) {
  6072. if (isXlink(key)) {
  6073. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6074. } else if (!isEnumeratedAttr(key)) {
  6075. elm.removeAttribute(key);
  6076. }
  6077. }
  6078. }
  6079. }
  6080. function setAttr (el, key, value) {
  6081. if (el.tagName.indexOf('-') > -1) {
  6082. baseSetAttr(el, key, value);
  6083. } else if (isBooleanAttr(key)) {
  6084. // set attribute for blank value
  6085. // e.g. <option disabled>Select one</option>
  6086. if (isFalsyAttrValue(value)) {
  6087. el.removeAttribute(key);
  6088. } else {
  6089. // technically allowfullscreen is a boolean attribute for <iframe>,
  6090. // but Flash expects a value of "true" when used on <embed> tag
  6091. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  6092. ? 'true'
  6093. : key;
  6094. el.setAttribute(key, value);
  6095. }
  6096. } else if (isEnumeratedAttr(key)) {
  6097. el.setAttribute(key, convertEnumeratedValue(key, value));
  6098. } else if (isXlink(key)) {
  6099. if (isFalsyAttrValue(value)) {
  6100. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6101. } else {
  6102. el.setAttributeNS(xlinkNS, key, value);
  6103. }
  6104. } else {
  6105. baseSetAttr(el, key, value);
  6106. }
  6107. }
  6108. function baseSetAttr (el, key, value) {
  6109. if (isFalsyAttrValue(value)) {
  6110. el.removeAttribute(key);
  6111. } else {
  6112. // #7138: IE10 & 11 fires input event when setting placeholder on
  6113. // <textarea>... block the first input event and remove the blocker
  6114. // immediately.
  6115. /* istanbul ignore if */
  6116. if (
  6117. isIE && !isIE9 &&
  6118. el.tagName === 'TEXTAREA' &&
  6119. key === 'placeholder' && value !== '' && !el.__ieph
  6120. ) {
  6121. const blocker = e => {
  6122. e.stopImmediatePropagation();
  6123. el.removeEventListener('input', blocker);
  6124. };
  6125. el.addEventListener('input', blocker);
  6126. // $flow-disable-line
  6127. el.__ieph = true; /* IE placeholder patched */
  6128. }
  6129. el.setAttribute(key, value);
  6130. }
  6131. }
  6132. var attrs = {
  6133. create: updateAttrs,
  6134. update: updateAttrs
  6135. };
  6136. /* */
  6137. function updateClass (oldVnode, vnode) {
  6138. const el = vnode.elm;
  6139. const data = vnode.data;
  6140. const oldData = oldVnode.data;
  6141. if (
  6142. isUndef(data.staticClass) &&
  6143. isUndef(data.class) && (
  6144. isUndef(oldData) || (
  6145. isUndef(oldData.staticClass) &&
  6146. isUndef(oldData.class)
  6147. )
  6148. )
  6149. ) {
  6150. return
  6151. }
  6152. let cls = genClassForVnode(vnode);
  6153. // handle transition classes
  6154. const transitionClass = el._transitionClasses;
  6155. if (isDef(transitionClass)) {
  6156. cls = concat(cls, stringifyClass(transitionClass));
  6157. }
  6158. // set the class
  6159. if (cls !== el._prevClass) {
  6160. el.setAttribute('class', cls);
  6161. el._prevClass = cls;
  6162. }
  6163. }
  6164. var klass = {
  6165. create: updateClass,
  6166. update: updateClass
  6167. };
  6168. /* */
  6169. const validDivisionCharRE = /[\w).+\-_$\]]/;
  6170. function parseFilters (exp) {
  6171. let inSingle = false;
  6172. let inDouble = false;
  6173. let inTemplateString = false;
  6174. let inRegex = false;
  6175. let curly = 0;
  6176. let square = 0;
  6177. let paren = 0;
  6178. let lastFilterIndex = 0;
  6179. let c, prev, i, expression, filters;
  6180. for (i = 0; i < exp.length; i++) {
  6181. prev = c;
  6182. c = exp.charCodeAt(i);
  6183. if (inSingle) {
  6184. if (c === 0x27 && prev !== 0x5C) inSingle = false;
  6185. } else if (inDouble) {
  6186. if (c === 0x22 && prev !== 0x5C) inDouble = false;
  6187. } else if (inTemplateString) {
  6188. if (c === 0x60 && prev !== 0x5C) inTemplateString = false;
  6189. } else if (inRegex) {
  6190. if (c === 0x2f && prev !== 0x5C) inRegex = false;
  6191. } else if (
  6192. c === 0x7C && // pipe
  6193. exp.charCodeAt(i + 1) !== 0x7C &&
  6194. exp.charCodeAt(i - 1) !== 0x7C &&
  6195. !curly && !square && !paren
  6196. ) {
  6197. if (expression === undefined) {
  6198. // first filter, end of expression
  6199. lastFilterIndex = i + 1;
  6200. expression = exp.slice(0, i).trim();
  6201. } else {
  6202. pushFilter();
  6203. }
  6204. } else {
  6205. switch (c) {
  6206. case 0x22: inDouble = true; break // "
  6207. case 0x27: inSingle = true; break // '
  6208. case 0x60: inTemplateString = true; break // `
  6209. case 0x28: paren++; break // (
  6210. case 0x29: paren--; break // )
  6211. case 0x5B: square++; break // [
  6212. case 0x5D: square--; break // ]
  6213. case 0x7B: curly++; break // {
  6214. case 0x7D: curly--; break // }
  6215. }
  6216. if (c === 0x2f) { // /
  6217. let j = i - 1;
  6218. let p;
  6219. // find first non-whitespace prev char
  6220. for (; j >= 0; j--) {
  6221. p = exp.charAt(j);
  6222. if (p !== ' ') break
  6223. }
  6224. if (!p || !validDivisionCharRE.test(p)) {
  6225. inRegex = true;
  6226. }
  6227. }
  6228. }
  6229. }
  6230. if (expression === undefined) {
  6231. expression = exp.slice(0, i).trim();
  6232. } else if (lastFilterIndex !== 0) {
  6233. pushFilter();
  6234. }
  6235. function pushFilter () {
  6236. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  6237. lastFilterIndex = i + 1;
  6238. }
  6239. if (filters) {
  6240. for (i = 0; i < filters.length; i++) {
  6241. expression = wrapFilter(expression, filters[i]);
  6242. }
  6243. }
  6244. return expression
  6245. }
  6246. function wrapFilter (exp, filter) {
  6247. const i = filter.indexOf('(');
  6248. if (i < 0) {
  6249. // _f: resolveFilter
  6250. return `_f("${filter}")(${exp})`
  6251. } else {
  6252. const name = filter.slice(0, i);
  6253. const args = filter.slice(i + 1);
  6254. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`
  6255. }
  6256. }
  6257. /* */
  6258. /* eslint-disable no-unused-vars */
  6259. function baseWarn (msg, range) {
  6260. console.error(`[Vue compiler]: ${msg}`);
  6261. }
  6262. /* eslint-enable no-unused-vars */
  6263. function pluckModuleFunction (
  6264. modules,
  6265. key
  6266. ) {
  6267. return modules
  6268. ? modules.map(m => m[key]).filter(_ => _)
  6269. : []
  6270. }
  6271. function addProp (el, name, value, range, dynamic) {
  6272. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  6273. el.plain = false;
  6274. }
  6275. function addAttr (el, name, value, range, dynamic) {
  6276. const attrs = dynamic
  6277. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  6278. : (el.attrs || (el.attrs = []));
  6279. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  6280. el.plain = false;
  6281. }
  6282. // add a raw attr (use this in preTransforms)
  6283. function addRawAttr (el, name, value, range) {
  6284. el.attrsMap[name] = value;
  6285. el.attrsList.push(rangeSetItem({ name, value }, range));
  6286. }
  6287. function addDirective (
  6288. el,
  6289. name,
  6290. rawName,
  6291. value,
  6292. arg,
  6293. isDynamicArg,
  6294. modifiers,
  6295. range
  6296. ) {
  6297. (el.directives || (el.directives = [])).push(rangeSetItem({
  6298. name,
  6299. rawName,
  6300. value,
  6301. arg,
  6302. isDynamicArg,
  6303. modifiers
  6304. }, range));
  6305. el.plain = false;
  6306. }
  6307. function prependModifierMarker (symbol, name, dynamic) {
  6308. return dynamic
  6309. ? `_p(${name},"${symbol}")`
  6310. : symbol + name // mark the event as captured
  6311. }
  6312. function addHandler (
  6313. el,
  6314. name,
  6315. value,
  6316. modifiers,
  6317. important,
  6318. warn,
  6319. range,
  6320. dynamic
  6321. ) {
  6322. modifiers = modifiers || emptyObject;
  6323. // warn prevent and passive modifier
  6324. /* istanbul ignore if */
  6325. if (
  6326. warn &&
  6327. modifiers.prevent && modifiers.passive
  6328. ) {
  6329. warn(
  6330. 'passive and prevent can\'t be used together. ' +
  6331. 'Passive handler can\'t prevent default event.',
  6332. range
  6333. );
  6334. }
  6335. // normalize click.right and click.middle since they don't actually fire
  6336. // this is technically browser-specific, but at least for now browsers are
  6337. // the only target envs that have right/middle clicks.
  6338. if (modifiers.right) {
  6339. if (dynamic) {
  6340. name = `(${name})==='click'?'contextmenu':(${name})`;
  6341. } else if (name === 'click') {
  6342. name = 'contextmenu';
  6343. delete modifiers.right;
  6344. }
  6345. } else if (modifiers.middle) {
  6346. if (dynamic) {
  6347. name = `(${name})==='click'?'mouseup':(${name})`;
  6348. } else if (name === 'click') {
  6349. name = 'mouseup';
  6350. }
  6351. }
  6352. // check capture modifier
  6353. if (modifiers.capture) {
  6354. delete modifiers.capture;
  6355. name = prependModifierMarker('!', name, dynamic);
  6356. }
  6357. if (modifiers.once) {
  6358. delete modifiers.once;
  6359. name = prependModifierMarker('~', name, dynamic);
  6360. }
  6361. /* istanbul ignore if */
  6362. if (modifiers.passive) {
  6363. delete modifiers.passive;
  6364. name = prependModifierMarker('&', name, dynamic);
  6365. }
  6366. let events;
  6367. if (modifiers.native) {
  6368. delete modifiers.native;
  6369. events = el.nativeEvents || (el.nativeEvents = {});
  6370. } else {
  6371. events = el.events || (el.events = {});
  6372. }
  6373. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  6374. if (modifiers !== emptyObject) {
  6375. newHandler.modifiers = modifiers;
  6376. }
  6377. const handlers = events[name];
  6378. /* istanbul ignore if */
  6379. if (Array.isArray(handlers)) {
  6380. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  6381. } else if (handlers) {
  6382. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  6383. } else {
  6384. events[name] = newHandler;
  6385. }
  6386. el.plain = false;
  6387. }
  6388. function getRawBindingAttr (
  6389. el,
  6390. name
  6391. ) {
  6392. return el.rawAttrsMap[':' + name] ||
  6393. el.rawAttrsMap['v-bind:' + name] ||
  6394. el.rawAttrsMap[name]
  6395. }
  6396. function getBindingAttr (
  6397. el,
  6398. name,
  6399. getStatic
  6400. ) {
  6401. const dynamicValue =
  6402. getAndRemoveAttr(el, ':' + name) ||
  6403. getAndRemoveAttr(el, 'v-bind:' + name);
  6404. if (dynamicValue != null) {
  6405. return parseFilters(dynamicValue)
  6406. } else if (getStatic !== false) {
  6407. const staticValue = getAndRemoveAttr(el, name);
  6408. if (staticValue != null) {
  6409. return JSON.stringify(staticValue)
  6410. }
  6411. }
  6412. }
  6413. // note: this only removes the attr from the Array (attrsList) so that it
  6414. // doesn't get processed by processAttrs.
  6415. // By default it does NOT remove it from the map (attrsMap) because the map is
  6416. // needed during codegen.
  6417. function getAndRemoveAttr (
  6418. el,
  6419. name,
  6420. removeFromMap
  6421. ) {
  6422. let val;
  6423. if ((val = el.attrsMap[name]) != null) {
  6424. const list = el.attrsList;
  6425. for (let i = 0, l = list.length; i < l; i++) {
  6426. if (list[i].name === name) {
  6427. list.splice(i, 1);
  6428. break
  6429. }
  6430. }
  6431. }
  6432. if (removeFromMap) {
  6433. delete el.attrsMap[name];
  6434. }
  6435. return val
  6436. }
  6437. function getAndRemoveAttrByRegex (
  6438. el,
  6439. name
  6440. ) {
  6441. const list = el.attrsList;
  6442. for (let i = 0, l = list.length; i < l; i++) {
  6443. const attr = list[i];
  6444. if (name.test(attr.name)) {
  6445. list.splice(i, 1);
  6446. return attr
  6447. }
  6448. }
  6449. }
  6450. function rangeSetItem (
  6451. item,
  6452. range
  6453. ) {
  6454. if (range) {
  6455. if (range.start != null) {
  6456. item.start = range.start;
  6457. }
  6458. if (range.end != null) {
  6459. item.end = range.end;
  6460. }
  6461. }
  6462. return item
  6463. }
  6464. /* */
  6465. /**
  6466. * Cross-platform code generation for component v-model
  6467. */
  6468. function genComponentModel (
  6469. el,
  6470. value,
  6471. modifiers
  6472. ) {
  6473. const { number, trim } = modifiers || {};
  6474. const baseValueExpression = '$$v';
  6475. let valueExpression = baseValueExpression;
  6476. if (trim) {
  6477. valueExpression =
  6478. `(typeof ${baseValueExpression} === 'string'` +
  6479. `? ${baseValueExpression}.trim()` +
  6480. `: ${baseValueExpression})`;
  6481. }
  6482. if (number) {
  6483. valueExpression = `_n(${valueExpression})`;
  6484. }
  6485. const assignment = genAssignmentCode(value, valueExpression);
  6486. el.model = {
  6487. value: `(${value})`,
  6488. expression: JSON.stringify(value),
  6489. callback: `function (${baseValueExpression}) {${assignment}}`
  6490. };
  6491. }
  6492. /**
  6493. * Cross-platform codegen helper for generating v-model value assignment code.
  6494. */
  6495. function genAssignmentCode (
  6496. value,
  6497. assignment
  6498. ) {
  6499. const res = parseModel(value);
  6500. if (res.key === null) {
  6501. return `${value}=${assignment}`
  6502. } else {
  6503. return `$set(${res.exp}, ${res.key}, ${assignment})`
  6504. }
  6505. }
  6506. /**
  6507. * Parse a v-model expression into a base path and a final key segment.
  6508. * Handles both dot-path and possible square brackets.
  6509. *
  6510. * Possible cases:
  6511. *
  6512. * - test
  6513. * - test[key]
  6514. * - test[test1[key]]
  6515. * - test["a"][key]
  6516. * - xxx.test[a[a].test1[key]]
  6517. * - test.xxx.a["asa"][test1[key]]
  6518. *
  6519. */
  6520. let len, str, chr, index$1, expressionPos, expressionEndPos;
  6521. function parseModel (val) {
  6522. // Fix https://github.com/vuejs/vue/pull/7730
  6523. // allow v-model="obj.val " (trailing whitespace)
  6524. val = val.trim();
  6525. len = val.length;
  6526. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6527. index$1 = val.lastIndexOf('.');
  6528. if (index$1 > -1) {
  6529. return {
  6530. exp: val.slice(0, index$1),
  6531. key: '"' + val.slice(index$1 + 1) + '"'
  6532. }
  6533. } else {
  6534. return {
  6535. exp: val,
  6536. key: null
  6537. }
  6538. }
  6539. }
  6540. str = val;
  6541. index$1 = expressionPos = expressionEndPos = 0;
  6542. while (!eof()) {
  6543. chr = next();
  6544. /* istanbul ignore if */
  6545. if (isStringStart(chr)) {
  6546. parseString(chr);
  6547. } else if (chr === 0x5B) {
  6548. parseBracket(chr);
  6549. }
  6550. }
  6551. return {
  6552. exp: val.slice(0, expressionPos),
  6553. key: val.slice(expressionPos + 1, expressionEndPos)
  6554. }
  6555. }
  6556. function next () {
  6557. return str.charCodeAt(++index$1)
  6558. }
  6559. function eof () {
  6560. return index$1 >= len
  6561. }
  6562. function isStringStart (chr) {
  6563. return chr === 0x22 || chr === 0x27
  6564. }
  6565. function parseBracket (chr) {
  6566. let inBracket = 1;
  6567. expressionPos = index$1;
  6568. while (!eof()) {
  6569. chr = next();
  6570. if (isStringStart(chr)) {
  6571. parseString(chr);
  6572. continue
  6573. }
  6574. if (chr === 0x5B) inBracket++;
  6575. if (chr === 0x5D) inBracket--;
  6576. if (inBracket === 0) {
  6577. expressionEndPos = index$1;
  6578. break
  6579. }
  6580. }
  6581. }
  6582. function parseString (chr) {
  6583. const stringQuote = chr;
  6584. while (!eof()) {
  6585. chr = next();
  6586. if (chr === stringQuote) {
  6587. break
  6588. }
  6589. }
  6590. }
  6591. /* */
  6592. let warn$1;
  6593. // in some cases, the event used has to be determined at runtime
  6594. // so we used some reserved tokens during compile.
  6595. const RANGE_TOKEN = '__r';
  6596. const CHECKBOX_RADIO_TOKEN = '__c';
  6597. function model (
  6598. el,
  6599. dir,
  6600. _warn
  6601. ) {
  6602. warn$1 = _warn;
  6603. const value = dir.value;
  6604. const modifiers = dir.modifiers;
  6605. const tag = el.tag;
  6606. const type = el.attrsMap.type;
  6607. {
  6608. // inputs with type="file" are read only and setting the input's
  6609. // value will throw an error.
  6610. if (tag === 'input' && type === 'file') {
  6611. warn$1(
  6612. `<${el.tag} v-model="${value}" type="file">:\n` +
  6613. `File inputs are read only. Use a v-on:change listener instead.`,
  6614. el.rawAttrsMap['v-model']
  6615. );
  6616. }
  6617. }
  6618. if (el.component) {
  6619. genComponentModel(el, value, modifiers);
  6620. // component v-model doesn't need extra runtime
  6621. return false
  6622. } else if (tag === 'select') {
  6623. genSelect(el, value, modifiers);
  6624. } else if (tag === 'input' && type === 'checkbox') {
  6625. genCheckboxModel(el, value, modifiers);
  6626. } else if (tag === 'input' && type === 'radio') {
  6627. genRadioModel(el, value, modifiers);
  6628. } else if (tag === 'input' || tag === 'textarea') {
  6629. genDefaultModel(el, value, modifiers);
  6630. } else if (!config.isReservedTag(tag)) {
  6631. genComponentModel(el, value, modifiers);
  6632. // component v-model doesn't need extra runtime
  6633. return false
  6634. } else {
  6635. warn$1(
  6636. `<${el.tag} v-model="${value}">: ` +
  6637. `v-model is not supported on this element type. ` +
  6638. 'If you are working with contenteditable, it\'s recommended to ' +
  6639. 'wrap a library dedicated for that purpose inside a custom component.',
  6640. el.rawAttrsMap['v-model']
  6641. );
  6642. }
  6643. // ensure runtime directive metadata
  6644. return true
  6645. }
  6646. function genCheckboxModel (
  6647. el,
  6648. value,
  6649. modifiers
  6650. ) {
  6651. const number = modifiers && modifiers.number;
  6652. const valueBinding = getBindingAttr(el, 'value') || 'null';
  6653. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  6654. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  6655. addProp(el, 'checked',
  6656. `Array.isArray(${value})` +
  6657. `?_i(${value},${valueBinding})>-1` + (
  6658. trueValueBinding === 'true'
  6659. ? `:(${value})`
  6660. : `:_q(${value},${trueValueBinding})`
  6661. )
  6662. );
  6663. addHandler(el, 'change',
  6664. `var $$a=${value},` +
  6665. '$$el=$event.target,' +
  6666. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  6667. 'if(Array.isArray($$a)){' +
  6668. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  6669. '$$i=_i($$a,$$v);' +
  6670. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  6671. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  6672. `}else{${genAssignmentCode(value, '$$c')}}`,
  6673. null, true
  6674. );
  6675. }
  6676. function genRadioModel (
  6677. el,
  6678. value,
  6679. modifiers
  6680. ) {
  6681. const number = modifiers && modifiers.number;
  6682. let valueBinding = getBindingAttr(el, 'value') || 'null';
  6683. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  6684. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  6685. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  6686. }
  6687. function genSelect (
  6688. el,
  6689. value,
  6690. modifiers
  6691. ) {
  6692. const number = modifiers && modifiers.number;
  6693. const selectedVal = `Array.prototype.filter` +
  6694. `.call($event.target.options,function(o){return o.selected})` +
  6695. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  6696. `return ${number ? '_n(val)' : 'val'}})`;
  6697. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  6698. let code = `var $$selectedVal = ${selectedVal};`;
  6699. code = `${code} ${genAssignmentCode(value, assignment)}`;
  6700. addHandler(el, 'change', code, null, true);
  6701. }
  6702. function genDefaultModel (
  6703. el,
  6704. value,
  6705. modifiers
  6706. ) {
  6707. const type = el.attrsMap.type;
  6708. // warn if v-bind:value conflicts with v-model
  6709. // except for inputs with v-bind:type
  6710. {
  6711. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  6712. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  6713. if (value && !typeBinding) {
  6714. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  6715. warn$1(
  6716. `${binding}="${value}" conflicts with v-model on the same element ` +
  6717. 'because the latter already expands to a value binding internally',
  6718. el.rawAttrsMap[binding]
  6719. );
  6720. }
  6721. }
  6722. const { lazy, number, trim } = modifiers || {};
  6723. const needCompositionGuard = !lazy && type !== 'range';
  6724. const event = lazy
  6725. ? 'change'
  6726. : type === 'range'
  6727. ? RANGE_TOKEN
  6728. : 'input';
  6729. let valueExpression = '$event.target.value';
  6730. if (trim) {
  6731. valueExpression = `$event.target.value.trim()`;
  6732. }
  6733. if (number) {
  6734. valueExpression = `_n(${valueExpression})`;
  6735. }
  6736. let code = genAssignmentCode(value, valueExpression);
  6737. if (needCompositionGuard) {
  6738. code = `if($event.target.composing)return;${code}`;
  6739. }
  6740. addProp(el, 'value', `(${value})`);
  6741. addHandler(el, event, code, null, true);
  6742. if (trim || number) {
  6743. addHandler(el, 'blur', '$forceUpdate()');
  6744. }
  6745. }
  6746. /* */
  6747. // normalize v-model event tokens that can only be determined at runtime.
  6748. // it's important to place the event as the first in the array because
  6749. // the whole point is ensuring the v-model callback gets called before
  6750. // user-attached handlers.
  6751. function normalizeEvents (on) {
  6752. /* istanbul ignore if */
  6753. if (isDef(on[RANGE_TOKEN])) {
  6754. // IE input[type=range] only supports `change` event
  6755. const event = isIE ? 'change' : 'input';
  6756. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  6757. delete on[RANGE_TOKEN];
  6758. }
  6759. // This was originally intended to fix #4521 but no longer necessary
  6760. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  6761. /* istanbul ignore if */
  6762. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  6763. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  6764. delete on[CHECKBOX_RADIO_TOKEN];
  6765. }
  6766. }
  6767. let target$1;
  6768. function createOnceHandler$1 (event, handler, capture) {
  6769. const _target = target$1; // save current target element in closure
  6770. return function onceHandler () {
  6771. const res = handler.apply(null, arguments);
  6772. if (res !== null) {
  6773. remove$2(event, onceHandler, capture, _target);
  6774. }
  6775. }
  6776. }
  6777. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  6778. // implementation and does not fire microtasks in between event propagation, so
  6779. // safe to exclude.
  6780. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  6781. function add$1 (
  6782. name,
  6783. handler,
  6784. capture,
  6785. passive
  6786. ) {
  6787. // async edge case #6566: inner click event triggers patch, event handler
  6788. // attached to outer element during patch, and triggered again. This
  6789. // happens because browsers fire microtask ticks between event propagation.
  6790. // the solution is simple: we save the timestamp when a handler is attached,
  6791. // and the handler would only fire if the event passed to it was fired
  6792. // AFTER it was attached.
  6793. if (useMicrotaskFix) {
  6794. const attachedTimestamp = currentFlushTimestamp;
  6795. const original = handler;
  6796. handler = original._wrapper = function (e) {
  6797. if (
  6798. // no bubbling, should always fire.
  6799. // this is just a safety net in case event.timeStamp is unreliable in
  6800. // certain weird environments...
  6801. e.target === e.currentTarget ||
  6802. // event is fired after handler attachment
  6803. e.timeStamp >= attachedTimestamp ||
  6804. // bail for environments that have buggy event.timeStamp implementations
  6805. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  6806. // #9681 QtWebEngine event.timeStamp is negative value
  6807. e.timeStamp <= 0 ||
  6808. // #9448 bail if event is fired in another document in a multi-page
  6809. // electron/nw.js app, since event.timeStamp will be using a different
  6810. // starting reference
  6811. e.target.ownerDocument !== document
  6812. ) {
  6813. return original.apply(this, arguments)
  6814. }
  6815. };
  6816. }
  6817. target$1.addEventListener(
  6818. name,
  6819. handler,
  6820. supportsPassive
  6821. ? { capture, passive }
  6822. : capture
  6823. );
  6824. }
  6825. function remove$2 (
  6826. name,
  6827. handler,
  6828. capture,
  6829. _target
  6830. ) {
  6831. (_target || target$1).removeEventListener(
  6832. name,
  6833. handler._wrapper || handler,
  6834. capture
  6835. );
  6836. }
  6837. function updateDOMListeners (oldVnode, vnode) {
  6838. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  6839. return
  6840. }
  6841. const on = vnode.data.on || {};
  6842. const oldOn = oldVnode.data.on || {};
  6843. target$1 = vnode.elm;
  6844. normalizeEvents(on);
  6845. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  6846. target$1 = undefined;
  6847. }
  6848. var events = {
  6849. create: updateDOMListeners,
  6850. update: updateDOMListeners
  6851. };
  6852. /* */
  6853. let svgContainer;
  6854. function updateDOMProps (oldVnode, vnode) {
  6855. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  6856. return
  6857. }
  6858. let key, cur;
  6859. const elm = vnode.elm;
  6860. const oldProps = oldVnode.data.domProps || {};
  6861. let props = vnode.data.domProps || {};
  6862. // clone observed objects, as the user probably wants to mutate it
  6863. if (isDef(props.__ob__)) {
  6864. props = vnode.data.domProps = extend({}, props);
  6865. }
  6866. for (key in oldProps) {
  6867. if (!(key in props)) {
  6868. elm[key] = '';
  6869. }
  6870. }
  6871. for (key in props) {
  6872. cur = props[key];
  6873. // ignore children if the node has textContent or innerHTML,
  6874. // as these will throw away existing DOM nodes and cause removal errors
  6875. // on subsequent patches (#3360)
  6876. if (key === 'textContent' || key === 'innerHTML') {
  6877. if (vnode.children) vnode.children.length = 0;
  6878. if (cur === oldProps[key]) continue
  6879. // #6601 work around Chrome version <= 55 bug where single textNode
  6880. // replaced by innerHTML/textContent retains its parentNode property
  6881. if (elm.childNodes.length === 1) {
  6882. elm.removeChild(elm.childNodes[0]);
  6883. }
  6884. }
  6885. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  6886. // store value as _value as well since
  6887. // non-string values will be stringified
  6888. elm._value = cur;
  6889. // avoid resetting cursor position when value is the same
  6890. const strCur = isUndef(cur) ? '' : String(cur);
  6891. if (shouldUpdateValue(elm, strCur)) {
  6892. elm.value = strCur;
  6893. }
  6894. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  6895. // IE doesn't support innerHTML for SVG elements
  6896. svgContainer = svgContainer || document.createElement('div');
  6897. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  6898. const svg = svgContainer.firstChild;
  6899. while (elm.firstChild) {
  6900. elm.removeChild(elm.firstChild);
  6901. }
  6902. while (svg.firstChild) {
  6903. elm.appendChild(svg.firstChild);
  6904. }
  6905. } else if (
  6906. // skip the update if old and new VDOM state is the same.
  6907. // `value` is handled separately because the DOM value may be temporarily
  6908. // out of sync with VDOM state due to focus, composition and modifiers.
  6909. // This #4521 by skipping the unnecesarry `checked` update.
  6910. cur !== oldProps[key]
  6911. ) {
  6912. // some property updates can throw
  6913. // e.g. `value` on <progress> w/ non-finite value
  6914. try {
  6915. elm[key] = cur;
  6916. } catch (e) {}
  6917. }
  6918. }
  6919. }
  6920. // check platforms/web/util/attrs.js acceptValue
  6921. function shouldUpdateValue (elm, checkVal) {
  6922. return (!elm.composing && (
  6923. elm.tagName === 'OPTION' ||
  6924. isNotInFocusAndDirty(elm, checkVal) ||
  6925. isDirtyWithModifiers(elm, checkVal)
  6926. ))
  6927. }
  6928. function isNotInFocusAndDirty (elm, checkVal) {
  6929. // return true when textbox (.number and .trim) loses focus and its value is
  6930. // not equal to the updated value
  6931. let notInFocus = true;
  6932. // #6157
  6933. // work around IE bug when accessing document.activeElement in an iframe
  6934. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  6935. return notInFocus && elm.value !== checkVal
  6936. }
  6937. function isDirtyWithModifiers (elm, newVal) {
  6938. const value = elm.value;
  6939. const modifiers = elm._vModifiers; // injected by v-model runtime
  6940. if (isDef(modifiers)) {
  6941. if (modifiers.number) {
  6942. return toNumber(value) !== toNumber(newVal)
  6943. }
  6944. if (modifiers.trim) {
  6945. return value.trim() !== newVal.trim()
  6946. }
  6947. }
  6948. return value !== newVal
  6949. }
  6950. var domProps = {
  6951. create: updateDOMProps,
  6952. update: updateDOMProps
  6953. };
  6954. /* */
  6955. const parseStyleText = cached(function (cssText) {
  6956. const res = {};
  6957. const listDelimiter = /;(?![^(]*\))/g;
  6958. const propertyDelimiter = /:(.+)/;
  6959. cssText.split(listDelimiter).forEach(function (item) {
  6960. if (item) {
  6961. const tmp = item.split(propertyDelimiter);
  6962. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  6963. }
  6964. });
  6965. return res
  6966. });
  6967. // merge static and dynamic style data on the same vnode
  6968. function normalizeStyleData (data) {
  6969. const style = normalizeStyleBinding(data.style);
  6970. // static style is pre-processed into an object during compilation
  6971. // and is always a fresh object, so it's safe to merge into it
  6972. return data.staticStyle
  6973. ? extend(data.staticStyle, style)
  6974. : style
  6975. }
  6976. // normalize possible array / string values into Object
  6977. function normalizeStyleBinding (bindingStyle) {
  6978. if (Array.isArray(bindingStyle)) {
  6979. return toObject(bindingStyle)
  6980. }
  6981. if (typeof bindingStyle === 'string') {
  6982. return parseStyleText(bindingStyle)
  6983. }
  6984. return bindingStyle
  6985. }
  6986. /**
  6987. * parent component style should be after child's
  6988. * so that parent component's style could override it
  6989. */
  6990. function getStyle (vnode, checkChild) {
  6991. const res = {};
  6992. let styleData;
  6993. if (checkChild) {
  6994. let childNode = vnode;
  6995. while (childNode.componentInstance) {
  6996. childNode = childNode.componentInstance._vnode;
  6997. if (
  6998. childNode && childNode.data &&
  6999. (styleData = normalizeStyleData(childNode.data))
  7000. ) {
  7001. extend(res, styleData);
  7002. }
  7003. }
  7004. }
  7005. if ((styleData = normalizeStyleData(vnode.data))) {
  7006. extend(res, styleData);
  7007. }
  7008. let parentNode = vnode;
  7009. while ((parentNode = parentNode.parent)) {
  7010. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7011. extend(res, styleData);
  7012. }
  7013. }
  7014. return res
  7015. }
  7016. /* */
  7017. const cssVarRE = /^--/;
  7018. const importantRE = /\s*!important$/;
  7019. const setProp = (el, name, val) => {
  7020. /* istanbul ignore if */
  7021. if (cssVarRE.test(name)) {
  7022. el.style.setProperty(name, val);
  7023. } else if (importantRE.test(val)) {
  7024. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7025. } else {
  7026. const normalizedName = normalize(name);
  7027. if (Array.isArray(val)) {
  7028. // Support values array created by autoprefixer, e.g.
  7029. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7030. // Set them one by one, and the browser will only set those it can recognize
  7031. for (let i = 0, len = val.length; i < len; i++) {
  7032. el.style[normalizedName] = val[i];
  7033. }
  7034. } else {
  7035. el.style[normalizedName] = val;
  7036. }
  7037. }
  7038. };
  7039. const vendorNames = ['Webkit', 'Moz', 'ms'];
  7040. let emptyStyle;
  7041. const normalize = cached(function (prop) {
  7042. emptyStyle = emptyStyle || document.createElement('div').style;
  7043. prop = camelize(prop);
  7044. if (prop !== 'filter' && (prop in emptyStyle)) {
  7045. return prop
  7046. }
  7047. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7048. for (let i = 0; i < vendorNames.length; i++) {
  7049. const name = vendorNames[i] + capName;
  7050. if (name in emptyStyle) {
  7051. return name
  7052. }
  7053. }
  7054. });
  7055. function updateStyle (oldVnode, vnode) {
  7056. const data = vnode.data;
  7057. const oldData = oldVnode.data;
  7058. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  7059. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  7060. ) {
  7061. return
  7062. }
  7063. let cur, name;
  7064. const el = vnode.elm;
  7065. const oldStaticStyle = oldData.staticStyle;
  7066. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  7067. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  7068. const oldStyle = oldStaticStyle || oldStyleBinding;
  7069. const style = normalizeStyleBinding(vnode.data.style) || {};
  7070. // store normalized style under a different key for next diff
  7071. // make sure to clone it if it's reactive, since the user likely wants
  7072. // to mutate it.
  7073. vnode.data.normalizedStyle = isDef(style.__ob__)
  7074. ? extend({}, style)
  7075. : style;
  7076. const newStyle = getStyle(vnode, true);
  7077. for (name in oldStyle) {
  7078. if (isUndef(newStyle[name])) {
  7079. setProp(el, name, '');
  7080. }
  7081. }
  7082. for (name in newStyle) {
  7083. cur = newStyle[name];
  7084. if (cur !== oldStyle[name]) {
  7085. // ie9 setting to null has no effect, must use empty string
  7086. setProp(el, name, cur == null ? '' : cur);
  7087. }
  7088. }
  7089. }
  7090. var style = {
  7091. create: updateStyle,
  7092. update: updateStyle
  7093. };
  7094. /* */
  7095. const whitespaceRE = /\s+/;
  7096. /**
  7097. * Add class with compatibility for SVG since classList is not supported on
  7098. * SVG elements in IE
  7099. */
  7100. function addClass (el, cls) {
  7101. /* istanbul ignore if */
  7102. if (!cls || !(cls = cls.trim())) {
  7103. return
  7104. }
  7105. /* istanbul ignore else */
  7106. if (el.classList) {
  7107. if (cls.indexOf(' ') > -1) {
  7108. cls.split(whitespaceRE).forEach(c => el.classList.add(c));
  7109. } else {
  7110. el.classList.add(cls);
  7111. }
  7112. } else {
  7113. const cur = ` ${el.getAttribute('class') || ''} `;
  7114. if (cur.indexOf(' ' + cls + ' ') < 0) {
  7115. el.setAttribute('class', (cur + cls).trim());
  7116. }
  7117. }
  7118. }
  7119. /**
  7120. * Remove class with compatibility for SVG since classList is not supported on
  7121. * SVG elements in IE
  7122. */
  7123. function removeClass (el, cls) {
  7124. /* istanbul ignore if */
  7125. if (!cls || !(cls = cls.trim())) {
  7126. return
  7127. }
  7128. /* istanbul ignore else */
  7129. if (el.classList) {
  7130. if (cls.indexOf(' ') > -1) {
  7131. cls.split(whitespaceRE).forEach(c => el.classList.remove(c));
  7132. } else {
  7133. el.classList.remove(cls);
  7134. }
  7135. if (!el.classList.length) {
  7136. el.removeAttribute('class');
  7137. }
  7138. } else {
  7139. let cur = ` ${el.getAttribute('class') || ''} `;
  7140. const tar = ' ' + cls + ' ';
  7141. while (cur.indexOf(tar) >= 0) {
  7142. cur = cur.replace(tar, ' ');
  7143. }
  7144. cur = cur.trim();
  7145. if (cur) {
  7146. el.setAttribute('class', cur);
  7147. } else {
  7148. el.removeAttribute('class');
  7149. }
  7150. }
  7151. }
  7152. /* */
  7153. function resolveTransition (def$$1) {
  7154. if (!def$$1) {
  7155. return
  7156. }
  7157. /* istanbul ignore else */
  7158. if (typeof def$$1 === 'object') {
  7159. const res = {};
  7160. if (def$$1.css !== false) {
  7161. extend(res, autoCssTransition(def$$1.name || 'v'));
  7162. }
  7163. extend(res, def$$1);
  7164. return res
  7165. } else if (typeof def$$1 === 'string') {
  7166. return autoCssTransition(def$$1)
  7167. }
  7168. }
  7169. const autoCssTransition = cached(name => {
  7170. return {
  7171. enterClass: `${name}-enter`,
  7172. enterToClass: `${name}-enter-to`,
  7173. enterActiveClass: `${name}-enter-active`,
  7174. leaveClass: `${name}-leave`,
  7175. leaveToClass: `${name}-leave-to`,
  7176. leaveActiveClass: `${name}-leave-active`
  7177. }
  7178. });
  7179. const hasTransition = inBrowser && !isIE9;
  7180. const TRANSITION = 'transition';
  7181. const ANIMATION = 'animation';
  7182. // Transition property/event sniffing
  7183. let transitionProp = 'transition';
  7184. let transitionEndEvent = 'transitionend';
  7185. let animationProp = 'animation';
  7186. let animationEndEvent = 'animationend';
  7187. if (hasTransition) {
  7188. /* istanbul ignore if */
  7189. if (window.ontransitionend === undefined &&
  7190. window.onwebkittransitionend !== undefined
  7191. ) {
  7192. transitionProp = 'WebkitTransition';
  7193. transitionEndEvent = 'webkitTransitionEnd';
  7194. }
  7195. if (window.onanimationend === undefined &&
  7196. window.onwebkitanimationend !== undefined
  7197. ) {
  7198. animationProp = 'WebkitAnimation';
  7199. animationEndEvent = 'webkitAnimationEnd';
  7200. }
  7201. }
  7202. // binding to window is necessary to make hot reload work in IE in strict mode
  7203. const raf = inBrowser
  7204. ? window.requestAnimationFrame
  7205. ? window.requestAnimationFrame.bind(window)
  7206. : setTimeout
  7207. : /* istanbul ignore next */ fn => fn();
  7208. function nextFrame (fn) {
  7209. raf(() => {
  7210. raf(fn);
  7211. });
  7212. }
  7213. function addTransitionClass (el, cls) {
  7214. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  7215. if (transitionClasses.indexOf(cls) < 0) {
  7216. transitionClasses.push(cls);
  7217. addClass(el, cls);
  7218. }
  7219. }
  7220. function removeTransitionClass (el, cls) {
  7221. if (el._transitionClasses) {
  7222. remove(el._transitionClasses, cls);
  7223. }
  7224. removeClass(el, cls);
  7225. }
  7226. function whenTransitionEnds (
  7227. el,
  7228. expectedType,
  7229. cb
  7230. ) {
  7231. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  7232. if (!type) return cb()
  7233. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  7234. let ended = 0;
  7235. const end = () => {
  7236. el.removeEventListener(event, onEnd);
  7237. cb();
  7238. };
  7239. const onEnd = e => {
  7240. if (e.target === el) {
  7241. if (++ended >= propCount) {
  7242. end();
  7243. }
  7244. }
  7245. };
  7246. setTimeout(() => {
  7247. if (ended < propCount) {
  7248. end();
  7249. }
  7250. }, timeout + 1);
  7251. el.addEventListener(event, onEnd);
  7252. }
  7253. const transformRE = /\b(transform|all)(,|$)/;
  7254. function getTransitionInfo (el, expectedType) {
  7255. const styles = window.getComputedStyle(el);
  7256. // JSDOM may return undefined for transition properties
  7257. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  7258. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  7259. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  7260. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  7261. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  7262. const animationTimeout = getTimeout(animationDelays, animationDurations);
  7263. let type;
  7264. let timeout = 0;
  7265. let propCount = 0;
  7266. /* istanbul ignore if */
  7267. if (expectedType === TRANSITION) {
  7268. if (transitionTimeout > 0) {
  7269. type = TRANSITION;
  7270. timeout = transitionTimeout;
  7271. propCount = transitionDurations.length;
  7272. }
  7273. } else if (expectedType === ANIMATION) {
  7274. if (animationTimeout > 0) {
  7275. type = ANIMATION;
  7276. timeout = animationTimeout;
  7277. propCount = animationDurations.length;
  7278. }
  7279. } else {
  7280. timeout = Math.max(transitionTimeout, animationTimeout);
  7281. type = timeout > 0
  7282. ? transitionTimeout > animationTimeout
  7283. ? TRANSITION
  7284. : ANIMATION
  7285. : null;
  7286. propCount = type
  7287. ? type === TRANSITION
  7288. ? transitionDurations.length
  7289. : animationDurations.length
  7290. : 0;
  7291. }
  7292. const hasTransform =
  7293. type === TRANSITION &&
  7294. transformRE.test(styles[transitionProp + 'Property']);
  7295. return {
  7296. type,
  7297. timeout,
  7298. propCount,
  7299. hasTransform
  7300. }
  7301. }
  7302. function getTimeout (delays, durations) {
  7303. /* istanbul ignore next */
  7304. while (delays.length < durations.length) {
  7305. delays = delays.concat(delays);
  7306. }
  7307. return Math.max.apply(null, durations.map((d, i) => {
  7308. return toMs(d) + toMs(delays[i])
  7309. }))
  7310. }
  7311. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  7312. // in a locale-dependent way, using a comma instead of a dot.
  7313. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  7314. // as a floor function) causing unexpected behaviors
  7315. function toMs (s) {
  7316. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  7317. }
  7318. /* */
  7319. function enter (vnode, toggleDisplay) {
  7320. const el = vnode.elm;
  7321. // call leave callback now
  7322. if (isDef(el._leaveCb)) {
  7323. el._leaveCb.cancelled = true;
  7324. el._leaveCb();
  7325. }
  7326. const data = resolveTransition(vnode.data.transition);
  7327. if (isUndef(data)) {
  7328. return
  7329. }
  7330. /* istanbul ignore if */
  7331. if (isDef(el._enterCb) || el.nodeType !== 1) {
  7332. return
  7333. }
  7334. const {
  7335. css,
  7336. type,
  7337. enterClass,
  7338. enterToClass,
  7339. enterActiveClass,
  7340. appearClass,
  7341. appearToClass,
  7342. appearActiveClass,
  7343. beforeEnter,
  7344. enter,
  7345. afterEnter,
  7346. enterCancelled,
  7347. beforeAppear,
  7348. appear,
  7349. afterAppear,
  7350. appearCancelled,
  7351. duration
  7352. } = data;
  7353. // activeInstance will always be the <transition> component managing this
  7354. // transition. One edge case to check is when the <transition> is placed
  7355. // as the root node of a child component. In that case we need to check
  7356. // <transition>'s parent for appear check.
  7357. let context = activeInstance;
  7358. let transitionNode = activeInstance.$vnode;
  7359. while (transitionNode && transitionNode.parent) {
  7360. context = transitionNode.context;
  7361. transitionNode = transitionNode.parent;
  7362. }
  7363. const isAppear = !context._isMounted || !vnode.isRootInsert;
  7364. if (isAppear && !appear && appear !== '') {
  7365. return
  7366. }
  7367. const startClass = isAppear && appearClass
  7368. ? appearClass
  7369. : enterClass;
  7370. const activeClass = isAppear && appearActiveClass
  7371. ? appearActiveClass
  7372. : enterActiveClass;
  7373. const toClass = isAppear && appearToClass
  7374. ? appearToClass
  7375. : enterToClass;
  7376. const beforeEnterHook = isAppear
  7377. ? (beforeAppear || beforeEnter)
  7378. : beforeEnter;
  7379. const enterHook = isAppear
  7380. ? (typeof appear === 'function' ? appear : enter)
  7381. : enter;
  7382. const afterEnterHook = isAppear
  7383. ? (afterAppear || afterEnter)
  7384. : afterEnter;
  7385. const enterCancelledHook = isAppear
  7386. ? (appearCancelled || enterCancelled)
  7387. : enterCancelled;
  7388. const explicitEnterDuration = toNumber(
  7389. isObject(duration)
  7390. ? duration.enter
  7391. : duration
  7392. );
  7393. if (explicitEnterDuration != null) {
  7394. checkDuration(explicitEnterDuration, 'enter', vnode);
  7395. }
  7396. const expectsCSS = css !== false && !isIE9;
  7397. const userWantsControl = getHookArgumentsLength(enterHook);
  7398. const cb = el._enterCb = once(() => {
  7399. if (expectsCSS) {
  7400. removeTransitionClass(el, toClass);
  7401. removeTransitionClass(el, activeClass);
  7402. }
  7403. if (cb.cancelled) {
  7404. if (expectsCSS) {
  7405. removeTransitionClass(el, startClass);
  7406. }
  7407. enterCancelledHook && enterCancelledHook(el);
  7408. } else {
  7409. afterEnterHook && afterEnterHook(el);
  7410. }
  7411. el._enterCb = null;
  7412. });
  7413. if (!vnode.data.show) {
  7414. // remove pending leave element on enter by injecting an insert hook
  7415. mergeVNodeHook(vnode, 'insert', () => {
  7416. const parent = el.parentNode;
  7417. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7418. if (pendingNode &&
  7419. pendingNode.tag === vnode.tag &&
  7420. pendingNode.elm._leaveCb
  7421. ) {
  7422. pendingNode.elm._leaveCb();
  7423. }
  7424. enterHook && enterHook(el, cb);
  7425. });
  7426. }
  7427. // start enter transition
  7428. beforeEnterHook && beforeEnterHook(el);
  7429. if (expectsCSS) {
  7430. addTransitionClass(el, startClass);
  7431. addTransitionClass(el, activeClass);
  7432. nextFrame(() => {
  7433. removeTransitionClass(el, startClass);
  7434. if (!cb.cancelled) {
  7435. addTransitionClass(el, toClass);
  7436. if (!userWantsControl) {
  7437. if (isValidDuration(explicitEnterDuration)) {
  7438. setTimeout(cb, explicitEnterDuration);
  7439. } else {
  7440. whenTransitionEnds(el, type, cb);
  7441. }
  7442. }
  7443. }
  7444. });
  7445. }
  7446. if (vnode.data.show) {
  7447. toggleDisplay && toggleDisplay();
  7448. enterHook && enterHook(el, cb);
  7449. }
  7450. if (!expectsCSS && !userWantsControl) {
  7451. cb();
  7452. }
  7453. }
  7454. function leave (vnode, rm) {
  7455. const el = vnode.elm;
  7456. // call enter callback now
  7457. if (isDef(el._enterCb)) {
  7458. el._enterCb.cancelled = true;
  7459. el._enterCb();
  7460. }
  7461. const data = resolveTransition(vnode.data.transition);
  7462. if (isUndef(data) || el.nodeType !== 1) {
  7463. return rm()
  7464. }
  7465. /* istanbul ignore if */
  7466. if (isDef(el._leaveCb)) {
  7467. return
  7468. }
  7469. const {
  7470. css,
  7471. type,
  7472. leaveClass,
  7473. leaveToClass,
  7474. leaveActiveClass,
  7475. beforeLeave,
  7476. leave,
  7477. afterLeave,
  7478. leaveCancelled,
  7479. delayLeave,
  7480. duration
  7481. } = data;
  7482. const expectsCSS = css !== false && !isIE9;
  7483. const userWantsControl = getHookArgumentsLength(leave);
  7484. const explicitLeaveDuration = toNumber(
  7485. isObject(duration)
  7486. ? duration.leave
  7487. : duration
  7488. );
  7489. if (isDef(explicitLeaveDuration)) {
  7490. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7491. }
  7492. const cb = el._leaveCb = once(() => {
  7493. if (el.parentNode && el.parentNode._pending) {
  7494. el.parentNode._pending[vnode.key] = null;
  7495. }
  7496. if (expectsCSS) {
  7497. removeTransitionClass(el, leaveToClass);
  7498. removeTransitionClass(el, leaveActiveClass);
  7499. }
  7500. if (cb.cancelled) {
  7501. if (expectsCSS) {
  7502. removeTransitionClass(el, leaveClass);
  7503. }
  7504. leaveCancelled && leaveCancelled(el);
  7505. } else {
  7506. rm();
  7507. afterLeave && afterLeave(el);
  7508. }
  7509. el._leaveCb = null;
  7510. });
  7511. if (delayLeave) {
  7512. delayLeave(performLeave);
  7513. } else {
  7514. performLeave();
  7515. }
  7516. function performLeave () {
  7517. // the delayed leave may have already been cancelled
  7518. if (cb.cancelled) {
  7519. return
  7520. }
  7521. // record leaving element
  7522. if (!vnode.data.show && el.parentNode) {
  7523. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  7524. }
  7525. beforeLeave && beforeLeave(el);
  7526. if (expectsCSS) {
  7527. addTransitionClass(el, leaveClass);
  7528. addTransitionClass(el, leaveActiveClass);
  7529. nextFrame(() => {
  7530. removeTransitionClass(el, leaveClass);
  7531. if (!cb.cancelled) {
  7532. addTransitionClass(el, leaveToClass);
  7533. if (!userWantsControl) {
  7534. if (isValidDuration(explicitLeaveDuration)) {
  7535. setTimeout(cb, explicitLeaveDuration);
  7536. } else {
  7537. whenTransitionEnds(el, type, cb);
  7538. }
  7539. }
  7540. }
  7541. });
  7542. }
  7543. leave && leave(el, cb);
  7544. if (!expectsCSS && !userWantsControl) {
  7545. cb();
  7546. }
  7547. }
  7548. }
  7549. // only used in dev mode
  7550. function checkDuration (val, name, vnode) {
  7551. if (typeof val !== 'number') {
  7552. warn(
  7553. `<transition> explicit ${name} duration is not a valid number - ` +
  7554. `got ${JSON.stringify(val)}.`,
  7555. vnode.context
  7556. );
  7557. } else if (isNaN(val)) {
  7558. warn(
  7559. `<transition> explicit ${name} duration is NaN - ` +
  7560. 'the duration expression might be incorrect.',
  7561. vnode.context
  7562. );
  7563. }
  7564. }
  7565. function isValidDuration (val) {
  7566. return typeof val === 'number' && !isNaN(val)
  7567. }
  7568. /**
  7569. * Normalize a transition hook's argument length. The hook may be:
  7570. * - a merged hook (invoker) with the original in .fns
  7571. * - a wrapped component method (check ._length)
  7572. * - a plain function (.length)
  7573. */
  7574. function getHookArgumentsLength (fn) {
  7575. if (isUndef(fn)) {
  7576. return false
  7577. }
  7578. const invokerFns = fn.fns;
  7579. if (isDef(invokerFns)) {
  7580. // invoker
  7581. return getHookArgumentsLength(
  7582. Array.isArray(invokerFns)
  7583. ? invokerFns[0]
  7584. : invokerFns
  7585. )
  7586. } else {
  7587. return (fn._length || fn.length) > 1
  7588. }
  7589. }
  7590. function _enter (_, vnode) {
  7591. if (vnode.data.show !== true) {
  7592. enter(vnode);
  7593. }
  7594. }
  7595. var transition = inBrowser ? {
  7596. create: _enter,
  7597. activate: _enter,
  7598. remove (vnode, rm) {
  7599. /* istanbul ignore else */
  7600. if (vnode.data.show !== true) {
  7601. leave(vnode, rm);
  7602. } else {
  7603. rm();
  7604. }
  7605. }
  7606. } : {};
  7607. var platformModules = [
  7608. attrs,
  7609. klass,
  7610. events,
  7611. domProps,
  7612. style,
  7613. transition
  7614. ];
  7615. /* */
  7616. // the directive module should be applied last, after all
  7617. // built-in modules have been applied.
  7618. const modules = platformModules.concat(baseModules);
  7619. const patch = createPatchFunction({ nodeOps, modules });
  7620. /**
  7621. * Not type checking this file because flow doesn't like attaching
  7622. * properties to Elements.
  7623. */
  7624. /* istanbul ignore if */
  7625. if (isIE9) {
  7626. // http://www.matts411.com/post/internet-explorer-9-oninput/
  7627. document.addEventListener('selectionchange', () => {
  7628. const el = document.activeElement;
  7629. if (el && el.vmodel) {
  7630. trigger(el, 'input');
  7631. }
  7632. });
  7633. }
  7634. const directive = {
  7635. inserted (el, binding, vnode, oldVnode) {
  7636. if (vnode.tag === 'select') {
  7637. // #6903
  7638. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  7639. mergeVNodeHook(vnode, 'postpatch', () => {
  7640. directive.componentUpdated(el, binding, vnode);
  7641. });
  7642. } else {
  7643. setSelected(el, binding, vnode.context);
  7644. }
  7645. el._vOptions = [].map.call(el.options, getValue);
  7646. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  7647. el._vModifiers = binding.modifiers;
  7648. if (!binding.modifiers.lazy) {
  7649. el.addEventListener('compositionstart', onCompositionStart);
  7650. el.addEventListener('compositionend', onCompositionEnd);
  7651. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  7652. // switching focus before confirming composition choice
  7653. // this also fixes the issue where some browsers e.g. iOS Chrome
  7654. // fires "change" instead of "input" on autocomplete.
  7655. el.addEventListener('change', onCompositionEnd);
  7656. /* istanbul ignore if */
  7657. if (isIE9) {
  7658. el.vmodel = true;
  7659. }
  7660. }
  7661. }
  7662. },
  7663. componentUpdated (el, binding, vnode) {
  7664. if (vnode.tag === 'select') {
  7665. setSelected(el, binding, vnode.context);
  7666. // in case the options rendered by v-for have changed,
  7667. // it's possible that the value is out-of-sync with the rendered options.
  7668. // detect such cases and filter out values that no longer has a matching
  7669. // option in the DOM.
  7670. const prevOptions = el._vOptions;
  7671. const curOptions = el._vOptions = [].map.call(el.options, getValue);
  7672. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  7673. // trigger change event if
  7674. // no matching option found for at least one value
  7675. const needReset = el.multiple
  7676. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  7677. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  7678. if (needReset) {
  7679. trigger(el, 'change');
  7680. }
  7681. }
  7682. }
  7683. }
  7684. };
  7685. function setSelected (el, binding, vm) {
  7686. actuallySetSelected(el, binding, vm);
  7687. /* istanbul ignore if */
  7688. if (isIE || isEdge) {
  7689. setTimeout(() => {
  7690. actuallySetSelected(el, binding, vm);
  7691. }, 0);
  7692. }
  7693. }
  7694. function actuallySetSelected (el, binding, vm) {
  7695. const value = binding.value;
  7696. const isMultiple = el.multiple;
  7697. if (isMultiple && !Array.isArray(value)) {
  7698. warn(
  7699. `<select multiple v-model="${binding.expression}"> ` +
  7700. `expects an Array value for its binding, but got ${
  7701. Object.prototype.toString.call(value).slice(8, -1)
  7702. }`,
  7703. vm
  7704. );
  7705. return
  7706. }
  7707. let selected, option;
  7708. for (let i = 0, l = el.options.length; i < l; i++) {
  7709. option = el.options[i];
  7710. if (isMultiple) {
  7711. selected = looseIndexOf(value, getValue(option)) > -1;
  7712. if (option.selected !== selected) {
  7713. option.selected = selected;
  7714. }
  7715. } else {
  7716. if (looseEqual(getValue(option), value)) {
  7717. if (el.selectedIndex !== i) {
  7718. el.selectedIndex = i;
  7719. }
  7720. return
  7721. }
  7722. }
  7723. }
  7724. if (!isMultiple) {
  7725. el.selectedIndex = -1;
  7726. }
  7727. }
  7728. function hasNoMatchingOption (value, options) {
  7729. return options.every(o => !looseEqual(o, value))
  7730. }
  7731. function getValue (option) {
  7732. return '_value' in option
  7733. ? option._value
  7734. : option.value
  7735. }
  7736. function onCompositionStart (e) {
  7737. e.target.composing = true;
  7738. }
  7739. function onCompositionEnd (e) {
  7740. // prevent triggering an input event for no reason
  7741. if (!e.target.composing) return
  7742. e.target.composing = false;
  7743. trigger(e.target, 'input');
  7744. }
  7745. function trigger (el, type) {
  7746. const e = document.createEvent('HTMLEvents');
  7747. e.initEvent(type, true, true);
  7748. el.dispatchEvent(e);
  7749. }
  7750. /* */
  7751. // recursively search for possible transition defined inside the component root
  7752. function locateNode (vnode) {
  7753. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  7754. ? locateNode(vnode.componentInstance._vnode)
  7755. : vnode
  7756. }
  7757. var show = {
  7758. bind (el, { value }, vnode) {
  7759. vnode = locateNode(vnode);
  7760. const transition$$1 = vnode.data && vnode.data.transition;
  7761. const originalDisplay = el.__vOriginalDisplay =
  7762. el.style.display === 'none' ? '' : el.style.display;
  7763. if (value && transition$$1) {
  7764. vnode.data.show = true;
  7765. enter(vnode, () => {
  7766. el.style.display = originalDisplay;
  7767. });
  7768. } else {
  7769. el.style.display = value ? originalDisplay : 'none';
  7770. }
  7771. },
  7772. update (el, { value, oldValue }, vnode) {
  7773. /* istanbul ignore if */
  7774. if (!value === !oldValue) return
  7775. vnode = locateNode(vnode);
  7776. const transition$$1 = vnode.data && vnode.data.transition;
  7777. if (transition$$1) {
  7778. vnode.data.show = true;
  7779. if (value) {
  7780. enter(vnode, () => {
  7781. el.style.display = el.__vOriginalDisplay;
  7782. });
  7783. } else {
  7784. leave(vnode, () => {
  7785. el.style.display = 'none';
  7786. });
  7787. }
  7788. } else {
  7789. el.style.display = value ? el.__vOriginalDisplay : 'none';
  7790. }
  7791. },
  7792. unbind (
  7793. el,
  7794. binding,
  7795. vnode,
  7796. oldVnode,
  7797. isDestroy
  7798. ) {
  7799. if (!isDestroy) {
  7800. el.style.display = el.__vOriginalDisplay;
  7801. }
  7802. }
  7803. };
  7804. var platformDirectives = {
  7805. model: directive,
  7806. show
  7807. };
  7808. /* */
  7809. const transitionProps = {
  7810. name: String,
  7811. appear: Boolean,
  7812. css: Boolean,
  7813. mode: String,
  7814. type: String,
  7815. enterClass: String,
  7816. leaveClass: String,
  7817. enterToClass: String,
  7818. leaveToClass: String,
  7819. enterActiveClass: String,
  7820. leaveActiveClass: String,
  7821. appearClass: String,
  7822. appearActiveClass: String,
  7823. appearToClass: String,
  7824. duration: [Number, String, Object]
  7825. };
  7826. // in case the child is also an abstract component, e.g. <keep-alive>
  7827. // we want to recursively retrieve the real component to be rendered
  7828. function getRealChild (vnode) {
  7829. const compOptions = vnode && vnode.componentOptions;
  7830. if (compOptions && compOptions.Ctor.options.abstract) {
  7831. return getRealChild(getFirstComponentChild(compOptions.children))
  7832. } else {
  7833. return vnode
  7834. }
  7835. }
  7836. function extractTransitionData (comp) {
  7837. const data = {};
  7838. const options = comp.$options;
  7839. // props
  7840. for (const key in options.propsData) {
  7841. data[key] = comp[key];
  7842. }
  7843. // events.
  7844. // extract listeners and pass them directly to the transition methods
  7845. const listeners = options._parentListeners;
  7846. for (const key in listeners) {
  7847. data[camelize(key)] = listeners[key];
  7848. }
  7849. return data
  7850. }
  7851. function placeholder (h, rawChild) {
  7852. if (/\d-keep-alive$/.test(rawChild.tag)) {
  7853. return h('keep-alive', {
  7854. props: rawChild.componentOptions.propsData
  7855. })
  7856. }
  7857. }
  7858. function hasParentTransition (vnode) {
  7859. while ((vnode = vnode.parent)) {
  7860. if (vnode.data.transition) {
  7861. return true
  7862. }
  7863. }
  7864. }
  7865. function isSameChild (child, oldChild) {
  7866. return oldChild.key === child.key && oldChild.tag === child.tag
  7867. }
  7868. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  7869. const isVShowDirective = d => d.name === 'show';
  7870. var Transition = {
  7871. name: 'transition',
  7872. props: transitionProps,
  7873. abstract: true,
  7874. render (h) {
  7875. let children = this.$slots.default;
  7876. if (!children) {
  7877. return
  7878. }
  7879. // filter out text nodes (possible whitespaces)
  7880. children = children.filter(isNotTextNode);
  7881. /* istanbul ignore if */
  7882. if (!children.length) {
  7883. return
  7884. }
  7885. // warn multiple elements
  7886. if (children.length > 1) {
  7887. warn(
  7888. '<transition> can only be used on a single element. Use ' +
  7889. '<transition-group> for lists.',
  7890. this.$parent
  7891. );
  7892. }
  7893. const mode = this.mode;
  7894. // warn invalid mode
  7895. if (mode && mode !== 'in-out' && mode !== 'out-in'
  7896. ) {
  7897. warn(
  7898. 'invalid <transition> mode: ' + mode,
  7899. this.$parent
  7900. );
  7901. }
  7902. const rawChild = children[0];
  7903. // if this is a component root node and the component's
  7904. // parent container node also has transition, skip.
  7905. if (hasParentTransition(this.$vnode)) {
  7906. return rawChild
  7907. }
  7908. // apply transition data to child
  7909. // use getRealChild() to ignore abstract components e.g. keep-alive
  7910. const child = getRealChild(rawChild);
  7911. /* istanbul ignore if */
  7912. if (!child) {
  7913. return rawChild
  7914. }
  7915. if (this._leaving) {
  7916. return placeholder(h, rawChild)
  7917. }
  7918. // ensure a key that is unique to the vnode type and to this transition
  7919. // component instance. This key will be used to remove pending leaving nodes
  7920. // during entering.
  7921. const id = `__transition-${this._uid}-`;
  7922. child.key = child.key == null
  7923. ? child.isComment
  7924. ? id + 'comment'
  7925. : id + child.tag
  7926. : isPrimitive(child.key)
  7927. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  7928. : child.key;
  7929. const data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  7930. const oldRawChild = this._vnode;
  7931. const oldChild = getRealChild(oldRawChild);
  7932. // mark v-show
  7933. // so that the transition module can hand over the control to the directive
  7934. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  7935. child.data.show = true;
  7936. }
  7937. if (
  7938. oldChild &&
  7939. oldChild.data &&
  7940. !isSameChild(child, oldChild) &&
  7941. !isAsyncPlaceholder(oldChild) &&
  7942. // #6687 component root is a comment node
  7943. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  7944. ) {
  7945. // replace old child transition data with fresh one
  7946. // important for dynamic transitions!
  7947. const oldData = oldChild.data.transition = extend({}, data);
  7948. // handle transition mode
  7949. if (mode === 'out-in') {
  7950. // return placeholder node and queue update when leave finishes
  7951. this._leaving = true;
  7952. mergeVNodeHook(oldData, 'afterLeave', () => {
  7953. this._leaving = false;
  7954. this.$forceUpdate();
  7955. });
  7956. return placeholder(h, rawChild)
  7957. } else if (mode === 'in-out') {
  7958. if (isAsyncPlaceholder(child)) {
  7959. return oldRawChild
  7960. }
  7961. let delayedLeave;
  7962. const performLeave = () => { delayedLeave(); };
  7963. mergeVNodeHook(data, 'afterEnter', performLeave);
  7964. mergeVNodeHook(data, 'enterCancelled', performLeave);
  7965. mergeVNodeHook(oldData, 'delayLeave', leave => { delayedLeave = leave; });
  7966. }
  7967. }
  7968. return rawChild
  7969. }
  7970. };
  7971. /* */
  7972. const props = extend({
  7973. tag: String,
  7974. moveClass: String
  7975. }, transitionProps);
  7976. delete props.mode;
  7977. var TransitionGroup = {
  7978. props,
  7979. beforeMount () {
  7980. const update = this._update;
  7981. this._update = (vnode, hydrating) => {
  7982. const restoreActiveInstance = setActiveInstance(this);
  7983. // force removing pass
  7984. this.__patch__(
  7985. this._vnode,
  7986. this.kept,
  7987. false, // hydrating
  7988. true // removeOnly (!important, avoids unnecessary moves)
  7989. );
  7990. this._vnode = this.kept;
  7991. restoreActiveInstance();
  7992. update.call(this, vnode, hydrating);
  7993. };
  7994. },
  7995. render (h) {
  7996. const tag = this.tag || this.$vnode.data.tag || 'span';
  7997. const map = Object.create(null);
  7998. const prevChildren = this.prevChildren = this.children;
  7999. const rawChildren = this.$slots.default || [];
  8000. const children = this.children = [];
  8001. const transitionData = extractTransitionData(this);
  8002. for (let i = 0; i < rawChildren.length; i++) {
  8003. const c = rawChildren[i];
  8004. if (c.tag) {
  8005. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8006. children.push(c);
  8007. map[c.key] = c
  8008. ;(c.data || (c.data = {})).transition = transitionData;
  8009. } else {
  8010. const opts = c.componentOptions;
  8011. const name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  8012. warn(`<transition-group> children must be keyed: <${name}>`);
  8013. }
  8014. }
  8015. }
  8016. if (prevChildren) {
  8017. const kept = [];
  8018. const removed = [];
  8019. for (let i = 0; i < prevChildren.length; i++) {
  8020. const c = prevChildren[i];
  8021. c.data.transition = transitionData;
  8022. c.data.pos = c.elm.getBoundingClientRect();
  8023. if (map[c.key]) {
  8024. kept.push(c);
  8025. } else {
  8026. removed.push(c);
  8027. }
  8028. }
  8029. this.kept = h(tag, null, kept);
  8030. this.removed = removed;
  8031. }
  8032. return h(tag, null, children)
  8033. },
  8034. updated () {
  8035. const children = this.prevChildren;
  8036. const moveClass = this.moveClass || ((this.name || 'v') + '-move');
  8037. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8038. return
  8039. }
  8040. // we divide the work into three loops to avoid mixing DOM reads and writes
  8041. // in each iteration - which helps prevent layout thrashing.
  8042. children.forEach(callPendingCbs);
  8043. children.forEach(recordPosition);
  8044. children.forEach(applyTranslation);
  8045. // force reflow to put everything in position
  8046. // assign to this to avoid being removed in tree-shaking
  8047. // $flow-disable-line
  8048. this._reflow = document.body.offsetHeight;
  8049. children.forEach((c) => {
  8050. if (c.data.moved) {
  8051. const el = c.elm;
  8052. const s = el.style;
  8053. addTransitionClass(el, moveClass);
  8054. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8055. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  8056. if (e && e.target !== el) {
  8057. return
  8058. }
  8059. if (!e || /transform$/.test(e.propertyName)) {
  8060. el.removeEventListener(transitionEndEvent, cb);
  8061. el._moveCb = null;
  8062. removeTransitionClass(el, moveClass);
  8063. }
  8064. });
  8065. }
  8066. });
  8067. },
  8068. methods: {
  8069. hasMove (el, moveClass) {
  8070. /* istanbul ignore if */
  8071. if (!hasTransition) {
  8072. return false
  8073. }
  8074. /* istanbul ignore if */
  8075. if (this._hasMove) {
  8076. return this._hasMove
  8077. }
  8078. // Detect whether an element with the move class applied has
  8079. // CSS transitions. Since the element may be inside an entering
  8080. // transition at this very moment, we make a clone of it and remove
  8081. // all other transition classes applied to ensure only the move class
  8082. // is applied.
  8083. const clone = el.cloneNode();
  8084. if (el._transitionClasses) {
  8085. el._transitionClasses.forEach((cls) => { removeClass(clone, cls); });
  8086. }
  8087. addClass(clone, moveClass);
  8088. clone.style.display = 'none';
  8089. this.$el.appendChild(clone);
  8090. const info = getTransitionInfo(clone);
  8091. this.$el.removeChild(clone);
  8092. return (this._hasMove = info.hasTransform)
  8093. }
  8094. }
  8095. };
  8096. function callPendingCbs (c) {
  8097. /* istanbul ignore if */
  8098. if (c.elm._moveCb) {
  8099. c.elm._moveCb();
  8100. }
  8101. /* istanbul ignore if */
  8102. if (c.elm._enterCb) {
  8103. c.elm._enterCb();
  8104. }
  8105. }
  8106. function recordPosition (c) {
  8107. c.data.newPos = c.elm.getBoundingClientRect();
  8108. }
  8109. function applyTranslation (c) {
  8110. const oldPos = c.data.pos;
  8111. const newPos = c.data.newPos;
  8112. const dx = oldPos.left - newPos.left;
  8113. const dy = oldPos.top - newPos.top;
  8114. if (dx || dy) {
  8115. c.data.moved = true;
  8116. const s = c.elm.style;
  8117. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  8118. s.transitionDuration = '0s';
  8119. }
  8120. }
  8121. var platformComponents = {
  8122. Transition,
  8123. TransitionGroup
  8124. };
  8125. /* */
  8126. // install platform specific utils
  8127. Vue.config.mustUseProp = mustUseProp;
  8128. Vue.config.isReservedTag = isReservedTag;
  8129. Vue.config.isReservedAttr = isReservedAttr;
  8130. Vue.config.getTagNamespace = getTagNamespace;
  8131. Vue.config.isUnknownElement = isUnknownElement;
  8132. // install platform runtime directives & components
  8133. extend(Vue.options.directives, platformDirectives);
  8134. extend(Vue.options.components, platformComponents);
  8135. // install platform patch function
  8136. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  8137. // public mount method
  8138. Vue.prototype.$mount = function (
  8139. el,
  8140. hydrating
  8141. ) {
  8142. el = el && inBrowser ? query(el) : undefined;
  8143. return mountComponent(this, el, hydrating)
  8144. };
  8145. // devtools global hook
  8146. /* istanbul ignore next */
  8147. if (inBrowser) {
  8148. setTimeout(() => {
  8149. if (config.devtools) {
  8150. if (devtools) {
  8151. devtools.emit('init', Vue);
  8152. } else {
  8153. console[console.info ? 'info' : 'log'](
  8154. 'Download the Vue Devtools extension for a better development experience:\n' +
  8155. 'https://github.com/vuejs/vue-devtools'
  8156. );
  8157. }
  8158. }
  8159. if (config.productionTip !== false &&
  8160. typeof console !== 'undefined'
  8161. ) {
  8162. console[console.info ? 'info' : 'log'](
  8163. `You are running Vue in development mode.\n` +
  8164. `Make sure to turn on production mode when deploying for production.\n` +
  8165. `See more tips at https://vuejs.org/guide/deployment.html`
  8166. );
  8167. }
  8168. }, 0);
  8169. }
  8170. /* */
  8171. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  8172. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  8173. const buildRegex = cached(delimiters => {
  8174. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  8175. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  8176. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  8177. });
  8178. function parseText (
  8179. text,
  8180. delimiters
  8181. ) {
  8182. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  8183. if (!tagRE.test(text)) {
  8184. return
  8185. }
  8186. const tokens = [];
  8187. const rawTokens = [];
  8188. let lastIndex = tagRE.lastIndex = 0;
  8189. let match, index, tokenValue;
  8190. while ((match = tagRE.exec(text))) {
  8191. index = match.index;
  8192. // push text token
  8193. if (index > lastIndex) {
  8194. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  8195. tokens.push(JSON.stringify(tokenValue));
  8196. }
  8197. // tag token
  8198. const exp = parseFilters(match[1].trim());
  8199. tokens.push(`_s(${exp})`);
  8200. rawTokens.push({ '@binding': exp });
  8201. lastIndex = index + match[0].length;
  8202. }
  8203. if (lastIndex < text.length) {
  8204. rawTokens.push(tokenValue = text.slice(lastIndex));
  8205. tokens.push(JSON.stringify(tokenValue));
  8206. }
  8207. return {
  8208. expression: tokens.join('+'),
  8209. tokens: rawTokens
  8210. }
  8211. }
  8212. /* */
  8213. function transformNode (el, options) {
  8214. const warn = options.warn || baseWarn;
  8215. const staticClass = getAndRemoveAttr(el, 'class');
  8216. if (staticClass) {
  8217. const res = parseText(staticClass, options.delimiters);
  8218. if (res) {
  8219. warn(
  8220. `class="${staticClass}": ` +
  8221. 'Interpolation inside attributes has been removed. ' +
  8222. 'Use v-bind or the colon shorthand instead. For example, ' +
  8223. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  8224. el.rawAttrsMap['class']
  8225. );
  8226. }
  8227. }
  8228. if (staticClass) {
  8229. el.staticClass = JSON.stringify(staticClass);
  8230. }
  8231. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  8232. if (classBinding) {
  8233. el.classBinding = classBinding;
  8234. }
  8235. }
  8236. function genData (el) {
  8237. let data = '';
  8238. if (el.staticClass) {
  8239. data += `staticClass:${el.staticClass},`;
  8240. }
  8241. if (el.classBinding) {
  8242. data += `class:${el.classBinding},`;
  8243. }
  8244. return data
  8245. }
  8246. var klass$1 = {
  8247. staticKeys: ['staticClass'],
  8248. transformNode,
  8249. genData
  8250. };
  8251. /* */
  8252. function transformNode$1 (el, options) {
  8253. const warn = options.warn || baseWarn;
  8254. const staticStyle = getAndRemoveAttr(el, 'style');
  8255. if (staticStyle) {
  8256. /* istanbul ignore if */
  8257. {
  8258. const res = parseText(staticStyle, options.delimiters);
  8259. if (res) {
  8260. warn(
  8261. `style="${staticStyle}": ` +
  8262. 'Interpolation inside attributes has been removed. ' +
  8263. 'Use v-bind or the colon shorthand instead. For example, ' +
  8264. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  8265. el.rawAttrsMap['style']
  8266. );
  8267. }
  8268. }
  8269. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  8270. }
  8271. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  8272. if (styleBinding) {
  8273. el.styleBinding = styleBinding;
  8274. }
  8275. }
  8276. function genData$1 (el) {
  8277. let data = '';
  8278. if (el.staticStyle) {
  8279. data += `staticStyle:${el.staticStyle},`;
  8280. }
  8281. if (el.styleBinding) {
  8282. data += `style:(${el.styleBinding}),`;
  8283. }
  8284. return data
  8285. }
  8286. var style$1 = {
  8287. staticKeys: ['staticStyle'],
  8288. transformNode: transformNode$1,
  8289. genData: genData$1
  8290. };
  8291. /* */
  8292. let decoder;
  8293. var he = {
  8294. decode (html) {
  8295. decoder = decoder || document.createElement('div');
  8296. decoder.innerHTML = html;
  8297. return decoder.textContent
  8298. }
  8299. };
  8300. /* */
  8301. const isUnaryTag = makeMap(
  8302. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  8303. 'link,meta,param,source,track,wbr'
  8304. );
  8305. // Elements that you can, intentionally, leave open
  8306. // (and which close themselves)
  8307. const canBeLeftOpenTag = makeMap(
  8308. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  8309. );
  8310. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  8311. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  8312. const isNonPhrasingTag = makeMap(
  8313. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  8314. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  8315. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  8316. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  8317. 'title,tr,track'
  8318. );
  8319. /**
  8320. * Not type-checking this file because it's mostly vendor code.
  8321. */
  8322. // Regular Expressions for parsing tags and attributes
  8323. const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8324. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8325. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  8326. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  8327. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  8328. const startTagClose = /^\s*(\/?)>/;
  8329. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  8330. const doctype = /^<!DOCTYPE [^>]+>/i;
  8331. // #7298: escape - to avoid being pased as HTML comment when inlined in page
  8332. const comment = /^<!\--/;
  8333. const conditionalComment = /^<!\[/;
  8334. // Special Elements (can contain anything)
  8335. const isPlainTextElement = makeMap('script,style,textarea', true);
  8336. const reCache = {};
  8337. const decodingMap = {
  8338. '&lt;': '<',
  8339. '&gt;': '>',
  8340. '&quot;': '"',
  8341. '&amp;': '&',
  8342. '&#10;': '\n',
  8343. '&#9;': '\t',
  8344. '&#39;': "'"
  8345. };
  8346. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  8347. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  8348. // #5992
  8349. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  8350. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  8351. function decodeAttr (value, shouldDecodeNewlines) {
  8352. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  8353. return value.replace(re, match => decodingMap[match])
  8354. }
  8355. function parseHTML (html, options) {
  8356. const stack = [];
  8357. const expectHTML = options.expectHTML;
  8358. const isUnaryTag$$1 = options.isUnaryTag || no;
  8359. const canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  8360. let index = 0;
  8361. let last, lastTag;
  8362. while (html) {
  8363. last = html;
  8364. // Make sure we're not in a plaintext content element like script/style
  8365. if (!lastTag || !isPlainTextElement(lastTag)) {
  8366. let textEnd = html.indexOf('<');
  8367. if (textEnd === 0) {
  8368. // Comment:
  8369. if (comment.test(html)) {
  8370. const commentEnd = html.indexOf('-->');
  8371. if (commentEnd >= 0) {
  8372. if (options.shouldKeepComment) {
  8373. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  8374. }
  8375. advance(commentEnd + 3);
  8376. continue
  8377. }
  8378. }
  8379. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  8380. if (conditionalComment.test(html)) {
  8381. const conditionalEnd = html.indexOf(']>');
  8382. if (conditionalEnd >= 0) {
  8383. advance(conditionalEnd + 2);
  8384. continue
  8385. }
  8386. }
  8387. // Doctype:
  8388. const doctypeMatch = html.match(doctype);
  8389. if (doctypeMatch) {
  8390. advance(doctypeMatch[0].length);
  8391. continue
  8392. }
  8393. // End tag:
  8394. const endTagMatch = html.match(endTag);
  8395. if (endTagMatch) {
  8396. const curIndex = index;
  8397. advance(endTagMatch[0].length);
  8398. parseEndTag(endTagMatch[1], curIndex, index);
  8399. continue
  8400. }
  8401. // Start tag:
  8402. const startTagMatch = parseStartTag();
  8403. if (startTagMatch) {
  8404. handleStartTag(startTagMatch);
  8405. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  8406. advance(1);
  8407. }
  8408. continue
  8409. }
  8410. }
  8411. let text, rest, next;
  8412. if (textEnd >= 0) {
  8413. rest = html.slice(textEnd);
  8414. while (
  8415. !endTag.test(rest) &&
  8416. !startTagOpen.test(rest) &&
  8417. !comment.test(rest) &&
  8418. !conditionalComment.test(rest)
  8419. ) {
  8420. // < in plain text, be forgiving and treat it as text
  8421. next = rest.indexOf('<', 1);
  8422. if (next < 0) break
  8423. textEnd += next;
  8424. rest = html.slice(textEnd);
  8425. }
  8426. text = html.substring(0, textEnd);
  8427. }
  8428. if (textEnd < 0) {
  8429. text = html;
  8430. }
  8431. if (text) {
  8432. advance(text.length);
  8433. }
  8434. if (options.chars && text) {
  8435. options.chars(text, index - text.length, index);
  8436. }
  8437. } else {
  8438. let endTagLength = 0;
  8439. const stackedTag = lastTag.toLowerCase();
  8440. const reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  8441. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  8442. endTagLength = endTag.length;
  8443. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  8444. text = text
  8445. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  8446. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  8447. }
  8448. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  8449. text = text.slice(1);
  8450. }
  8451. if (options.chars) {
  8452. options.chars(text);
  8453. }
  8454. return ''
  8455. });
  8456. index += html.length - rest.length;
  8457. html = rest;
  8458. parseEndTag(stackedTag, index - endTagLength, index);
  8459. }
  8460. if (html === last) {
  8461. options.chars && options.chars(html);
  8462. if (!stack.length && options.warn) {
  8463. options.warn(`Mal-formatted tag at end of template: "${html}"`, { start: index + html.length });
  8464. }
  8465. break
  8466. }
  8467. }
  8468. // Clean up any remaining tags
  8469. parseEndTag();
  8470. function advance (n) {
  8471. index += n;
  8472. html = html.substring(n);
  8473. }
  8474. function parseStartTag () {
  8475. const start = html.match(startTagOpen);
  8476. if (start) {
  8477. const match = {
  8478. tagName: start[1],
  8479. attrs: [],
  8480. start: index
  8481. };
  8482. advance(start[0].length);
  8483. let end, attr;
  8484. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  8485. attr.start = index;
  8486. advance(attr[0].length);
  8487. attr.end = index;
  8488. match.attrs.push(attr);
  8489. }
  8490. if (end) {
  8491. match.unarySlash = end[1];
  8492. advance(end[0].length);
  8493. match.end = index;
  8494. return match
  8495. }
  8496. }
  8497. }
  8498. function handleStartTag (match) {
  8499. const tagName = match.tagName;
  8500. const unarySlash = match.unarySlash;
  8501. if (expectHTML) {
  8502. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  8503. parseEndTag(lastTag);
  8504. }
  8505. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  8506. parseEndTag(tagName);
  8507. }
  8508. }
  8509. const unary = isUnaryTag$$1(tagName) || !!unarySlash;
  8510. const l = match.attrs.length;
  8511. const attrs = new Array(l);
  8512. for (let i = 0; i < l; i++) {
  8513. const args = match.attrs[i];
  8514. const value = args[3] || args[4] || args[5] || '';
  8515. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  8516. ? options.shouldDecodeNewlinesForHref
  8517. : options.shouldDecodeNewlines;
  8518. attrs[i] = {
  8519. name: args[1],
  8520. value: decodeAttr(value, shouldDecodeNewlines)
  8521. };
  8522. if (options.outputSourceRange) {
  8523. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  8524. attrs[i].end = args.end;
  8525. }
  8526. }
  8527. if (!unary) {
  8528. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  8529. lastTag = tagName;
  8530. }
  8531. if (options.start) {
  8532. options.start(tagName, attrs, unary, match.start, match.end);
  8533. }
  8534. }
  8535. function parseEndTag (tagName, start, end) {
  8536. let pos, lowerCasedTagName;
  8537. if (start == null) start = index;
  8538. if (end == null) end = index;
  8539. // Find the closest opened tag of the same type
  8540. if (tagName) {
  8541. lowerCasedTagName = tagName.toLowerCase();
  8542. for (pos = stack.length - 1; pos >= 0; pos--) {
  8543. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  8544. break
  8545. }
  8546. }
  8547. } else {
  8548. // If no tag name is provided, clean shop
  8549. pos = 0;
  8550. }
  8551. if (pos >= 0) {
  8552. // Close all the open elements, up the stack
  8553. for (let i = stack.length - 1; i >= pos; i--) {
  8554. if (i > pos || !tagName &&
  8555. options.warn
  8556. ) {
  8557. options.warn(
  8558. `tag <${stack[i].tag}> has no matching end tag.`,
  8559. { start: stack[i].start, end: stack[i].end }
  8560. );
  8561. }
  8562. if (options.end) {
  8563. options.end(stack[i].tag, start, end);
  8564. }
  8565. }
  8566. // Remove the open elements from the stack
  8567. stack.length = pos;
  8568. lastTag = pos && stack[pos - 1].tag;
  8569. } else if (lowerCasedTagName === 'br') {
  8570. if (options.start) {
  8571. options.start(tagName, [], true, start, end);
  8572. }
  8573. } else if (lowerCasedTagName === 'p') {
  8574. if (options.start) {
  8575. options.start(tagName, [], false, start, end);
  8576. }
  8577. if (options.end) {
  8578. options.end(tagName, start, end);
  8579. }
  8580. }
  8581. }
  8582. }
  8583. /* */
  8584. const onRE = /^@|^v-on:/;
  8585. const dirRE = /^v-|^@|^:/;
  8586. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  8587. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  8588. const stripParensRE = /^\(|\)$/g;
  8589. const dynamicArgRE = /^\[.*\]$/;
  8590. const argRE = /:(.*)$/;
  8591. const bindRE = /^:|^\.|^v-bind:/;
  8592. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  8593. const slotRE = /^v-slot(:|$)|^#/;
  8594. const lineBreakRE = /[\r\n]/;
  8595. const whitespaceRE$1 = /\s+/g;
  8596. const invalidAttributeRE = /[\s"'<>\/=]/;
  8597. const decodeHTMLCached = cached(he.decode);
  8598. const emptySlotScopeToken = `_empty_`;
  8599. // configurable state
  8600. let warn$2;
  8601. let delimiters;
  8602. let transforms;
  8603. let preTransforms;
  8604. let postTransforms;
  8605. let platformIsPreTag;
  8606. let platformMustUseProp;
  8607. let platformGetTagNamespace;
  8608. let maybeComponent;
  8609. function createASTElement (
  8610. tag,
  8611. attrs,
  8612. parent
  8613. ) {
  8614. return {
  8615. type: 1,
  8616. tag,
  8617. attrsList: attrs,
  8618. attrsMap: makeAttrsMap(attrs),
  8619. rawAttrsMap: {},
  8620. parent,
  8621. children: []
  8622. }
  8623. }
  8624. /**
  8625. * Convert HTML string to AST.
  8626. */
  8627. function parse (
  8628. template,
  8629. options
  8630. ) {
  8631. warn$2 = options.warn || baseWarn;
  8632. platformIsPreTag = options.isPreTag || no;
  8633. platformMustUseProp = options.mustUseProp || no;
  8634. platformGetTagNamespace = options.getTagNamespace || no;
  8635. const isReservedTag = options.isReservedTag || no;
  8636. maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  8637. transforms = pluckModuleFunction(options.modules, 'transformNode');
  8638. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  8639. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  8640. delimiters = options.delimiters;
  8641. const stack = [];
  8642. const preserveWhitespace = options.preserveWhitespace !== false;
  8643. const whitespaceOption = options.whitespace;
  8644. let root;
  8645. let currentParent;
  8646. let inVPre = false;
  8647. let inPre = false;
  8648. let warned = false;
  8649. function warnOnce (msg, range) {
  8650. if (!warned) {
  8651. warned = true;
  8652. warn$2(msg, range);
  8653. }
  8654. }
  8655. function closeElement (element) {
  8656. trimEndingWhitespace(element);
  8657. if (!inVPre && !element.processed) {
  8658. element = processElement(element, options);
  8659. }
  8660. // tree management
  8661. if (!stack.length && element !== root) {
  8662. // allow root elements with v-if, v-else-if and v-else
  8663. if (root.if && (element.elseif || element.else)) {
  8664. {
  8665. checkRootConstraints(element);
  8666. }
  8667. addIfCondition(root, {
  8668. exp: element.elseif,
  8669. block: element
  8670. });
  8671. } else {
  8672. warnOnce(
  8673. `Component template should contain exactly one root element. ` +
  8674. `If you are using v-if on multiple elements, ` +
  8675. `use v-else-if to chain them instead.`,
  8676. { start: element.start }
  8677. );
  8678. }
  8679. }
  8680. if (currentParent && !element.forbidden) {
  8681. if (element.elseif || element.else) {
  8682. processIfConditions(element, currentParent);
  8683. } else {
  8684. if (element.slotScope) {
  8685. // scoped slot
  8686. // keep it in the children list so that v-else(-if) conditions can
  8687. // find it as the prev node.
  8688. const name = element.slotTarget || '"default"'
  8689. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  8690. }
  8691. currentParent.children.push(element);
  8692. element.parent = currentParent;
  8693. }
  8694. }
  8695. // final children cleanup
  8696. // filter out scoped slots
  8697. element.children = element.children.filter(c => !(c).slotScope);
  8698. // remove trailing whitespace node again
  8699. trimEndingWhitespace(element);
  8700. // check pre state
  8701. if (element.pre) {
  8702. inVPre = false;
  8703. }
  8704. if (platformIsPreTag(element.tag)) {
  8705. inPre = false;
  8706. }
  8707. // apply post-transforms
  8708. for (let i = 0; i < postTransforms.length; i++) {
  8709. postTransforms[i](element, options);
  8710. }
  8711. }
  8712. function trimEndingWhitespace (el) {
  8713. // remove trailing whitespace node
  8714. if (!inPre) {
  8715. let lastNode;
  8716. while (
  8717. (lastNode = el.children[el.children.length - 1]) &&
  8718. lastNode.type === 3 &&
  8719. lastNode.text === ' '
  8720. ) {
  8721. el.children.pop();
  8722. }
  8723. }
  8724. }
  8725. function checkRootConstraints (el) {
  8726. if (el.tag === 'slot' || el.tag === 'template') {
  8727. warnOnce(
  8728. `Cannot use <${el.tag}> as component root element because it may ` +
  8729. 'contain multiple nodes.',
  8730. { start: el.start }
  8731. );
  8732. }
  8733. if (el.attrsMap.hasOwnProperty('v-for')) {
  8734. warnOnce(
  8735. 'Cannot use v-for on stateful component root element because ' +
  8736. 'it renders multiple elements.',
  8737. el.rawAttrsMap['v-for']
  8738. );
  8739. }
  8740. }
  8741. parseHTML(template, {
  8742. warn: warn$2,
  8743. expectHTML: options.expectHTML,
  8744. isUnaryTag: options.isUnaryTag,
  8745. canBeLeftOpenTag: options.canBeLeftOpenTag,
  8746. shouldDecodeNewlines: options.shouldDecodeNewlines,
  8747. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  8748. shouldKeepComment: options.comments,
  8749. outputSourceRange: options.outputSourceRange,
  8750. start (tag, attrs, unary, start, end) {
  8751. // check namespace.
  8752. // inherit parent ns if there is one
  8753. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  8754. // handle IE svg bug
  8755. /* istanbul ignore if */
  8756. if (isIE && ns === 'svg') {
  8757. attrs = guardIESVGBug(attrs);
  8758. }
  8759. let element = createASTElement(tag, attrs, currentParent);
  8760. if (ns) {
  8761. element.ns = ns;
  8762. }
  8763. {
  8764. if (options.outputSourceRange) {
  8765. element.start = start;
  8766. element.end = end;
  8767. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  8768. cumulated[attr.name] = attr;
  8769. return cumulated
  8770. }, {});
  8771. }
  8772. attrs.forEach(attr => {
  8773. if (invalidAttributeRE.test(attr.name)) {
  8774. warn$2(
  8775. `Invalid dynamic argument expression: attribute names cannot contain ` +
  8776. `spaces, quotes, <, >, / or =.`,
  8777. {
  8778. start: attr.start + attr.name.indexOf(`[`),
  8779. end: attr.start + attr.name.length
  8780. }
  8781. );
  8782. }
  8783. });
  8784. }
  8785. if (isForbiddenTag(element) && !isServerRendering()) {
  8786. element.forbidden = true;
  8787. warn$2(
  8788. 'Templates should only be responsible for mapping the state to the ' +
  8789. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  8790. `<${tag}>` + ', as they will not be parsed.',
  8791. { start: element.start }
  8792. );
  8793. }
  8794. // apply pre-transforms
  8795. for (let i = 0; i < preTransforms.length; i++) {
  8796. element = preTransforms[i](element, options) || element;
  8797. }
  8798. if (!inVPre) {
  8799. processPre(element);
  8800. if (element.pre) {
  8801. inVPre = true;
  8802. }
  8803. }
  8804. if (platformIsPreTag(element.tag)) {
  8805. inPre = true;
  8806. }
  8807. if (inVPre) {
  8808. processRawAttrs(element);
  8809. } else if (!element.processed) {
  8810. // structural directives
  8811. processFor(element);
  8812. processIf(element);
  8813. processOnce(element);
  8814. }
  8815. if (!root) {
  8816. root = element;
  8817. {
  8818. checkRootConstraints(root);
  8819. }
  8820. }
  8821. if (!unary) {
  8822. currentParent = element;
  8823. stack.push(element);
  8824. } else {
  8825. closeElement(element);
  8826. }
  8827. },
  8828. end (tag, start, end) {
  8829. const element = stack[stack.length - 1];
  8830. // pop stack
  8831. stack.length -= 1;
  8832. currentParent = stack[stack.length - 1];
  8833. if (options.outputSourceRange) {
  8834. element.end = end;
  8835. }
  8836. closeElement(element);
  8837. },
  8838. chars (text, start, end) {
  8839. if (!currentParent) {
  8840. {
  8841. if (text === template) {
  8842. warnOnce(
  8843. 'Component template requires a root element, rather than just text.',
  8844. { start }
  8845. );
  8846. } else if ((text = text.trim())) {
  8847. warnOnce(
  8848. `text "${text}" outside root element will be ignored.`,
  8849. { start }
  8850. );
  8851. }
  8852. }
  8853. return
  8854. }
  8855. // IE textarea placeholder bug
  8856. /* istanbul ignore if */
  8857. if (isIE &&
  8858. currentParent.tag === 'textarea' &&
  8859. currentParent.attrsMap.placeholder === text
  8860. ) {
  8861. return
  8862. }
  8863. const children = currentParent.children;
  8864. if (inPre || text.trim()) {
  8865. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  8866. } else if (!children.length) {
  8867. // remove the whitespace-only node right after an opening tag
  8868. text = '';
  8869. } else if (whitespaceOption) {
  8870. if (whitespaceOption === 'condense') {
  8871. // in condense mode, remove the whitespace node if it contains
  8872. // line break, otherwise condense to a single space
  8873. text = lineBreakRE.test(text) ? '' : ' ';
  8874. } else {
  8875. text = ' ';
  8876. }
  8877. } else {
  8878. text = preserveWhitespace ? ' ' : '';
  8879. }
  8880. if (text) {
  8881. if (!inPre && whitespaceOption === 'condense') {
  8882. // condense consecutive whitespaces into single space
  8883. text = text.replace(whitespaceRE$1, ' ');
  8884. }
  8885. let res;
  8886. let child;
  8887. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  8888. child = {
  8889. type: 2,
  8890. expression: res.expression,
  8891. tokens: res.tokens,
  8892. text
  8893. };
  8894. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  8895. child = {
  8896. type: 3,
  8897. text
  8898. };
  8899. }
  8900. if (child) {
  8901. if (options.outputSourceRange) {
  8902. child.start = start;
  8903. child.end = end;
  8904. }
  8905. children.push(child);
  8906. }
  8907. }
  8908. },
  8909. comment (text, start, end) {
  8910. // adding anyting as a sibling to the root node is forbidden
  8911. // comments should still be allowed, but ignored
  8912. if (currentParent) {
  8913. const child = {
  8914. type: 3,
  8915. text,
  8916. isComment: true
  8917. };
  8918. if (options.outputSourceRange) {
  8919. child.start = start;
  8920. child.end = end;
  8921. }
  8922. currentParent.children.push(child);
  8923. }
  8924. }
  8925. });
  8926. return root
  8927. }
  8928. function processPre (el) {
  8929. if (getAndRemoveAttr(el, 'v-pre') != null) {
  8930. el.pre = true;
  8931. }
  8932. }
  8933. function processRawAttrs (el) {
  8934. const list = el.attrsList;
  8935. const len = list.length;
  8936. if (len) {
  8937. const attrs = el.attrs = new Array(len);
  8938. for (let i = 0; i < len; i++) {
  8939. attrs[i] = {
  8940. name: list[i].name,
  8941. value: JSON.stringify(list[i].value)
  8942. };
  8943. if (list[i].start != null) {
  8944. attrs[i].start = list[i].start;
  8945. attrs[i].end = list[i].end;
  8946. }
  8947. }
  8948. } else if (!el.pre) {
  8949. // non root node in pre blocks with no attributes
  8950. el.plain = true;
  8951. }
  8952. }
  8953. function processElement (
  8954. element,
  8955. options
  8956. ) {
  8957. processKey(element);
  8958. // determine whether this is a plain element after
  8959. // removing structural attributes
  8960. element.plain = (
  8961. !element.key &&
  8962. !element.scopedSlots &&
  8963. !element.attrsList.length
  8964. );
  8965. processRef(element);
  8966. processSlotContent(element);
  8967. processSlotOutlet(element);
  8968. processComponent(element);
  8969. for (let i = 0; i < transforms.length; i++) {
  8970. element = transforms[i](element, options) || element;
  8971. }
  8972. processAttrs(element);
  8973. return element
  8974. }
  8975. function processKey (el) {
  8976. const exp = getBindingAttr(el, 'key');
  8977. if (exp) {
  8978. {
  8979. if (el.tag === 'template') {
  8980. warn$2(
  8981. `<template> cannot be keyed. Place the key on real elements instead.`,
  8982. getRawBindingAttr(el, 'key')
  8983. );
  8984. }
  8985. if (el.for) {
  8986. const iterator = el.iterator2 || el.iterator1;
  8987. const parent = el.parent;
  8988. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  8989. warn$2(
  8990. `Do not use v-for index as key on <transition-group> children, ` +
  8991. `this is the same as not using keys.`,
  8992. getRawBindingAttr(el, 'key'),
  8993. true /* tip */
  8994. );
  8995. }
  8996. }
  8997. }
  8998. el.key = exp;
  8999. }
  9000. }
  9001. function processRef (el) {
  9002. const ref = getBindingAttr(el, 'ref');
  9003. if (ref) {
  9004. el.ref = ref;
  9005. el.refInFor = checkInFor(el);
  9006. }
  9007. }
  9008. function processFor (el) {
  9009. let exp;
  9010. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9011. const res = parseFor(exp);
  9012. if (res) {
  9013. extend(el, res);
  9014. } else {
  9015. warn$2(
  9016. `Invalid v-for expression: ${exp}`,
  9017. el.rawAttrsMap['v-for']
  9018. );
  9019. }
  9020. }
  9021. }
  9022. function parseFor (exp) {
  9023. const inMatch = exp.match(forAliasRE);
  9024. if (!inMatch) return
  9025. const res = {};
  9026. res.for = inMatch[2].trim();
  9027. const alias = inMatch[1].trim().replace(stripParensRE, '');
  9028. const iteratorMatch = alias.match(forIteratorRE);
  9029. if (iteratorMatch) {
  9030. res.alias = alias.replace(forIteratorRE, '').trim();
  9031. res.iterator1 = iteratorMatch[1].trim();
  9032. if (iteratorMatch[2]) {
  9033. res.iterator2 = iteratorMatch[2].trim();
  9034. }
  9035. } else {
  9036. res.alias = alias;
  9037. }
  9038. return res
  9039. }
  9040. function processIf (el) {
  9041. const exp = getAndRemoveAttr(el, 'v-if');
  9042. if (exp) {
  9043. el.if = exp;
  9044. addIfCondition(el, {
  9045. exp: exp,
  9046. block: el
  9047. });
  9048. } else {
  9049. if (getAndRemoveAttr(el, 'v-else') != null) {
  9050. el.else = true;
  9051. }
  9052. const elseif = getAndRemoveAttr(el, 'v-else-if');
  9053. if (elseif) {
  9054. el.elseif = elseif;
  9055. }
  9056. }
  9057. }
  9058. function processIfConditions (el, parent) {
  9059. const prev = findPrevElement(parent.children);
  9060. if (prev && prev.if) {
  9061. addIfCondition(prev, {
  9062. exp: el.elseif,
  9063. block: el
  9064. });
  9065. } else {
  9066. warn$2(
  9067. `v-${el.elseif ? ('else-if="' + el.elseif + '"') : 'else'} ` +
  9068. `used on element <${el.tag}> without corresponding v-if.`,
  9069. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  9070. );
  9071. }
  9072. }
  9073. function findPrevElement (children) {
  9074. let i = children.length;
  9075. while (i--) {
  9076. if (children[i].type === 1) {
  9077. return children[i]
  9078. } else {
  9079. if (children[i].text !== ' ') {
  9080. warn$2(
  9081. `text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  9082. `will be ignored.`,
  9083. children[i]
  9084. );
  9085. }
  9086. children.pop();
  9087. }
  9088. }
  9089. }
  9090. function addIfCondition (el, condition) {
  9091. if (!el.ifConditions) {
  9092. el.ifConditions = [];
  9093. }
  9094. el.ifConditions.push(condition);
  9095. }
  9096. function processOnce (el) {
  9097. const once$$1 = getAndRemoveAttr(el, 'v-once');
  9098. if (once$$1 != null) {
  9099. el.once = true;
  9100. }
  9101. }
  9102. // handle content being passed to a component as slot,
  9103. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  9104. function processSlotContent (el) {
  9105. let slotScope;
  9106. if (el.tag === 'template') {
  9107. slotScope = getAndRemoveAttr(el, 'scope');
  9108. /* istanbul ignore if */
  9109. if (slotScope) {
  9110. warn$2(
  9111. `the "scope" attribute for scoped slots have been deprecated and ` +
  9112. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  9113. `can also be used on plain elements in addition to <template> to ` +
  9114. `denote scoped slots.`,
  9115. el.rawAttrsMap['scope'],
  9116. true
  9117. );
  9118. }
  9119. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  9120. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  9121. /* istanbul ignore if */
  9122. if (el.attrsMap['v-for']) {
  9123. warn$2(
  9124. `Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  9125. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  9126. `scoped slot to make it clearer.`,
  9127. el.rawAttrsMap['slot-scope'],
  9128. true
  9129. );
  9130. }
  9131. el.slotScope = slotScope;
  9132. }
  9133. // slot="xxx"
  9134. const slotTarget = getBindingAttr(el, 'slot');
  9135. if (slotTarget) {
  9136. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  9137. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  9138. // preserve slot as an attribute for native shadow DOM compat
  9139. // only for non-scoped slots.
  9140. if (el.tag !== 'template' && !el.slotScope) {
  9141. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  9142. }
  9143. }
  9144. // 2.6 v-slot syntax
  9145. {
  9146. if (el.tag === 'template') {
  9147. // v-slot on <template>
  9148. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  9149. if (slotBinding) {
  9150. {
  9151. if (el.slotTarget || el.slotScope) {
  9152. warn$2(
  9153. `Unexpected mixed usage of different slot syntaxes.`,
  9154. el
  9155. );
  9156. }
  9157. if (el.parent && !maybeComponent(el.parent)) {
  9158. warn$2(
  9159. `<template v-slot> can only appear at the root level inside ` +
  9160. `the receiving the component`,
  9161. el
  9162. );
  9163. }
  9164. }
  9165. const { name, dynamic } = getSlotName(slotBinding);
  9166. el.slotTarget = name;
  9167. el.slotTargetDynamic = dynamic;
  9168. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  9169. }
  9170. } else {
  9171. // v-slot on component, denotes default slot
  9172. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  9173. if (slotBinding) {
  9174. {
  9175. if (!maybeComponent(el)) {
  9176. warn$2(
  9177. `v-slot can only be used on components or <template>.`,
  9178. slotBinding
  9179. );
  9180. }
  9181. if (el.slotScope || el.slotTarget) {
  9182. warn$2(
  9183. `Unexpected mixed usage of different slot syntaxes.`,
  9184. el
  9185. );
  9186. }
  9187. if (el.scopedSlots) {
  9188. warn$2(
  9189. `To avoid scope ambiguity, the default slot should also use ` +
  9190. `<template> syntax when there are other named slots.`,
  9191. slotBinding
  9192. );
  9193. }
  9194. }
  9195. // add the component's children to its default slot
  9196. const slots = el.scopedSlots || (el.scopedSlots = {});
  9197. const { name, dynamic } = getSlotName(slotBinding);
  9198. const slotContainer = slots[name] = createASTElement('template', [], el);
  9199. slotContainer.slotTarget = name;
  9200. slotContainer.slotTargetDynamic = dynamic;
  9201. slotContainer.children = el.children.filter((c) => {
  9202. if (!c.slotScope) {
  9203. c.parent = slotContainer;
  9204. return true
  9205. }
  9206. });
  9207. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  9208. // remove children as they are returned from scopedSlots now
  9209. el.children = [];
  9210. // mark el non-plain so data gets generated
  9211. el.plain = false;
  9212. }
  9213. }
  9214. }
  9215. }
  9216. function getSlotName (binding) {
  9217. let name = binding.name.replace(slotRE, '');
  9218. if (!name) {
  9219. if (binding.name[0] !== '#') {
  9220. name = 'default';
  9221. } else {
  9222. warn$2(
  9223. `v-slot shorthand syntax requires a slot name.`,
  9224. binding
  9225. );
  9226. }
  9227. }
  9228. return dynamicArgRE.test(name)
  9229. // dynamic [name]
  9230. ? { name: name.slice(1, -1), dynamic: true }
  9231. // static name
  9232. : { name: `"${name}"`, dynamic: false }
  9233. }
  9234. // handle <slot/> outlets
  9235. function processSlotOutlet (el) {
  9236. if (el.tag === 'slot') {
  9237. el.slotName = getBindingAttr(el, 'name');
  9238. if (el.key) {
  9239. warn$2(
  9240. `\`key\` does not work on <slot> because slots are abstract outlets ` +
  9241. `and can possibly expand into multiple elements. ` +
  9242. `Use the key on a wrapping element instead.`,
  9243. getRawBindingAttr(el, 'key')
  9244. );
  9245. }
  9246. }
  9247. }
  9248. function processComponent (el) {
  9249. let binding;
  9250. if ((binding = getBindingAttr(el, 'is'))) {
  9251. el.component = binding;
  9252. }
  9253. if (getAndRemoveAttr(el, 'inline-template') != null) {
  9254. el.inlineTemplate = true;
  9255. }
  9256. }
  9257. function processAttrs (el) {
  9258. const list = el.attrsList;
  9259. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  9260. for (i = 0, l = list.length; i < l; i++) {
  9261. name = rawName = list[i].name;
  9262. value = list[i].value;
  9263. if (dirRE.test(name)) {
  9264. // mark element as dynamic
  9265. el.hasBindings = true;
  9266. // modifiers
  9267. modifiers = parseModifiers(name.replace(dirRE, ''));
  9268. // support .foo shorthand syntax for the .prop modifier
  9269. if (modifiers) {
  9270. name = name.replace(modifierRE, '');
  9271. }
  9272. if (bindRE.test(name)) { // v-bind
  9273. name = name.replace(bindRE, '');
  9274. value = parseFilters(value);
  9275. isDynamic = dynamicArgRE.test(name);
  9276. if (isDynamic) {
  9277. name = name.slice(1, -1);
  9278. }
  9279. if (
  9280. value.trim().length === 0
  9281. ) {
  9282. warn$2(
  9283. `The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`
  9284. );
  9285. }
  9286. if (modifiers) {
  9287. if (modifiers.prop && !isDynamic) {
  9288. name = camelize(name);
  9289. if (name === 'innerHtml') name = 'innerHTML';
  9290. }
  9291. if (modifiers.camel && !isDynamic) {
  9292. name = camelize(name);
  9293. }
  9294. if (modifiers.sync) {
  9295. syncGen = genAssignmentCode(value, `$event`);
  9296. if (!isDynamic) {
  9297. addHandler(
  9298. el,
  9299. `update:${camelize(name)}`,
  9300. syncGen,
  9301. null,
  9302. false,
  9303. warn$2,
  9304. list[i]
  9305. );
  9306. if (hyphenate(name) !== camelize(name)) {
  9307. addHandler(
  9308. el,
  9309. `update:${hyphenate(name)}`,
  9310. syncGen,
  9311. null,
  9312. false,
  9313. warn$2,
  9314. list[i]
  9315. );
  9316. }
  9317. } else {
  9318. // handler w/ dynamic event name
  9319. addHandler(
  9320. el,
  9321. `"update:"+(${name})`,
  9322. syncGen,
  9323. null,
  9324. false,
  9325. warn$2,
  9326. list[i],
  9327. true // dynamic
  9328. );
  9329. }
  9330. }
  9331. }
  9332. if ((modifiers && modifiers.prop) || (
  9333. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  9334. )) {
  9335. addProp(el, name, value, list[i], isDynamic);
  9336. } else {
  9337. addAttr(el, name, value, list[i], isDynamic);
  9338. }
  9339. } else if (onRE.test(name)) { // v-on
  9340. name = name.replace(onRE, '');
  9341. isDynamic = dynamicArgRE.test(name);
  9342. if (isDynamic) {
  9343. name = name.slice(1, -1);
  9344. }
  9345. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  9346. } else { // normal directives
  9347. name = name.replace(dirRE, '');
  9348. // parse arg
  9349. const argMatch = name.match(argRE);
  9350. let arg = argMatch && argMatch[1];
  9351. isDynamic = false;
  9352. if (arg) {
  9353. name = name.slice(0, -(arg.length + 1));
  9354. if (dynamicArgRE.test(arg)) {
  9355. arg = arg.slice(1, -1);
  9356. isDynamic = true;
  9357. }
  9358. }
  9359. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  9360. if (name === 'model') {
  9361. checkForAliasModel(el, value);
  9362. }
  9363. }
  9364. } else {
  9365. // literal attribute
  9366. {
  9367. const res = parseText(value, delimiters);
  9368. if (res) {
  9369. warn$2(
  9370. `${name}="${value}": ` +
  9371. 'Interpolation inside attributes has been removed. ' +
  9372. 'Use v-bind or the colon shorthand instead. For example, ' +
  9373. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  9374. list[i]
  9375. );
  9376. }
  9377. }
  9378. addAttr(el, name, JSON.stringify(value), list[i]);
  9379. // #6887 firefox doesn't update muted state if set via attribute
  9380. // even immediately after element creation
  9381. if (!el.component &&
  9382. name === 'muted' &&
  9383. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  9384. addProp(el, name, 'true', list[i]);
  9385. }
  9386. }
  9387. }
  9388. }
  9389. function checkInFor (el) {
  9390. let parent = el;
  9391. while (parent) {
  9392. if (parent.for !== undefined) {
  9393. return true
  9394. }
  9395. parent = parent.parent;
  9396. }
  9397. return false
  9398. }
  9399. function parseModifiers (name) {
  9400. const match = name.match(modifierRE);
  9401. if (match) {
  9402. const ret = {};
  9403. match.forEach(m => { ret[m.slice(1)] = true; });
  9404. return ret
  9405. }
  9406. }
  9407. function makeAttrsMap (attrs) {
  9408. const map = {};
  9409. for (let i = 0, l = attrs.length; i < l; i++) {
  9410. if (
  9411. map[attrs[i].name] && !isIE && !isEdge
  9412. ) {
  9413. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  9414. }
  9415. map[attrs[i].name] = attrs[i].value;
  9416. }
  9417. return map
  9418. }
  9419. // for script (e.g. type="x/template") or style, do not decode content
  9420. function isTextTag (el) {
  9421. return el.tag === 'script' || el.tag === 'style'
  9422. }
  9423. function isForbiddenTag (el) {
  9424. return (
  9425. el.tag === 'style' ||
  9426. (el.tag === 'script' && (
  9427. !el.attrsMap.type ||
  9428. el.attrsMap.type === 'text/javascript'
  9429. ))
  9430. )
  9431. }
  9432. const ieNSBug = /^xmlns:NS\d+/;
  9433. const ieNSPrefix = /^NS\d+:/;
  9434. /* istanbul ignore next */
  9435. function guardIESVGBug (attrs) {
  9436. const res = [];
  9437. for (let i = 0; i < attrs.length; i++) {
  9438. const attr = attrs[i];
  9439. if (!ieNSBug.test(attr.name)) {
  9440. attr.name = attr.name.replace(ieNSPrefix, '');
  9441. res.push(attr);
  9442. }
  9443. }
  9444. return res
  9445. }
  9446. function checkForAliasModel (el, value) {
  9447. let _el = el;
  9448. while (_el) {
  9449. if (_el.for && _el.alias === value) {
  9450. warn$2(
  9451. `<${el.tag} v-model="${value}">: ` +
  9452. `You are binding v-model directly to a v-for iteration alias. ` +
  9453. `This will not be able to modify the v-for source array because ` +
  9454. `writing to the alias is like modifying a function local variable. ` +
  9455. `Consider using an array of objects and use v-model on an object property instead.`,
  9456. el.rawAttrsMap['v-model']
  9457. );
  9458. }
  9459. _el = _el.parent;
  9460. }
  9461. }
  9462. /* */
  9463. function preTransformNode (el, options) {
  9464. if (el.tag === 'input') {
  9465. const map = el.attrsMap;
  9466. if (!map['v-model']) {
  9467. return
  9468. }
  9469. let typeBinding;
  9470. if (map[':type'] || map['v-bind:type']) {
  9471. typeBinding = getBindingAttr(el, 'type');
  9472. }
  9473. if (!map.type && !typeBinding && map['v-bind']) {
  9474. typeBinding = `(${map['v-bind']}).type`;
  9475. }
  9476. if (typeBinding) {
  9477. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  9478. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  9479. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  9480. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  9481. // 1. checkbox
  9482. const branch0 = cloneASTElement(el);
  9483. // process for on the main node
  9484. processFor(branch0);
  9485. addRawAttr(branch0, 'type', 'checkbox');
  9486. processElement(branch0, options);
  9487. branch0.processed = true; // prevent it from double-processed
  9488. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  9489. addIfCondition(branch0, {
  9490. exp: branch0.if,
  9491. block: branch0
  9492. });
  9493. // 2. add radio else-if condition
  9494. const branch1 = cloneASTElement(el);
  9495. getAndRemoveAttr(branch1, 'v-for', true);
  9496. addRawAttr(branch1, 'type', 'radio');
  9497. processElement(branch1, options);
  9498. addIfCondition(branch0, {
  9499. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  9500. block: branch1
  9501. });
  9502. // 3. other
  9503. const branch2 = cloneASTElement(el);
  9504. getAndRemoveAttr(branch2, 'v-for', true);
  9505. addRawAttr(branch2, ':type', typeBinding);
  9506. processElement(branch2, options);
  9507. addIfCondition(branch0, {
  9508. exp: ifCondition,
  9509. block: branch2
  9510. });
  9511. if (hasElse) {
  9512. branch0.else = true;
  9513. } else if (elseIfCondition) {
  9514. branch0.elseif = elseIfCondition;
  9515. }
  9516. return branch0
  9517. }
  9518. }
  9519. }
  9520. function cloneASTElement (el) {
  9521. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  9522. }
  9523. var model$1 = {
  9524. preTransformNode
  9525. };
  9526. var modules$1 = [
  9527. klass$1,
  9528. style$1,
  9529. model$1
  9530. ];
  9531. /* */
  9532. function text (el, dir) {
  9533. if (dir.value) {
  9534. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  9535. }
  9536. }
  9537. /* */
  9538. function html (el, dir) {
  9539. if (dir.value) {
  9540. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  9541. }
  9542. }
  9543. var directives$1 = {
  9544. model,
  9545. text,
  9546. html
  9547. };
  9548. /* */
  9549. const baseOptions = {
  9550. expectHTML: true,
  9551. modules: modules$1,
  9552. directives: directives$1,
  9553. isPreTag,
  9554. isUnaryTag,
  9555. mustUseProp,
  9556. canBeLeftOpenTag,
  9557. isReservedTag,
  9558. getTagNamespace,
  9559. staticKeys: genStaticKeys(modules$1)
  9560. };
  9561. /* */
  9562. let isStaticKey;
  9563. let isPlatformReservedTag;
  9564. const genStaticKeysCached = cached(genStaticKeys$1);
  9565. /**
  9566. * Goal of the optimizer: walk the generated template AST tree
  9567. * and detect sub-trees that are purely static, i.e. parts of
  9568. * the DOM that never needs to change.
  9569. *
  9570. * Once we detect these sub-trees, we can:
  9571. *
  9572. * 1. Hoist them into constants, so that we no longer need to
  9573. * create fresh nodes for them on each re-render;
  9574. * 2. Completely skip them in the patching process.
  9575. */
  9576. function optimize (root, options) {
  9577. if (!root) return
  9578. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  9579. isPlatformReservedTag = options.isReservedTag || no;
  9580. // first pass: mark all non-static nodes.
  9581. markStatic$1(root);
  9582. // second pass: mark static roots.
  9583. markStaticRoots(root, false);
  9584. }
  9585. function genStaticKeys$1 (keys) {
  9586. return makeMap(
  9587. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  9588. (keys ? ',' + keys : '')
  9589. )
  9590. }
  9591. function markStatic$1 (node) {
  9592. node.static = isStatic(node);
  9593. if (node.type === 1) {
  9594. // do not make component slot content static. this avoids
  9595. // 1. components not able to mutate slot nodes
  9596. // 2. static slot content fails for hot-reloading
  9597. if (
  9598. !isPlatformReservedTag(node.tag) &&
  9599. node.tag !== 'slot' &&
  9600. node.attrsMap['inline-template'] == null
  9601. ) {
  9602. return
  9603. }
  9604. for (let i = 0, l = node.children.length; i < l; i++) {
  9605. const child = node.children[i];
  9606. markStatic$1(child);
  9607. if (!child.static) {
  9608. node.static = false;
  9609. }
  9610. }
  9611. if (node.ifConditions) {
  9612. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  9613. const block = node.ifConditions[i].block;
  9614. markStatic$1(block);
  9615. if (!block.static) {
  9616. node.static = false;
  9617. }
  9618. }
  9619. }
  9620. }
  9621. }
  9622. function markStaticRoots (node, isInFor) {
  9623. if (node.type === 1) {
  9624. if (node.static || node.once) {
  9625. node.staticInFor = isInFor;
  9626. }
  9627. // For a node to qualify as a static root, it should have children that
  9628. // are not just static text. Otherwise the cost of hoisting out will
  9629. // outweigh the benefits and it's better off to just always render it fresh.
  9630. if (node.static && node.children.length && !(
  9631. node.children.length === 1 &&
  9632. node.children[0].type === 3
  9633. )) {
  9634. node.staticRoot = true;
  9635. return
  9636. } else {
  9637. node.staticRoot = false;
  9638. }
  9639. if (node.children) {
  9640. for (let i = 0, l = node.children.length; i < l; i++) {
  9641. markStaticRoots(node.children[i], isInFor || !!node.for);
  9642. }
  9643. }
  9644. if (node.ifConditions) {
  9645. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  9646. markStaticRoots(node.ifConditions[i].block, isInFor);
  9647. }
  9648. }
  9649. }
  9650. }
  9651. function isStatic (node) {
  9652. if (node.type === 2) { // expression
  9653. return false
  9654. }
  9655. if (node.type === 3) { // text
  9656. return true
  9657. }
  9658. return !!(node.pre || (
  9659. !node.hasBindings && // no dynamic bindings
  9660. !node.if && !node.for && // not v-if or v-for or v-else
  9661. !isBuiltInTag(node.tag) && // not a built-in
  9662. isPlatformReservedTag(node.tag) && // not a component
  9663. !isDirectChildOfTemplateFor(node) &&
  9664. Object.keys(node).every(isStaticKey)
  9665. ))
  9666. }
  9667. function isDirectChildOfTemplateFor (node) {
  9668. while (node.parent) {
  9669. node = node.parent;
  9670. if (node.tag !== 'template') {
  9671. return false
  9672. }
  9673. if (node.for) {
  9674. return true
  9675. }
  9676. }
  9677. return false
  9678. }
  9679. /* */
  9680. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
  9681. const fnInvokeRE = /\([^)]*?\);*$/;
  9682. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  9683. // KeyboardEvent.keyCode aliases
  9684. const keyCodes = {
  9685. esc: 27,
  9686. tab: 9,
  9687. enter: 13,
  9688. space: 32,
  9689. up: 38,
  9690. left: 37,
  9691. right: 39,
  9692. down: 40,
  9693. 'delete': [8, 46]
  9694. };
  9695. // KeyboardEvent.key aliases
  9696. const keyNames = {
  9697. // #7880: IE11 and Edge use `Esc` for Escape key name.
  9698. esc: ['Esc', 'Escape'],
  9699. tab: 'Tab',
  9700. enter: 'Enter',
  9701. // #9112: IE11 uses `Spacebar` for Space key name.
  9702. space: [' ', 'Spacebar'],
  9703. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  9704. up: ['Up', 'ArrowUp'],
  9705. left: ['Left', 'ArrowLeft'],
  9706. right: ['Right', 'ArrowRight'],
  9707. down: ['Down', 'ArrowDown'],
  9708. // #9112: IE11 uses `Del` for Delete key name.
  9709. 'delete': ['Backspace', 'Delete', 'Del']
  9710. };
  9711. // #4868: modifiers that prevent the execution of the listener
  9712. // need to explicitly return null so that we can determine whether to remove
  9713. // the listener for .once
  9714. const genGuard = condition => `if(${condition})return null;`;
  9715. const modifierCode = {
  9716. stop: '$event.stopPropagation();',
  9717. prevent: '$event.preventDefault();',
  9718. self: genGuard(`$event.target !== $event.currentTarget`),
  9719. ctrl: genGuard(`!$event.ctrlKey`),
  9720. shift: genGuard(`!$event.shiftKey`),
  9721. alt: genGuard(`!$event.altKey`),
  9722. meta: genGuard(`!$event.metaKey`),
  9723. left: genGuard(`'button' in $event && $event.button !== 0`),
  9724. middle: genGuard(`'button' in $event && $event.button !== 1`),
  9725. right: genGuard(`'button' in $event && $event.button !== 2`)
  9726. };
  9727. function genHandlers (
  9728. events,
  9729. isNative
  9730. ) {
  9731. const prefix = isNative ? 'nativeOn:' : 'on:';
  9732. let staticHandlers = ``;
  9733. let dynamicHandlers = ``;
  9734. for (const name in events) {
  9735. const handlerCode = genHandler(events[name]);
  9736. if (events[name] && events[name].dynamic) {
  9737. dynamicHandlers += `${name},${handlerCode},`;
  9738. } else {
  9739. staticHandlers += `"${name}":${handlerCode},`;
  9740. }
  9741. }
  9742. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  9743. if (dynamicHandlers) {
  9744. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`
  9745. } else {
  9746. return prefix + staticHandlers
  9747. }
  9748. }
  9749. function genHandler (handler) {
  9750. if (!handler) {
  9751. return 'function(){}'
  9752. }
  9753. if (Array.isArray(handler)) {
  9754. return `[${handler.map(handler => genHandler(handler)).join(',')}]`
  9755. }
  9756. const isMethodPath = simplePathRE.test(handler.value);
  9757. const isFunctionExpression = fnExpRE.test(handler.value);
  9758. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  9759. if (!handler.modifiers) {
  9760. if (isMethodPath || isFunctionExpression) {
  9761. return handler.value
  9762. }
  9763. return `function($event){${
  9764. isFunctionInvocation ? `return ${handler.value}` : handler.value
  9765. }}` // inline statement
  9766. } else {
  9767. let code = '';
  9768. let genModifierCode = '';
  9769. const keys = [];
  9770. for (const key in handler.modifiers) {
  9771. if (modifierCode[key]) {
  9772. genModifierCode += modifierCode[key];
  9773. // left/right
  9774. if (keyCodes[key]) {
  9775. keys.push(key);
  9776. }
  9777. } else if (key === 'exact') {
  9778. const modifiers = (handler.modifiers);
  9779. genModifierCode += genGuard(
  9780. ['ctrl', 'shift', 'alt', 'meta']
  9781. .filter(keyModifier => !modifiers[keyModifier])
  9782. .map(keyModifier => `$event.${keyModifier}Key`)
  9783. .join('||')
  9784. );
  9785. } else {
  9786. keys.push(key);
  9787. }
  9788. }
  9789. if (keys.length) {
  9790. code += genKeyFilter(keys);
  9791. }
  9792. // Make sure modifiers like prevent and stop get executed after key filtering
  9793. if (genModifierCode) {
  9794. code += genModifierCode;
  9795. }
  9796. const handlerCode = isMethodPath
  9797. ? `return ${handler.value}($event)`
  9798. : isFunctionExpression
  9799. ? `return (${handler.value})($event)`
  9800. : isFunctionInvocation
  9801. ? `return ${handler.value}`
  9802. : handler.value;
  9803. return `function($event){${code}${handlerCode}}`
  9804. }
  9805. }
  9806. function genKeyFilter (keys) {
  9807. return (
  9808. // make sure the key filters only apply to KeyboardEvents
  9809. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  9810. // key events that do not have keyCode property...
  9811. `if(!$event.type.indexOf('key')&&` +
  9812. `${keys.map(genFilterCode).join('&&')})return null;`
  9813. )
  9814. }
  9815. function genFilterCode (key) {
  9816. const keyVal = parseInt(key, 10);
  9817. if (keyVal) {
  9818. return `$event.keyCode!==${keyVal}`
  9819. }
  9820. const keyCode = keyCodes[key];
  9821. const keyName = keyNames[key];
  9822. return (
  9823. `_k($event.keyCode,` +
  9824. `${JSON.stringify(key)},` +
  9825. `${JSON.stringify(keyCode)},` +
  9826. `$event.key,` +
  9827. `${JSON.stringify(keyName)}` +
  9828. `)`
  9829. )
  9830. }
  9831. /* */
  9832. function on (el, dir) {
  9833. if (dir.modifiers) {
  9834. warn(`v-on without argument does not support modifiers.`);
  9835. }
  9836. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  9837. }
  9838. /* */
  9839. function bind$1 (el, dir) {
  9840. el.wrapData = (code) => {
  9841. return `_b(${code},'${el.tag}',${dir.value},${
  9842. dir.modifiers && dir.modifiers.prop ? 'true' : 'false'
  9843. }${
  9844. dir.modifiers && dir.modifiers.sync ? ',true' : ''
  9845. })`
  9846. };
  9847. }
  9848. /* */
  9849. var baseDirectives = {
  9850. on,
  9851. bind: bind$1,
  9852. cloak: noop
  9853. };
  9854. /* */
  9855. class CodegenState {
  9856. constructor (options) {
  9857. this.options = options;
  9858. this.warn = options.warn || baseWarn;
  9859. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  9860. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  9861. this.directives = extend(extend({}, baseDirectives), options.directives);
  9862. const isReservedTag = options.isReservedTag || no;
  9863. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  9864. this.onceId = 0;
  9865. this.staticRenderFns = [];
  9866. this.pre = false;
  9867. }
  9868. }
  9869. function generate (
  9870. ast,
  9871. options
  9872. ) {
  9873. const state = new CodegenState(options);
  9874. const code = ast ? genElement(ast, state) : '_c("div")';
  9875. return {
  9876. render: `with(this){return ${code}}`,
  9877. staticRenderFns: state.staticRenderFns
  9878. }
  9879. }
  9880. function genElement (el, state) {
  9881. if (el.parent) {
  9882. el.pre = el.pre || el.parent.pre;
  9883. }
  9884. if (el.staticRoot && !el.staticProcessed) {
  9885. return genStatic(el, state)
  9886. } else if (el.once && !el.onceProcessed) {
  9887. return genOnce(el, state)
  9888. } else if (el.for && !el.forProcessed) {
  9889. return genFor(el, state)
  9890. } else if (el.if && !el.ifProcessed) {
  9891. return genIf(el, state)
  9892. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  9893. return genChildren(el, state) || 'void 0'
  9894. } else if (el.tag === 'slot') {
  9895. return genSlot(el, state)
  9896. } else {
  9897. // component or element
  9898. let code;
  9899. if (el.component) {
  9900. code = genComponent(el.component, el, state);
  9901. } else {
  9902. let data;
  9903. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  9904. data = genData$2(el, state);
  9905. }
  9906. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  9907. code = `_c('${el.tag}'${
  9908. data ? `,${data}` : '' // data
  9909. }${
  9910. children ? `,${children}` : '' // children
  9911. })`;
  9912. }
  9913. // module transforms
  9914. for (let i = 0; i < state.transforms.length; i++) {
  9915. code = state.transforms[i](el, code);
  9916. }
  9917. return code
  9918. }
  9919. }
  9920. // hoist static sub-trees out
  9921. function genStatic (el, state) {
  9922. el.staticProcessed = true;
  9923. // Some elements (templates) need to behave differently inside of a v-pre
  9924. // node. All pre nodes are static roots, so we can use this as a location to
  9925. // wrap a state change and reset it upon exiting the pre node.
  9926. const originalPreState = state.pre;
  9927. if (el.pre) {
  9928. state.pre = el.pre;
  9929. }
  9930. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  9931. state.pre = originalPreState;
  9932. return `_m(${
  9933. state.staticRenderFns.length - 1
  9934. }${
  9935. el.staticInFor ? ',true' : ''
  9936. })`
  9937. }
  9938. // v-once
  9939. function genOnce (el, state) {
  9940. el.onceProcessed = true;
  9941. if (el.if && !el.ifProcessed) {
  9942. return genIf(el, state)
  9943. } else if (el.staticInFor) {
  9944. let key = '';
  9945. let parent = el.parent;
  9946. while (parent) {
  9947. if (parent.for) {
  9948. key = parent.key;
  9949. break
  9950. }
  9951. parent = parent.parent;
  9952. }
  9953. if (!key) {
  9954. state.warn(
  9955. `v-once can only be used inside v-for that is keyed. `,
  9956. el.rawAttrsMap['v-once']
  9957. );
  9958. return genElement(el, state)
  9959. }
  9960. return `_o(${genElement(el, state)},${state.onceId++},${key})`
  9961. } else {
  9962. return genStatic(el, state)
  9963. }
  9964. }
  9965. function genIf (
  9966. el,
  9967. state,
  9968. altGen,
  9969. altEmpty
  9970. ) {
  9971. el.ifProcessed = true; // avoid recursion
  9972. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  9973. }
  9974. function genIfConditions (
  9975. conditions,
  9976. state,
  9977. altGen,
  9978. altEmpty
  9979. ) {
  9980. if (!conditions.length) {
  9981. return altEmpty || '_e()'
  9982. }
  9983. const condition = conditions.shift();
  9984. if (condition.exp) {
  9985. return `(${condition.exp})?${
  9986. genTernaryExp(condition.block)
  9987. }:${
  9988. genIfConditions(conditions, state, altGen, altEmpty)
  9989. }`
  9990. } else {
  9991. return `${genTernaryExp(condition.block)}`
  9992. }
  9993. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  9994. function genTernaryExp (el) {
  9995. return altGen
  9996. ? altGen(el, state)
  9997. : el.once
  9998. ? genOnce(el, state)
  9999. : genElement(el, state)
  10000. }
  10001. }
  10002. function genFor (
  10003. el,
  10004. state,
  10005. altGen,
  10006. altHelper
  10007. ) {
  10008. const exp = el.for;
  10009. const alias = el.alias;
  10010. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  10011. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  10012. if (state.maybeComponent(el) &&
  10013. el.tag !== 'slot' &&
  10014. el.tag !== 'template' &&
  10015. !el.key
  10016. ) {
  10017. state.warn(
  10018. `<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  10019. `v-for should have explicit keys. ` +
  10020. `See https://vuejs.org/guide/list.html#key for more info.`,
  10021. el.rawAttrsMap['v-for'],
  10022. true /* tip */
  10023. );
  10024. }
  10025. el.forProcessed = true; // avoid recursion
  10026. return `${altHelper || '_l'}((${exp}),` +
  10027. `function(${alias}${iterator1}${iterator2}){` +
  10028. `return ${(altGen || genElement)(el, state)}` +
  10029. '})'
  10030. }
  10031. function genData$2 (el, state) {
  10032. let data = '{';
  10033. // directives first.
  10034. // directives may mutate the el's other properties before they are generated.
  10035. const dirs = genDirectives(el, state);
  10036. if (dirs) data += dirs + ',';
  10037. // key
  10038. if (el.key) {
  10039. data += `key:${el.key},`;
  10040. }
  10041. // ref
  10042. if (el.ref) {
  10043. data += `ref:${el.ref},`;
  10044. }
  10045. if (el.refInFor) {
  10046. data += `refInFor:true,`;
  10047. }
  10048. // pre
  10049. if (el.pre) {
  10050. data += `pre:true,`;
  10051. }
  10052. // record original tag name for components using "is" attribute
  10053. if (el.component) {
  10054. data += `tag:"${el.tag}",`;
  10055. }
  10056. // module data generation functions
  10057. for (let i = 0; i < state.dataGenFns.length; i++) {
  10058. data += state.dataGenFns[i](el);
  10059. }
  10060. // attributes
  10061. if (el.attrs) {
  10062. data += `attrs:${genProps(el.attrs)},`;
  10063. }
  10064. // DOM props
  10065. if (el.props) {
  10066. data += `domProps:${genProps(el.props)},`;
  10067. }
  10068. // event handlers
  10069. if (el.events) {
  10070. data += `${genHandlers(el.events, false)},`;
  10071. }
  10072. if (el.nativeEvents) {
  10073. data += `${genHandlers(el.nativeEvents, true)},`;
  10074. }
  10075. // slot target
  10076. // only for non-scoped slots
  10077. if (el.slotTarget && !el.slotScope) {
  10078. data += `slot:${el.slotTarget},`;
  10079. }
  10080. // scoped slots
  10081. if (el.scopedSlots) {
  10082. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  10083. }
  10084. // component v-model
  10085. if (el.model) {
  10086. data += `model:{value:${
  10087. el.model.value
  10088. },callback:${
  10089. el.model.callback
  10090. },expression:${
  10091. el.model.expression
  10092. }},`;
  10093. }
  10094. // inline-template
  10095. if (el.inlineTemplate) {
  10096. const inlineTemplate = genInlineTemplate(el, state);
  10097. if (inlineTemplate) {
  10098. data += `${inlineTemplate},`;
  10099. }
  10100. }
  10101. data = data.replace(/,$/, '') + '}';
  10102. // v-bind dynamic argument wrap
  10103. // v-bind with dynamic arguments must be applied using the same v-bind object
  10104. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10105. if (el.dynamicAttrs) {
  10106. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  10107. }
  10108. // v-bind data wrap
  10109. if (el.wrapData) {
  10110. data = el.wrapData(data);
  10111. }
  10112. // v-on data wrap
  10113. if (el.wrapListeners) {
  10114. data = el.wrapListeners(data);
  10115. }
  10116. return data
  10117. }
  10118. function genDirectives (el, state) {
  10119. const dirs = el.directives;
  10120. if (!dirs) return
  10121. let res = 'directives:[';
  10122. let hasRuntime = false;
  10123. let i, l, dir, needRuntime;
  10124. for (i = 0, l = dirs.length; i < l; i++) {
  10125. dir = dirs[i];
  10126. needRuntime = true;
  10127. const gen = state.directives[dir.name];
  10128. if (gen) {
  10129. // compile-time directive that manipulates AST.
  10130. // returns true if it also needs a runtime counterpart.
  10131. needRuntime = !!gen(el, dir, state.warn);
  10132. }
  10133. if (needRuntime) {
  10134. hasRuntime = true;
  10135. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${
  10136. dir.value ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}` : ''
  10137. }${
  10138. dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''
  10139. }${
  10140. dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''
  10141. }},`;
  10142. }
  10143. }
  10144. if (hasRuntime) {
  10145. return res.slice(0, -1) + ']'
  10146. }
  10147. }
  10148. function genInlineTemplate (el, state) {
  10149. const ast = el.children[0];
  10150. if (el.children.length !== 1 || ast.type !== 1) {
  10151. state.warn(
  10152. 'Inline-template components must have exactly one child element.',
  10153. { start: el.start }
  10154. );
  10155. }
  10156. if (ast && ast.type === 1) {
  10157. const inlineRenderFns = generate(ast, state.options);
  10158. return `inlineTemplate:{render:function(){${
  10159. inlineRenderFns.render
  10160. }},staticRenderFns:[${
  10161. inlineRenderFns.staticRenderFns.map(code => `function(){${code}}`).join(',')
  10162. }]}`
  10163. }
  10164. }
  10165. function genScopedSlots (
  10166. el,
  10167. slots,
  10168. state
  10169. ) {
  10170. // by default scoped slots are considered "stable", this allows child
  10171. // components with only scoped slots to skip forced updates from parent.
  10172. // but in some cases we have to bail-out of this optimization
  10173. // for example if the slot contains dynamic names, has v-if or v-for on them...
  10174. let needsForceUpdate = el.for || Object.keys(slots).some(key => {
  10175. const slot = slots[key];
  10176. return (
  10177. slot.slotTargetDynamic ||
  10178. slot.if ||
  10179. slot.for ||
  10180. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  10181. )
  10182. });
  10183. // #9534: if a component with scoped slots is inside a conditional branch,
  10184. // it's possible for the same component to be reused but with different
  10185. // compiled slot content. To avoid that, we generate a unique key based on
  10186. // the generated code of all the slot contents.
  10187. let needsKey = !!el.if;
  10188. // OR when it is inside another scoped slot or v-for (the reactivity may be
  10189. // disconnected due to the intermediate scope variable)
  10190. // #9438, #9506
  10191. // TODO: this can be further optimized by properly analyzing in-scope bindings
  10192. // and skip force updating ones that do not actually use scope variables.
  10193. if (!needsForceUpdate) {
  10194. let parent = el.parent;
  10195. while (parent) {
  10196. if (
  10197. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  10198. parent.for
  10199. ) {
  10200. needsForceUpdate = true;
  10201. break
  10202. }
  10203. if (parent.if) {
  10204. needsKey = true;
  10205. }
  10206. parent = parent.parent;
  10207. }
  10208. }
  10209. const generatedSlots = Object.keys(slots)
  10210. .map(key => genScopedSlot(slots[key], state))
  10211. .join(',');
  10212. return `scopedSlots:_u([${generatedSlots}]${
  10213. needsForceUpdate ? `,null,true` : ``
  10214. }${
  10215. !needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``
  10216. })`
  10217. }
  10218. function hash(str) {
  10219. let hash = 5381;
  10220. let i = str.length;
  10221. while(i) {
  10222. hash = (hash * 33) ^ str.charCodeAt(--i);
  10223. }
  10224. return hash >>> 0
  10225. }
  10226. function containsSlotChild (el) {
  10227. if (el.type === 1) {
  10228. if (el.tag === 'slot') {
  10229. return true
  10230. }
  10231. return el.children.some(containsSlotChild)
  10232. }
  10233. return false
  10234. }
  10235. function genScopedSlot (
  10236. el,
  10237. state
  10238. ) {
  10239. const isLegacySyntax = el.attrsMap['slot-scope'];
  10240. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  10241. return genIf(el, state, genScopedSlot, `null`)
  10242. }
  10243. if (el.for && !el.forProcessed) {
  10244. return genFor(el, state, genScopedSlot)
  10245. }
  10246. const slotScope = el.slotScope === emptySlotScopeToken
  10247. ? ``
  10248. : String(el.slotScope);
  10249. const fn = `function(${slotScope}){` +
  10250. `return ${el.tag === 'template'
  10251. ? el.if && isLegacySyntax
  10252. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  10253. : genChildren(el, state) || 'undefined'
  10254. : genElement(el, state)
  10255. }}`;
  10256. // reverse proxy v-slot without scope on this.$slots
  10257. const reverseProxy = slotScope ? `` : `,proxy:true`;
  10258. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`
  10259. }
  10260. function genChildren (
  10261. el,
  10262. state,
  10263. checkSkip,
  10264. altGenElement,
  10265. altGenNode
  10266. ) {
  10267. const children = el.children;
  10268. if (children.length) {
  10269. const el = children[0];
  10270. // optimize single v-for
  10271. if (children.length === 1 &&
  10272. el.for &&
  10273. el.tag !== 'template' &&
  10274. el.tag !== 'slot'
  10275. ) {
  10276. const normalizationType = checkSkip
  10277. ? state.maybeComponent(el) ? `,1` : `,0`
  10278. : ``;
  10279. return `${(altGenElement || genElement)(el, state)}${normalizationType}`
  10280. }
  10281. const normalizationType = checkSkip
  10282. ? getNormalizationType(children, state.maybeComponent)
  10283. : 0;
  10284. const gen = altGenNode || genNode;
  10285. return `[${children.map(c => gen(c, state)).join(',')}]${
  10286. normalizationType ? `,${normalizationType}` : ''
  10287. }`
  10288. }
  10289. }
  10290. // determine the normalization needed for the children array.
  10291. // 0: no normalization needed
  10292. // 1: simple normalization needed (possible 1-level deep nested array)
  10293. // 2: full normalization needed
  10294. function getNormalizationType (
  10295. children,
  10296. maybeComponent
  10297. ) {
  10298. let res = 0;
  10299. for (let i = 0; i < children.length; i++) {
  10300. const el = children[i];
  10301. if (el.type !== 1) {
  10302. continue
  10303. }
  10304. if (needsNormalization(el) ||
  10305. (el.ifConditions && el.ifConditions.some(c => needsNormalization(c.block)))) {
  10306. res = 2;
  10307. break
  10308. }
  10309. if (maybeComponent(el) ||
  10310. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  10311. res = 1;
  10312. }
  10313. }
  10314. return res
  10315. }
  10316. function needsNormalization (el) {
  10317. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  10318. }
  10319. function genNode (node, state) {
  10320. if (node.type === 1) {
  10321. return genElement(node, state)
  10322. } else if (node.type === 3 && node.isComment) {
  10323. return genComment(node)
  10324. } else {
  10325. return genText(node)
  10326. }
  10327. }
  10328. function genText (text) {
  10329. return `_v(${text.type === 2
  10330. ? text.expression // no need for () because already wrapped in _s()
  10331. : transformSpecialNewlines(JSON.stringify(text.text))
  10332. })`
  10333. }
  10334. function genComment (comment) {
  10335. return `_e(${JSON.stringify(comment.text)})`
  10336. }
  10337. function genSlot (el, state) {
  10338. const slotName = el.slotName || '"default"';
  10339. const children = genChildren(el, state);
  10340. let res = `_t(${slotName}${children ? `,${children}` : ''}`;
  10341. const attrs = el.attrs || el.dynamicAttrs
  10342. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  10343. // slot props are camelized
  10344. name: camelize(attr.name),
  10345. value: attr.value,
  10346. dynamic: attr.dynamic
  10347. })))
  10348. : null;
  10349. const bind$$1 = el.attrsMap['v-bind'];
  10350. if ((attrs || bind$$1) && !children) {
  10351. res += `,null`;
  10352. }
  10353. if (attrs) {
  10354. res += `,${attrs}`;
  10355. }
  10356. if (bind$$1) {
  10357. res += `${attrs ? '' : ',null'},${bind$$1}`;
  10358. }
  10359. return res + ')'
  10360. }
  10361. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  10362. function genComponent (
  10363. componentName,
  10364. el,
  10365. state
  10366. ) {
  10367. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  10368. return `_c(${componentName},${genData$2(el, state)}${
  10369. children ? `,${children}` : ''
  10370. })`
  10371. }
  10372. function genProps (props) {
  10373. let staticProps = ``;
  10374. let dynamicProps = ``;
  10375. for (let i = 0; i < props.length; i++) {
  10376. const prop = props[i];
  10377. const value = transformSpecialNewlines(prop.value);
  10378. if (prop.dynamic) {
  10379. dynamicProps += `${prop.name},${value},`;
  10380. } else {
  10381. staticProps += `"${prop.name}":${value},`;
  10382. }
  10383. }
  10384. staticProps = `{${staticProps.slice(0, -1)}}`;
  10385. if (dynamicProps) {
  10386. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`
  10387. } else {
  10388. return staticProps
  10389. }
  10390. }
  10391. // #3895, #4268
  10392. function transformSpecialNewlines (text) {
  10393. return text
  10394. .replace(/\u2028/g, '\\u2028')
  10395. .replace(/\u2029/g, '\\u2029')
  10396. }
  10397. /* */
  10398. // these keywords should not appear inside expressions, but operators like
  10399. // typeof, instanceof and in are allowed
  10400. const prohibitedKeywordRE = new RegExp('\\b' + (
  10401. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  10402. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  10403. 'extends,finally,continue,debugger,function,arguments'
  10404. ).split(',').join('\\b|\\b') + '\\b');
  10405. // these unary operators should not be used as property/method names
  10406. const unaryOperatorsRE = new RegExp('\\b' + (
  10407. 'delete,typeof,void'
  10408. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  10409. // strip strings in expressions
  10410. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  10411. // detect problematic expressions in a template
  10412. function detectErrors (ast, warn) {
  10413. if (ast) {
  10414. checkNode(ast, warn);
  10415. }
  10416. }
  10417. function checkNode (node, warn) {
  10418. if (node.type === 1) {
  10419. for (const name in node.attrsMap) {
  10420. if (dirRE.test(name)) {
  10421. const value = node.attrsMap[name];
  10422. if (value) {
  10423. const range = node.rawAttrsMap[name];
  10424. if (name === 'v-for') {
  10425. checkFor(node, `v-for="${value}"`, warn, range);
  10426. } else if (onRE.test(name)) {
  10427. checkEvent(value, `${name}="${value}"`, warn, range);
  10428. } else {
  10429. checkExpression(value, `${name}="${value}"`, warn, range);
  10430. }
  10431. }
  10432. }
  10433. }
  10434. if (node.children) {
  10435. for (let i = 0; i < node.children.length; i++) {
  10436. checkNode(node.children[i], warn);
  10437. }
  10438. }
  10439. } else if (node.type === 2) {
  10440. checkExpression(node.expression, node.text, warn, node);
  10441. }
  10442. }
  10443. function checkEvent (exp, text, warn, range) {
  10444. const stipped = exp.replace(stripStringRE, '');
  10445. const keywordMatch = stipped.match(unaryOperatorsRE);
  10446. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  10447. warn(
  10448. `avoid using JavaScript unary operator as property name: ` +
  10449. `"${keywordMatch[0]}" in expression ${text.trim()}`,
  10450. range
  10451. );
  10452. }
  10453. checkExpression(exp, text, warn, range);
  10454. }
  10455. function checkFor (node, text, warn, range) {
  10456. checkExpression(node.for || '', text, warn, range);
  10457. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  10458. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  10459. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  10460. }
  10461. function checkIdentifier (
  10462. ident,
  10463. type,
  10464. text,
  10465. warn,
  10466. range
  10467. ) {
  10468. if (typeof ident === 'string') {
  10469. try {
  10470. new Function(`var ${ident}=_`);
  10471. } catch (e) {
  10472. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  10473. }
  10474. }
  10475. }
  10476. function checkExpression (exp, text, warn, range) {
  10477. try {
  10478. new Function(`return ${exp}`);
  10479. } catch (e) {
  10480. const keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  10481. if (keywordMatch) {
  10482. warn(
  10483. `avoid using JavaScript keyword as property name: ` +
  10484. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`,
  10485. range
  10486. );
  10487. } else {
  10488. warn(
  10489. `invalid expression: ${e.message} in\n\n` +
  10490. ` ${exp}\n\n` +
  10491. ` Raw expression: ${text.trim()}\n`,
  10492. range
  10493. );
  10494. }
  10495. }
  10496. }
  10497. /* */
  10498. const range = 2;
  10499. function generateCodeFrame (
  10500. source,
  10501. start = 0,
  10502. end = source.length
  10503. ) {
  10504. const lines = source.split(/\r?\n/);
  10505. let count = 0;
  10506. const res = [];
  10507. for (let i = 0; i < lines.length; i++) {
  10508. count += lines[i].length + 1;
  10509. if (count >= start) {
  10510. for (let j = i - range; j <= i + range || end > count; j++) {
  10511. if (j < 0 || j >= lines.length) continue
  10512. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  10513. const lineLength = lines[j].length;
  10514. if (j === i) {
  10515. // push underline
  10516. const pad = start - (count - lineLength) + 1;
  10517. const length = end > count ? lineLength - pad : end - start;
  10518. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  10519. } else if (j > i) {
  10520. if (end > count) {
  10521. const length = Math.min(end - count, lineLength);
  10522. res.push(` | ` + repeat(`^`, length));
  10523. }
  10524. count += lineLength + 1;
  10525. }
  10526. }
  10527. break
  10528. }
  10529. }
  10530. return res.join('\n')
  10531. }
  10532. function repeat (str, n) {
  10533. let result = '';
  10534. if (n > 0) {
  10535. while (true) { // eslint-disable-line
  10536. if (n & 1) result += str;
  10537. n >>>= 1;
  10538. if (n <= 0) break
  10539. str += str;
  10540. }
  10541. }
  10542. return result
  10543. }
  10544. /* */
  10545. function createFunction (code, errors) {
  10546. try {
  10547. return new Function(code)
  10548. } catch (err) {
  10549. errors.push({ err, code });
  10550. return noop
  10551. }
  10552. }
  10553. function createCompileToFunctionFn (compile) {
  10554. const cache = Object.create(null);
  10555. return function compileToFunctions (
  10556. template,
  10557. options,
  10558. vm
  10559. ) {
  10560. options = extend({}, options);
  10561. const warn$$1 = options.warn || warn;
  10562. delete options.warn;
  10563. /* istanbul ignore if */
  10564. {
  10565. // detect possible CSP restriction
  10566. try {
  10567. new Function('return 1');
  10568. } catch (e) {
  10569. if (e.toString().match(/unsafe-eval|CSP/)) {
  10570. warn$$1(
  10571. 'It seems you are using the standalone build of Vue.js in an ' +
  10572. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  10573. 'The template compiler cannot work in this environment. Consider ' +
  10574. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  10575. 'templates into render functions.'
  10576. );
  10577. }
  10578. }
  10579. }
  10580. // check cache
  10581. const key = options.delimiters
  10582. ? String(options.delimiters) + template
  10583. : template;
  10584. if (cache[key]) {
  10585. return cache[key]
  10586. }
  10587. // compile
  10588. const compiled = compile(template, options);
  10589. // check compilation errors/tips
  10590. {
  10591. if (compiled.errors && compiled.errors.length) {
  10592. if (options.outputSourceRange) {
  10593. compiled.errors.forEach(e => {
  10594. warn$$1(
  10595. `Error compiling template:\n\n${e.msg}\n\n` +
  10596. generateCodeFrame(template, e.start, e.end),
  10597. vm
  10598. );
  10599. });
  10600. } else {
  10601. warn$$1(
  10602. `Error compiling template:\n\n${template}\n\n` +
  10603. compiled.errors.map(e => `- ${e}`).join('\n') + '\n',
  10604. vm
  10605. );
  10606. }
  10607. }
  10608. if (compiled.tips && compiled.tips.length) {
  10609. if (options.outputSourceRange) {
  10610. compiled.tips.forEach(e => tip(e.msg, vm));
  10611. } else {
  10612. compiled.tips.forEach(msg => tip(msg, vm));
  10613. }
  10614. }
  10615. }
  10616. // turn code into functions
  10617. const res = {};
  10618. const fnGenErrors = [];
  10619. res.render = createFunction(compiled.render, fnGenErrors);
  10620. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  10621. return createFunction(code, fnGenErrors)
  10622. });
  10623. // check function generation errors.
  10624. // this should only happen if there is a bug in the compiler itself.
  10625. // mostly for codegen development use
  10626. /* istanbul ignore if */
  10627. {
  10628. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  10629. warn$$1(
  10630. `Failed to generate render function:\n\n` +
  10631. fnGenErrors.map(({ err, code }) => `${err.toString()} in\n\n${code}\n`).join('\n'),
  10632. vm
  10633. );
  10634. }
  10635. }
  10636. return (cache[key] = res)
  10637. }
  10638. }
  10639. /* */
  10640. function createCompilerCreator (baseCompile) {
  10641. return function createCompiler (baseOptions) {
  10642. function compile (
  10643. template,
  10644. options
  10645. ) {
  10646. const finalOptions = Object.create(baseOptions);
  10647. const errors = [];
  10648. const tips = [];
  10649. let warn = (msg, range, tip) => {
  10650. (tip ? tips : errors).push(msg);
  10651. };
  10652. if (options) {
  10653. if (options.outputSourceRange) {
  10654. // $flow-disable-line
  10655. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  10656. warn = (msg, range, tip) => {
  10657. const data = { msg };
  10658. if (range) {
  10659. if (range.start != null) {
  10660. data.start = range.start + leadingSpaceLength;
  10661. }
  10662. if (range.end != null) {
  10663. data.end = range.end + leadingSpaceLength;
  10664. }
  10665. }
  10666. (tip ? tips : errors).push(data);
  10667. };
  10668. }
  10669. // merge custom modules
  10670. if (options.modules) {
  10671. finalOptions.modules =
  10672. (baseOptions.modules || []).concat(options.modules);
  10673. }
  10674. // merge custom directives
  10675. if (options.directives) {
  10676. finalOptions.directives = extend(
  10677. Object.create(baseOptions.directives || null),
  10678. options.directives
  10679. );
  10680. }
  10681. // copy other options
  10682. for (const key in options) {
  10683. if (key !== 'modules' && key !== 'directives') {
  10684. finalOptions[key] = options[key];
  10685. }
  10686. }
  10687. }
  10688. finalOptions.warn = warn;
  10689. const compiled = baseCompile(template.trim(), finalOptions);
  10690. {
  10691. detectErrors(compiled.ast, warn);
  10692. }
  10693. compiled.errors = errors;
  10694. compiled.tips = tips;
  10695. return compiled
  10696. }
  10697. return {
  10698. compile,
  10699. compileToFunctions: createCompileToFunctionFn(compile)
  10700. }
  10701. }
  10702. }
  10703. /* */
  10704. // `createCompilerCreator` allows creating compilers that use alternative
  10705. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  10706. // Here we just export a default compiler using the default parts.
  10707. const createCompiler = createCompilerCreator(function baseCompile (
  10708. template,
  10709. options
  10710. ) {
  10711. const ast = parse(template.trim(), options);
  10712. if (options.optimize !== false) {
  10713. optimize(ast, options);
  10714. }
  10715. const code = generate(ast, options);
  10716. return {
  10717. ast,
  10718. render: code.render,
  10719. staticRenderFns: code.staticRenderFns
  10720. }
  10721. });
  10722. /* */
  10723. const { compile, compileToFunctions } = createCompiler(baseOptions);
  10724. /* */
  10725. // check whether current browser encodes a char inside attribute values
  10726. let div;
  10727. function getShouldDecode (href) {
  10728. div = div || document.createElement('div');
  10729. div.innerHTML = href ? `<a href="\n"/>` : `<div a="\n"/>`;
  10730. return div.innerHTML.indexOf('&#10;') > 0
  10731. }
  10732. // #3663: IE encodes newlines inside attribute values while other browsers don't
  10733. const shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  10734. // #6828: chrome encodes content in a[href]
  10735. const shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  10736. /* */
  10737. const idToTemplate = cached(id => {
  10738. const el = query(id);
  10739. return el && el.innerHTML
  10740. });
  10741. const mount = Vue.prototype.$mount;
  10742. Vue.prototype.$mount = function (
  10743. el,
  10744. hydrating
  10745. ) {
  10746. el = el && query(el);
  10747. /* istanbul ignore if */
  10748. if (el === document.body || el === document.documentElement) {
  10749. warn(
  10750. `Do not mount Vue to <html> or <body> - mount to normal elements instead.`
  10751. );
  10752. return this
  10753. }
  10754. const options = this.$options;
  10755. // resolve template/el and convert to render function
  10756. if (!options.render) {
  10757. let template = options.template;
  10758. if (template) {
  10759. if (typeof template === 'string') {
  10760. if (template.charAt(0) === '#') {
  10761. template = idToTemplate(template);
  10762. /* istanbul ignore if */
  10763. if (!template) {
  10764. warn(
  10765. `Template element not found or is empty: ${options.template}`,
  10766. this
  10767. );
  10768. }
  10769. }
  10770. } else if (template.nodeType) {
  10771. template = template.innerHTML;
  10772. } else {
  10773. {
  10774. warn('invalid template option:' + template, this);
  10775. }
  10776. return this
  10777. }
  10778. } else if (el) {
  10779. template = getOuterHTML(el);
  10780. }
  10781. if (template) {
  10782. /* istanbul ignore if */
  10783. if (config.performance && mark) {
  10784. mark('compile');
  10785. }
  10786. const { render, staticRenderFns } = compileToFunctions(template, {
  10787. outputSourceRange: "development" !== 'production',
  10788. shouldDecodeNewlines,
  10789. shouldDecodeNewlinesForHref,
  10790. delimiters: options.delimiters,
  10791. comments: options.comments
  10792. }, this);
  10793. options.render = render;
  10794. options.staticRenderFns = staticRenderFns;
  10795. /* istanbul ignore if */
  10796. if (config.performance && mark) {
  10797. mark('compile end');
  10798. measure(`vue ${this._name} compile`, 'compile', 'compile end');
  10799. }
  10800. }
  10801. }
  10802. return mount.call(this, el, hydrating)
  10803. };
  10804. /**
  10805. * Get outerHTML of elements, taking care
  10806. * of SVG elements in IE as well.
  10807. */
  10808. function getOuterHTML (el) {
  10809. if (el.outerHTML) {
  10810. return el.outerHTML
  10811. } else {
  10812. const container = document.createElement('div');
  10813. container.appendChild(el.cloneNode(true));
  10814. return container.innerHTML
  10815. }
  10816. }
  10817. Vue.compile = compileToFunctions;
  10818. export default Vue;