build.dev.js 246 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var he = _interopDefault(require('he'));
  5. /* */
  6. var emptyObject = Object.freeze({});
  7. // These helpers produce better VM code in JS engines due to their
  8. // explicitness and function inlining.
  9. function isUndef (v) {
  10. return v === undefined || v === null
  11. }
  12. function isDef (v) {
  13. return v !== undefined && v !== null
  14. }
  15. function isTrue (v) {
  16. return v === true
  17. }
  18. function isFalse (v) {
  19. return v === false
  20. }
  21. /**
  22. * Check if value is primitive.
  23. */
  24. function isPrimitive (value) {
  25. return (
  26. typeof value === 'string' ||
  27. typeof value === 'number' ||
  28. // $flow-disable-line
  29. typeof value === 'symbol' ||
  30. typeof value === 'boolean'
  31. )
  32. }
  33. /**
  34. * Quick object check - this is primarily used to tell
  35. * Objects from primitive values when we know the value
  36. * is a JSON-compliant type.
  37. */
  38. function isObject (obj) {
  39. return obj !== null && typeof obj === 'object'
  40. }
  41. /**
  42. * Get the raw type string of a value, e.g., [object Object].
  43. */
  44. var _toString = Object.prototype.toString;
  45. function toRawType (value) {
  46. return _toString.call(value).slice(8, -1)
  47. }
  48. /**
  49. * Strict object type check. Only returns true
  50. * for plain JavaScript objects.
  51. */
  52. function isPlainObject (obj) {
  53. return _toString.call(obj) === '[object Object]'
  54. }
  55. /**
  56. * Check if val is a valid array index.
  57. */
  58. function isValidArrayIndex (val) {
  59. var n = parseFloat(String(val));
  60. return n >= 0 && Math.floor(n) === n && isFinite(val)
  61. }
  62. function isPromise (val) {
  63. return (
  64. isDef(val) &&
  65. typeof val.then === 'function' &&
  66. typeof val.catch === 'function'
  67. )
  68. }
  69. /**
  70. * Convert a value to a string that is actually rendered.
  71. */
  72. function toString (val) {
  73. return val == null
  74. ? ''
  75. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  76. ? JSON.stringify(val, null, 2)
  77. : String(val)
  78. }
  79. /**
  80. * Convert an input value to a number for persistence.
  81. * If the conversion fails, return original string.
  82. */
  83. function toNumber (val) {
  84. var n = parseFloat(val);
  85. return isNaN(n) ? val : n
  86. }
  87. /**
  88. * Make a map and return a function for checking if a key
  89. * is in that map.
  90. */
  91. function makeMap (
  92. str,
  93. expectsLowerCase
  94. ) {
  95. var map = Object.create(null);
  96. var list = str.split(',');
  97. for (var i = 0; i < list.length; i++) {
  98. map[list[i]] = true;
  99. }
  100. return expectsLowerCase
  101. ? function (val) { return map[val.toLowerCase()]; }
  102. : function (val) { return map[val]; }
  103. }
  104. /**
  105. * Check if a tag is a built-in tag.
  106. */
  107. var isBuiltInTag = makeMap('slot,component', true);
  108. /**
  109. * Check if an attribute is a reserved attribute.
  110. */
  111. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  112. /**
  113. * Remove an item from an array.
  114. */
  115. function remove (arr, item) {
  116. if (arr.length) {
  117. var index = arr.indexOf(item);
  118. if (index > -1) {
  119. return arr.splice(index, 1)
  120. }
  121. }
  122. }
  123. /**
  124. * Check whether an object has the property.
  125. */
  126. var hasOwnProperty = Object.prototype.hasOwnProperty;
  127. function hasOwn (obj, key) {
  128. return hasOwnProperty.call(obj, key)
  129. }
  130. /**
  131. * Create a cached version of a pure function.
  132. */
  133. function cached (fn) {
  134. var cache = Object.create(null);
  135. return (function cachedFn (str) {
  136. var hit = cache[str];
  137. return hit || (cache[str] = fn(str))
  138. })
  139. }
  140. /**
  141. * Camelize a hyphen-delimited string.
  142. */
  143. var camelizeRE = /-(\w)/g;
  144. var camelize = cached(function (str) {
  145. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  146. });
  147. /**
  148. * Capitalize a string.
  149. */
  150. var capitalize = cached(function (str) {
  151. return str.charAt(0).toUpperCase() + str.slice(1)
  152. });
  153. /**
  154. * Hyphenate a camelCase string.
  155. */
  156. var hyphenateRE = /\B([A-Z])/g;
  157. var hyphenate = cached(function (str) {
  158. return str.replace(hyphenateRE, '-$1').toLowerCase()
  159. });
  160. /**
  161. * Simple bind polyfill for environments that do not support it,
  162. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  163. * since native bind is now performant enough in most browsers.
  164. * But removing it would mean breaking code that was able to run in
  165. * PhantomJS 1.x, so this must be kept for backward compatibility.
  166. */
  167. /* istanbul ignore next */
  168. function polyfillBind (fn, ctx) {
  169. function boundFn (a) {
  170. var l = arguments.length;
  171. return l
  172. ? l > 1
  173. ? fn.apply(ctx, arguments)
  174. : fn.call(ctx, a)
  175. : fn.call(ctx)
  176. }
  177. boundFn._length = fn.length;
  178. return boundFn
  179. }
  180. function nativeBind (fn, ctx) {
  181. return fn.bind(ctx)
  182. }
  183. var bind = Function.prototype.bind
  184. ? nativeBind
  185. : polyfillBind;
  186. /**
  187. * Mix properties into target object.
  188. */
  189. function extend (to, _from) {
  190. for (var key in _from) {
  191. to[key] = _from[key];
  192. }
  193. return to
  194. }
  195. /**
  196. * Merge an Array of Objects into a single Object.
  197. */
  198. function toObject (arr) {
  199. var res = {};
  200. for (var i = 0; i < arr.length; i++) {
  201. if (arr[i]) {
  202. extend(res, arr[i]);
  203. }
  204. }
  205. return res
  206. }
  207. /* eslint-disable no-unused-vars */
  208. /**
  209. * Perform no operation.
  210. * Stubbing args to make Flow happy without leaving useless transpiled code
  211. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  212. */
  213. function noop (a, b, c) {}
  214. /**
  215. * Always return false.
  216. */
  217. var no = function (a, b, c) { return false; };
  218. /* eslint-enable no-unused-vars */
  219. /**
  220. * Return the same value.
  221. */
  222. var identity = function (_) { return _; };
  223. /**
  224. * Generate a string containing static keys from compiler modules.
  225. */
  226. function genStaticKeys (modules) {
  227. return modules.reduce(function (keys, m) {
  228. return keys.concat(m.staticKeys || [])
  229. }, []).join(',')
  230. }
  231. /**
  232. * Check if two values are loosely equal - that is,
  233. * if they are plain objects, do they have the same shape?
  234. */
  235. function looseEqual (a, b) {
  236. if (a === b) { return true }
  237. var isObjectA = isObject(a);
  238. var isObjectB = isObject(b);
  239. if (isObjectA && isObjectB) {
  240. try {
  241. var isArrayA = Array.isArray(a);
  242. var isArrayB = Array.isArray(b);
  243. if (isArrayA && isArrayB) {
  244. return a.length === b.length && a.every(function (e, i) {
  245. return looseEqual(e, b[i])
  246. })
  247. } else if (a instanceof Date && b instanceof Date) {
  248. return a.getTime() === b.getTime()
  249. } else if (!isArrayA && !isArrayB) {
  250. var keysA = Object.keys(a);
  251. var keysB = Object.keys(b);
  252. return keysA.length === keysB.length && keysA.every(function (key) {
  253. return looseEqual(a[key], b[key])
  254. })
  255. } else {
  256. /* istanbul ignore next */
  257. return false
  258. }
  259. } catch (e) {
  260. /* istanbul ignore next */
  261. return false
  262. }
  263. } else if (!isObjectA && !isObjectB) {
  264. return String(a) === String(b)
  265. } else {
  266. return false
  267. }
  268. }
  269. /**
  270. * Return the first index at which a loosely equal value can be
  271. * found in the array (if value is a plain object, the array must
  272. * contain an object of the same shape), or -1 if it is not present.
  273. */
  274. function looseIndexOf (arr, val) {
  275. for (var i = 0; i < arr.length; i++) {
  276. if (looseEqual(arr[i], val)) { return i }
  277. }
  278. return -1
  279. }
  280. /**
  281. * Ensure a function is called only once.
  282. */
  283. function once (fn) {
  284. var called = false;
  285. return function () {
  286. if (!called) {
  287. called = true;
  288. fn.apply(this, arguments);
  289. }
  290. }
  291. }
  292. /* */
  293. var isAttr = makeMap(
  294. 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
  295. 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
  296. 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' +
  297. 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' +
  298. 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' +
  299. 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
  300. 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
  301. 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
  302. 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
  303. 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
  304. 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
  305. 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
  306. 'target,title,type,usemap,value,width,wrap'
  307. );
  308. var unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/; // eslint-disable-line no-control-regex
  309. var isSSRUnsafeAttr = function (name) {
  310. return unsafeAttrCharRE.test(name)
  311. };
  312. /* istanbul ignore next */
  313. var isRenderableAttr = function (name) {
  314. return (
  315. isAttr(name) ||
  316. name.indexOf('data-') === 0 ||
  317. name.indexOf('aria-') === 0
  318. )
  319. };
  320. var propsToAttrMap = {
  321. acceptCharset: 'accept-charset',
  322. className: 'class',
  323. htmlFor: 'for',
  324. httpEquiv: 'http-equiv'
  325. };
  326. var ESC = {
  327. '<': '&lt;',
  328. '>': '&gt;',
  329. '"': '&quot;',
  330. '&': '&amp;'
  331. };
  332. function escape (s) {
  333. return s.replace(/[<>"&]/g, escapeChar)
  334. }
  335. function escapeChar (a) {
  336. return ESC[a] || a
  337. }
  338. var noUnitNumericStyleProps = {
  339. "animation-iteration-count": true,
  340. "border-image-outset": true,
  341. "border-image-slice": true,
  342. "border-image-width": true,
  343. "box-flex": true,
  344. "box-flex-group": true,
  345. "box-ordinal-group": true,
  346. "column-count": true,
  347. "columns": true,
  348. "flex": true,
  349. "flex-grow": true,
  350. "flex-positive": true,
  351. "flex-shrink": true,
  352. "flex-negative": true,
  353. "flex-order": true,
  354. "grid-row": true,
  355. "grid-row-end": true,
  356. "grid-row-span": true,
  357. "grid-row-start": true,
  358. "grid-column": true,
  359. "grid-column-end": true,
  360. "grid-column-span": true,
  361. "grid-column-start": true,
  362. "font-weight": true,
  363. "line-clamp": true,
  364. "line-height": true,
  365. "opacity": true,
  366. "order": true,
  367. "orphans": true,
  368. "tab-size": true,
  369. "widows": true,
  370. "z-index": true,
  371. "zoom": true,
  372. // SVG
  373. "fill-opacity": true,
  374. "flood-opacity": true,
  375. "stop-opacity": true,
  376. "stroke-dasharray": true,
  377. "stroke-dashoffset": true,
  378. "stroke-miterlimit": true,
  379. "stroke-opacity": true,
  380. "stroke-width": true
  381. };
  382. /* */
  383. // these are reserved for web because they are directly compiled away
  384. // during template compilation
  385. var isReservedAttr = makeMap('style,class');
  386. // attributes that should be using props for binding
  387. var acceptValue = makeMap('input,textarea,option,select,progress');
  388. var mustUseProp = function (tag, type, attr) {
  389. return (
  390. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  391. (attr === 'selected' && tag === 'option') ||
  392. (attr === 'checked' && tag === 'input') ||
  393. (attr === 'muted' && tag === 'video')
  394. )
  395. };
  396. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  397. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  398. var convertEnumeratedValue = function (key, value) {
  399. return isFalsyAttrValue(value) || value === 'false'
  400. ? 'false'
  401. // allow arbitrary string value for contenteditable
  402. : key === 'contenteditable' && isValidContentEditableValue(value)
  403. ? value
  404. : 'true'
  405. };
  406. var isBooleanAttr = makeMap(
  407. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  408. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  409. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  410. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  411. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  412. 'truespeed,typemustmatch,visible'
  413. );
  414. var isFalsyAttrValue = function (val) {
  415. return val == null || val === false
  416. };
  417. /* */
  418. function renderAttrs (node) {
  419. var attrs = node.data.attrs;
  420. var res = '';
  421. var opts = node.parent && node.parent.componentOptions;
  422. if (isUndef(opts) || opts.Ctor.options.inheritAttrs !== false) {
  423. var parent = node.parent;
  424. while (isDef(parent)) {
  425. if (isDef(parent.data) && isDef(parent.data.attrs)) {
  426. attrs = extend(extend({}, attrs), parent.data.attrs);
  427. }
  428. parent = parent.parent;
  429. }
  430. }
  431. if (isUndef(attrs)) {
  432. return res
  433. }
  434. for (var key in attrs) {
  435. if (isSSRUnsafeAttr(key)) {
  436. continue
  437. }
  438. if (key === 'style') {
  439. // leave it to the style module
  440. continue
  441. }
  442. res += renderAttr(key, attrs[key]);
  443. }
  444. return res
  445. }
  446. function renderAttr (key, value) {
  447. if (isBooleanAttr(key)) {
  448. if (!isFalsyAttrValue(value)) {
  449. return (" " + key + "=\"" + key + "\"")
  450. }
  451. } else if (isEnumeratedAttr(key)) {
  452. return (" " + key + "=\"" + (escape(convertEnumeratedValue(key, value))) + "\"")
  453. } else if (!isFalsyAttrValue(value)) {
  454. return (" " + key + "=\"" + (escape(String(value))) + "\"")
  455. }
  456. return ''
  457. }
  458. /* */
  459. var VNode = function VNode (
  460. tag,
  461. data,
  462. children,
  463. text,
  464. elm,
  465. context,
  466. componentOptions,
  467. asyncFactory
  468. ) {
  469. this.tag = tag;
  470. this.data = data;
  471. this.children = children;
  472. this.text = text;
  473. this.elm = elm;
  474. this.ns = undefined;
  475. this.context = context;
  476. this.fnContext = undefined;
  477. this.fnOptions = undefined;
  478. this.fnScopeId = undefined;
  479. this.key = data && data.key;
  480. this.componentOptions = componentOptions;
  481. this.componentInstance = undefined;
  482. this.parent = undefined;
  483. this.raw = false;
  484. this.isStatic = false;
  485. this.isRootInsert = true;
  486. this.isComment = false;
  487. this.isCloned = false;
  488. this.isOnce = false;
  489. this.asyncFactory = asyncFactory;
  490. this.asyncMeta = undefined;
  491. this.isAsyncPlaceholder = false;
  492. };
  493. var prototypeAccessors = { child: { configurable: true } };
  494. // DEPRECATED: alias for componentInstance for backwards compat.
  495. /* istanbul ignore next */
  496. prototypeAccessors.child.get = function () {
  497. return this.componentInstance
  498. };
  499. Object.defineProperties( VNode.prototype, prototypeAccessors );
  500. var createEmptyVNode = function (text) {
  501. if ( text === void 0 ) text = '';
  502. var node = new VNode();
  503. node.text = text;
  504. node.isComment = true;
  505. return node
  506. };
  507. function createTextVNode (val) {
  508. return new VNode(undefined, undefined, undefined, String(val))
  509. }
  510. // optimized shallow clone
  511. // used for static nodes and slot nodes because they may be reused across
  512. // multiple renders, cloning them avoids errors when DOM manipulations rely
  513. // on their elm reference.
  514. function cloneVNode (vnode) {
  515. var cloned = new VNode(
  516. vnode.tag,
  517. vnode.data,
  518. // #7975
  519. // clone children array to avoid mutating original in case of cloning
  520. // a child.
  521. vnode.children && vnode.children.slice(),
  522. vnode.text,
  523. vnode.elm,
  524. vnode.context,
  525. vnode.componentOptions,
  526. vnode.asyncFactory
  527. );
  528. cloned.ns = vnode.ns;
  529. cloned.isStatic = vnode.isStatic;
  530. cloned.key = vnode.key;
  531. cloned.isComment = vnode.isComment;
  532. cloned.fnContext = vnode.fnContext;
  533. cloned.fnOptions = vnode.fnOptions;
  534. cloned.fnScopeId = vnode.fnScopeId;
  535. cloned.asyncMeta = vnode.asyncMeta;
  536. cloned.isCloned = true;
  537. return cloned
  538. }
  539. /* */
  540. function renderDOMProps (node) {
  541. var props = node.data.domProps;
  542. var res = '';
  543. var parent = node.parent;
  544. while (isDef(parent)) {
  545. if (parent.data && parent.data.domProps) {
  546. props = extend(extend({}, props), parent.data.domProps);
  547. }
  548. parent = parent.parent;
  549. }
  550. if (isUndef(props)) {
  551. return res
  552. }
  553. var attrs = node.data.attrs;
  554. for (var key in props) {
  555. if (key === 'innerHTML') {
  556. setText(node, props[key], true);
  557. } else if (key === 'textContent') {
  558. setText(node, props[key], false);
  559. } else if (key === 'value' && node.tag === 'textarea') {
  560. setText(node, props[key], false);
  561. } else {
  562. // $flow-disable-line (WTF?)
  563. var attr = propsToAttrMap[key] || key.toLowerCase();
  564. if (isRenderableAttr(attr) &&
  565. // avoid rendering double-bound props/attrs twice
  566. !(isDef(attrs) && isDef(attrs[attr]))
  567. ) {
  568. res += renderAttr(attr, props[key]);
  569. }
  570. }
  571. }
  572. return res
  573. }
  574. function setText (node, text, raw) {
  575. var child = new VNode(undefined, undefined, undefined, text);
  576. child.raw = raw;
  577. node.children = [child];
  578. }
  579. /* */
  580. /**
  581. * unicode letters used for parsing html tags, component names and property paths.
  582. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  583. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  584. */
  585. var 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/;
  586. /**
  587. * Define a property.
  588. */
  589. function def (obj, key, val, enumerable) {
  590. Object.defineProperty(obj, key, {
  591. value: val,
  592. enumerable: !!enumerable,
  593. writable: true,
  594. configurable: true
  595. });
  596. }
  597. /* */
  598. // can we use __proto__?
  599. var hasProto = '__proto__' in {};
  600. // Browser environment sniffing
  601. var inBrowser = typeof window !== 'undefined';
  602. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  603. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  604. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  605. var isIE = UA && /msie|trident/.test(UA);
  606. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  607. var isEdge = UA && UA.indexOf('edge/') > 0;
  608. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  609. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  610. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  611. var isPhantomJS = UA && /phantomjs/.test(UA);
  612. var isFF = UA && UA.match(/firefox\/(\d+)/);
  613. // Firefox has a "watch" function on Object.prototype...
  614. var nativeWatch = ({}).watch;
  615. if (inBrowser) {
  616. try {
  617. var opts = {};
  618. Object.defineProperty(opts, 'passive', ({
  619. get: function get () {
  620. }
  621. })); // https://github.com/facebook/flow/issues/285
  622. window.addEventListener('test-passive', null, opts);
  623. } catch (e) {}
  624. }
  625. // this needs to be lazy-evaled because vue may be required before
  626. // vue-server-renderer can set VUE_ENV
  627. var _isServer;
  628. var isServerRendering = function () {
  629. if (_isServer === undefined) {
  630. /* istanbul ignore if */
  631. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  632. // detect presence of vue-server-renderer and avoid
  633. // Webpack shimming the process
  634. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  635. } else {
  636. _isServer = false;
  637. }
  638. }
  639. return _isServer
  640. };
  641. // detect devtools
  642. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  643. /* istanbul ignore next */
  644. function isNative (Ctor) {
  645. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  646. }
  647. var hasSymbol =
  648. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  649. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  650. var _Set;
  651. /* istanbul ignore if */ // $flow-disable-line
  652. if (typeof Set !== 'undefined' && isNative(Set)) {
  653. // use native Set when available.
  654. _Set = Set;
  655. } else {
  656. // a non-standard Set polyfill that only works with primitive keys.
  657. _Set = /*@__PURE__*/(function () {
  658. function Set () {
  659. this.set = Object.create(null);
  660. }
  661. Set.prototype.has = function has (key) {
  662. return this.set[key] === true
  663. };
  664. Set.prototype.add = function add (key) {
  665. this.set[key] = true;
  666. };
  667. Set.prototype.clear = function clear () {
  668. this.set = Object.create(null);
  669. };
  670. return Set;
  671. }());
  672. }
  673. var SSR_ATTR = 'data-server-rendered';
  674. var ASSET_TYPES = [
  675. 'component',
  676. 'directive',
  677. 'filter'
  678. ];
  679. var LIFECYCLE_HOOKS = [
  680. 'beforeCreate',
  681. 'created',
  682. 'beforeMount',
  683. 'mounted',
  684. 'beforeUpdate',
  685. 'updated',
  686. 'beforeDestroy',
  687. 'destroyed',
  688. 'activated',
  689. 'deactivated',
  690. 'errorCaptured',
  691. 'serverPrefetch'
  692. ];
  693. /* */
  694. var config = ({
  695. /**
  696. * Option merge strategies (used in core/util/options)
  697. */
  698. // $flow-disable-line
  699. optionMergeStrategies: Object.create(null),
  700. /**
  701. * Whether to suppress warnings.
  702. */
  703. silent: false,
  704. /**
  705. * Show production mode tip message on boot?
  706. */
  707. productionTip: "development" !== 'production',
  708. /**
  709. * Whether to enable devtools
  710. */
  711. devtools: "development" !== 'production',
  712. /**
  713. * Whether to record perf
  714. */
  715. performance: false,
  716. /**
  717. * Error handler for watcher errors
  718. */
  719. errorHandler: null,
  720. /**
  721. * Warn handler for watcher warns
  722. */
  723. warnHandler: null,
  724. /**
  725. * Ignore certain custom elements
  726. */
  727. ignoredElements: [],
  728. /**
  729. * Custom user key aliases for v-on
  730. */
  731. // $flow-disable-line
  732. keyCodes: Object.create(null),
  733. /**
  734. * Check if a tag is reserved so that it cannot be registered as a
  735. * component. This is platform-dependent and may be overwritten.
  736. */
  737. isReservedTag: no,
  738. /**
  739. * Check if an attribute is reserved so that it cannot be used as a component
  740. * prop. This is platform-dependent and may be overwritten.
  741. */
  742. isReservedAttr: no,
  743. /**
  744. * Check if a tag is an unknown element.
  745. * Platform-dependent.
  746. */
  747. isUnknownElement: no,
  748. /**
  749. * Get the namespace of an element
  750. */
  751. getTagNamespace: noop,
  752. /**
  753. * Parse the real tag name for the specific platform.
  754. */
  755. parsePlatformTagName: identity,
  756. /**
  757. * Check if an attribute must be bound using property, e.g. value
  758. * Platform-dependent.
  759. */
  760. mustUseProp: no,
  761. /**
  762. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  763. * This will significantly reduce performance if set to false.
  764. */
  765. async: true,
  766. /**
  767. * Exposed for legacy reasons
  768. */
  769. _lifecycleHooks: LIFECYCLE_HOOKS
  770. });
  771. /* */
  772. var warn = noop;
  773. var tip = noop;
  774. var generateComponentTrace = (noop); // work around flow check
  775. var formatComponentName = (noop);
  776. {
  777. var hasConsole = typeof console !== 'undefined';
  778. var classifyRE = /(?:^|[-_])(\w)/g;
  779. var classify = function (str) { return str
  780. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  781. .replace(/[-_]/g, ''); };
  782. warn = function (msg, vm) {
  783. var trace = vm ? generateComponentTrace(vm) : '';
  784. if (hasConsole && (!config.silent)) {
  785. console.error(("[Vue warn]: " + msg + trace));
  786. }
  787. };
  788. tip = function (msg, vm) {
  789. if (hasConsole && (!config.silent)) {
  790. console.warn("[Vue tip]: " + msg + (
  791. vm ? generateComponentTrace(vm) : ''
  792. ));
  793. }
  794. };
  795. formatComponentName = function (vm, includeFile) {
  796. if (vm.$root === vm) {
  797. return '<Root>'
  798. }
  799. var options = typeof vm === 'function' && vm.cid != null
  800. ? vm.options
  801. : vm._isVue
  802. ? vm.$options || vm.constructor.options
  803. : vm;
  804. var name = options.name || options._componentTag;
  805. var file = options.__file;
  806. if (!name && file) {
  807. var match = file.match(/([^/\\]+)\.vue$/);
  808. name = match && match[1];
  809. }
  810. return (
  811. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  812. (file && includeFile !== false ? (" at " + file) : '')
  813. )
  814. };
  815. var repeat = function (str, n) {
  816. var res = '';
  817. while (n) {
  818. if (n % 2 === 1) { res += str; }
  819. if (n > 1) { str += str; }
  820. n >>= 1;
  821. }
  822. return res
  823. };
  824. generateComponentTrace = function (vm) {
  825. if (vm._isVue && vm.$parent) {
  826. var tree = [];
  827. var currentRecursiveSequence = 0;
  828. while (vm) {
  829. if (tree.length > 0) {
  830. var last = tree[tree.length - 1];
  831. if (last.constructor === vm.constructor) {
  832. currentRecursiveSequence++;
  833. vm = vm.$parent;
  834. continue
  835. } else if (currentRecursiveSequence > 0) {
  836. tree[tree.length - 1] = [last, currentRecursiveSequence];
  837. currentRecursiveSequence = 0;
  838. }
  839. }
  840. tree.push(vm);
  841. vm = vm.$parent;
  842. }
  843. return '\n\nfound in\n\n' + tree
  844. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  845. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  846. : formatComponentName(vm))); })
  847. .join('\n')
  848. } else {
  849. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  850. }
  851. };
  852. }
  853. /* */
  854. var uid = 0;
  855. /**
  856. * A dep is an observable that can have multiple
  857. * directives subscribing to it.
  858. */
  859. var Dep = function Dep () {
  860. this.id = uid++;
  861. this.subs = [];
  862. };
  863. Dep.prototype.addSub = function addSub (sub) {
  864. this.subs.push(sub);
  865. };
  866. Dep.prototype.removeSub = function removeSub (sub) {
  867. remove(this.subs, sub);
  868. };
  869. Dep.prototype.depend = function depend () {
  870. if (Dep.target) {
  871. Dep.target.addDep(this);
  872. }
  873. };
  874. Dep.prototype.notify = function notify () {
  875. // stabilize the subscriber list first
  876. var subs = this.subs.slice();
  877. for (var i = 0, l = subs.length; i < l; i++) {
  878. subs[i].update();
  879. }
  880. };
  881. // The current target watcher being evaluated.
  882. // This is globally unique because only one watcher
  883. // can be evaluated at a time.
  884. Dep.target = null;
  885. var targetStack = [];
  886. function pushTarget (target) {
  887. targetStack.push(target);
  888. Dep.target = target;
  889. }
  890. function popTarget () {
  891. targetStack.pop();
  892. Dep.target = targetStack[targetStack.length - 1];
  893. }
  894. /*
  895. * not type checking this file because flow doesn't play well with
  896. * dynamically accessing methods on Array prototype
  897. */
  898. var arrayProto = Array.prototype;
  899. var arrayMethods = Object.create(arrayProto);
  900. var methodsToPatch = [
  901. 'push',
  902. 'pop',
  903. 'shift',
  904. 'unshift',
  905. 'splice',
  906. 'sort',
  907. 'reverse'
  908. ];
  909. /**
  910. * Intercept mutating methods and emit events
  911. */
  912. methodsToPatch.forEach(function (method) {
  913. // cache original method
  914. var original = arrayProto[method];
  915. def(arrayMethods, method, function mutator () {
  916. var args = [], len = arguments.length;
  917. while ( len-- ) args[ len ] = arguments[ len ];
  918. var result = original.apply(this, args);
  919. var ob = this.__ob__;
  920. var inserted;
  921. switch (method) {
  922. case 'push':
  923. case 'unshift':
  924. inserted = args;
  925. break
  926. case 'splice':
  927. inserted = args.slice(2);
  928. break
  929. }
  930. if (inserted) { ob.observeArray(inserted); }
  931. // notify change
  932. ob.dep.notify();
  933. return result
  934. });
  935. });
  936. /* */
  937. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  938. /**
  939. * In some cases we may want to disable observation inside a component's
  940. * update computation.
  941. */
  942. var shouldObserve = true;
  943. function toggleObserving (value) {
  944. shouldObserve = value;
  945. }
  946. /**
  947. * Observer class that is attached to each observed
  948. * object. Once attached, the observer converts the target
  949. * object's property keys into getter/setters that
  950. * collect dependencies and dispatch updates.
  951. */
  952. var Observer = function Observer (value) {
  953. this.value = value;
  954. this.dep = new Dep();
  955. this.vmCount = 0;
  956. def(value, '__ob__', this);
  957. if (Array.isArray(value)) {
  958. if (hasProto) {
  959. protoAugment(value, arrayMethods);
  960. } else {
  961. copyAugment(value, arrayMethods, arrayKeys);
  962. }
  963. this.observeArray(value);
  964. } else {
  965. this.walk(value);
  966. }
  967. };
  968. /**
  969. * Walk through all properties and convert them into
  970. * getter/setters. This method should only be called when
  971. * value type is Object.
  972. */
  973. Observer.prototype.walk = function walk (obj) {
  974. var keys = Object.keys(obj);
  975. for (var i = 0; i < keys.length; i++) {
  976. defineReactive$$1(obj, keys[i]);
  977. }
  978. };
  979. /**
  980. * Observe a list of Array items.
  981. */
  982. Observer.prototype.observeArray = function observeArray (items) {
  983. for (var i = 0, l = items.length; i < l; i++) {
  984. observe(items[i]);
  985. }
  986. };
  987. // helpers
  988. /**
  989. * Augment a target Object or Array by intercepting
  990. * the prototype chain using __proto__
  991. */
  992. function protoAugment (target, src) {
  993. /* eslint-disable no-proto */
  994. target.__proto__ = src;
  995. /* eslint-enable no-proto */
  996. }
  997. /**
  998. * Augment a target Object or Array by defining
  999. * hidden properties.
  1000. */
  1001. /* istanbul ignore next */
  1002. function copyAugment (target, src, keys) {
  1003. for (var i = 0, l = keys.length; i < l; i++) {
  1004. var key = keys[i];
  1005. def(target, key, src[key]);
  1006. }
  1007. }
  1008. /**
  1009. * Attempt to create an observer instance for a value,
  1010. * returns the new observer if successfully observed,
  1011. * or the existing observer if the value already has one.
  1012. */
  1013. function observe (value, asRootData) {
  1014. if (!isObject(value) || value instanceof VNode) {
  1015. return
  1016. }
  1017. var ob;
  1018. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  1019. ob = value.__ob__;
  1020. } else if (
  1021. shouldObserve &&
  1022. !isServerRendering() &&
  1023. (Array.isArray(value) || isPlainObject(value)) &&
  1024. Object.isExtensible(value) &&
  1025. !value._isVue
  1026. ) {
  1027. ob = new Observer(value);
  1028. }
  1029. if (asRootData && ob) {
  1030. ob.vmCount++;
  1031. }
  1032. return ob
  1033. }
  1034. /**
  1035. * Define a reactive property on an Object.
  1036. */
  1037. function defineReactive$$1 (
  1038. obj,
  1039. key,
  1040. val,
  1041. customSetter,
  1042. shallow
  1043. ) {
  1044. var dep = new Dep();
  1045. var property = Object.getOwnPropertyDescriptor(obj, key);
  1046. if (property && property.configurable === false) {
  1047. return
  1048. }
  1049. // cater for pre-defined getter/setters
  1050. var getter = property && property.get;
  1051. var setter = property && property.set;
  1052. if ((!getter || setter) && arguments.length === 2) {
  1053. val = obj[key];
  1054. }
  1055. var childOb = !shallow && observe(val);
  1056. Object.defineProperty(obj, key, {
  1057. enumerable: true,
  1058. configurable: true,
  1059. get: function reactiveGetter () {
  1060. var value = getter ? getter.call(obj) : val;
  1061. if (Dep.target) {
  1062. dep.depend();
  1063. if (childOb) {
  1064. childOb.dep.depend();
  1065. if (Array.isArray(value)) {
  1066. dependArray(value);
  1067. }
  1068. }
  1069. }
  1070. return value
  1071. },
  1072. set: function reactiveSetter (newVal) {
  1073. var value = getter ? getter.call(obj) : val;
  1074. /* eslint-disable no-self-compare */
  1075. if (newVal === value || (newVal !== newVal && value !== value)) {
  1076. return
  1077. }
  1078. /* eslint-enable no-self-compare */
  1079. if (customSetter) {
  1080. customSetter();
  1081. }
  1082. // #7981: for accessor properties without setter
  1083. if (getter && !setter) { return }
  1084. if (setter) {
  1085. setter.call(obj, newVal);
  1086. } else {
  1087. val = newVal;
  1088. }
  1089. childOb = !shallow && observe(newVal);
  1090. dep.notify();
  1091. }
  1092. });
  1093. }
  1094. /**
  1095. * Set a property on an object. Adds the new property and
  1096. * triggers change notification if the property doesn't
  1097. * already exist.
  1098. */
  1099. function set (target, key, val) {
  1100. if (isUndef(target) || isPrimitive(target)
  1101. ) {
  1102. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  1103. }
  1104. if (Array.isArray(target) && isValidArrayIndex(key)) {
  1105. target.length = Math.max(target.length, key);
  1106. target.splice(key, 1, val);
  1107. return val
  1108. }
  1109. if (key in target && !(key in Object.prototype)) {
  1110. target[key] = val;
  1111. return val
  1112. }
  1113. var ob = (target).__ob__;
  1114. if (target._isVue || (ob && ob.vmCount)) {
  1115. warn(
  1116. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  1117. 'at runtime - declare it upfront in the data option.'
  1118. );
  1119. return val
  1120. }
  1121. if (!ob) {
  1122. target[key] = val;
  1123. return val
  1124. }
  1125. defineReactive$$1(ob.value, key, val);
  1126. ob.dep.notify();
  1127. return val
  1128. }
  1129. /**
  1130. * Collect dependencies on array elements when the array is touched, since
  1131. * we cannot intercept array element access like property getters.
  1132. */
  1133. function dependArray (value) {
  1134. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  1135. e = value[i];
  1136. e && e.__ob__ && e.__ob__.dep.depend();
  1137. if (Array.isArray(e)) {
  1138. dependArray(e);
  1139. }
  1140. }
  1141. }
  1142. /* */
  1143. /**
  1144. * Option overwriting strategies are functions that handle
  1145. * how to merge a parent option value and a child option
  1146. * value into the final value.
  1147. */
  1148. var strats = config.optionMergeStrategies;
  1149. /**
  1150. * Options with restrictions
  1151. */
  1152. {
  1153. strats.el = strats.propsData = function (parent, child, vm, key) {
  1154. if (!vm) {
  1155. warn(
  1156. "option \"" + key + "\" can only be used during instance " +
  1157. 'creation with the `new` keyword.'
  1158. );
  1159. }
  1160. return defaultStrat(parent, child)
  1161. };
  1162. }
  1163. /**
  1164. * Helper that recursively merges two data objects together.
  1165. */
  1166. function mergeData (to, from) {
  1167. if (!from) { return to }
  1168. var key, toVal, fromVal;
  1169. var keys = hasSymbol
  1170. ? Reflect.ownKeys(from)
  1171. : Object.keys(from);
  1172. for (var i = 0; i < keys.length; i++) {
  1173. key = keys[i];
  1174. // in case the object is already observed...
  1175. if (key === '__ob__') { continue }
  1176. toVal = to[key];
  1177. fromVal = from[key];
  1178. if (!hasOwn(to, key)) {
  1179. set(to, key, fromVal);
  1180. } else if (
  1181. toVal !== fromVal &&
  1182. isPlainObject(toVal) &&
  1183. isPlainObject(fromVal)
  1184. ) {
  1185. mergeData(toVal, fromVal);
  1186. }
  1187. }
  1188. return to
  1189. }
  1190. /**
  1191. * Data
  1192. */
  1193. function mergeDataOrFn (
  1194. parentVal,
  1195. childVal,
  1196. vm
  1197. ) {
  1198. if (!vm) {
  1199. // in a Vue.extend merge, both should be functions
  1200. if (!childVal) {
  1201. return parentVal
  1202. }
  1203. if (!parentVal) {
  1204. return childVal
  1205. }
  1206. // when parentVal & childVal are both present,
  1207. // we need to return a function that returns the
  1208. // merged result of both functions... no need to
  1209. // check if parentVal is a function here because
  1210. // it has to be a function to pass previous merges.
  1211. return function mergedDataFn () {
  1212. return mergeData(
  1213. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1214. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1215. )
  1216. }
  1217. } else {
  1218. return function mergedInstanceDataFn () {
  1219. // instance merge
  1220. var instanceData = typeof childVal === 'function'
  1221. ? childVal.call(vm, vm)
  1222. : childVal;
  1223. var defaultData = typeof parentVal === 'function'
  1224. ? parentVal.call(vm, vm)
  1225. : parentVal;
  1226. if (instanceData) {
  1227. return mergeData(instanceData, defaultData)
  1228. } else {
  1229. return defaultData
  1230. }
  1231. }
  1232. }
  1233. }
  1234. strats.data = function (
  1235. parentVal,
  1236. childVal,
  1237. vm
  1238. ) {
  1239. if (!vm) {
  1240. if (childVal && typeof childVal !== 'function') {
  1241. warn(
  1242. 'The "data" option should be a function ' +
  1243. 'that returns a per-instance value in component ' +
  1244. 'definitions.',
  1245. vm
  1246. );
  1247. return parentVal
  1248. }
  1249. return mergeDataOrFn(parentVal, childVal)
  1250. }
  1251. return mergeDataOrFn(parentVal, childVal, vm)
  1252. };
  1253. /**
  1254. * Hooks and props are merged as arrays.
  1255. */
  1256. function mergeHook (
  1257. parentVal,
  1258. childVal
  1259. ) {
  1260. var res = childVal
  1261. ? parentVal
  1262. ? parentVal.concat(childVal)
  1263. : Array.isArray(childVal)
  1264. ? childVal
  1265. : [childVal]
  1266. : parentVal;
  1267. return res
  1268. ? dedupeHooks(res)
  1269. : res
  1270. }
  1271. function dedupeHooks (hooks) {
  1272. var res = [];
  1273. for (var i = 0; i < hooks.length; i++) {
  1274. if (res.indexOf(hooks[i]) === -1) {
  1275. res.push(hooks[i]);
  1276. }
  1277. }
  1278. return res
  1279. }
  1280. LIFECYCLE_HOOKS.forEach(function (hook) {
  1281. strats[hook] = mergeHook;
  1282. });
  1283. /**
  1284. * Assets
  1285. *
  1286. * When a vm is present (instance creation), we need to do
  1287. * a three-way merge between constructor options, instance
  1288. * options and parent options.
  1289. */
  1290. function mergeAssets (
  1291. parentVal,
  1292. childVal,
  1293. vm,
  1294. key
  1295. ) {
  1296. var res = Object.create(parentVal || null);
  1297. if (childVal) {
  1298. assertObjectType(key, childVal, vm);
  1299. return extend(res, childVal)
  1300. } else {
  1301. return res
  1302. }
  1303. }
  1304. ASSET_TYPES.forEach(function (type) {
  1305. strats[type + 's'] = mergeAssets;
  1306. });
  1307. /**
  1308. * Watchers.
  1309. *
  1310. * Watchers hashes should not overwrite one
  1311. * another, so we merge them as arrays.
  1312. */
  1313. strats.watch = function (
  1314. parentVal,
  1315. childVal,
  1316. vm,
  1317. key
  1318. ) {
  1319. // work around Firefox's Object.prototype.watch...
  1320. if (parentVal === nativeWatch) { parentVal = undefined; }
  1321. if (childVal === nativeWatch) { childVal = undefined; }
  1322. /* istanbul ignore if */
  1323. if (!childVal) { return Object.create(parentVal || null) }
  1324. {
  1325. assertObjectType(key, childVal, vm);
  1326. }
  1327. if (!parentVal) { return childVal }
  1328. var ret = {};
  1329. extend(ret, parentVal);
  1330. for (var key$1 in childVal) {
  1331. var parent = ret[key$1];
  1332. var child = childVal[key$1];
  1333. if (parent && !Array.isArray(parent)) {
  1334. parent = [parent];
  1335. }
  1336. ret[key$1] = parent
  1337. ? parent.concat(child)
  1338. : Array.isArray(child) ? child : [child];
  1339. }
  1340. return ret
  1341. };
  1342. /**
  1343. * Other object hashes.
  1344. */
  1345. strats.props =
  1346. strats.methods =
  1347. strats.inject =
  1348. strats.computed = function (
  1349. parentVal,
  1350. childVal,
  1351. vm,
  1352. key
  1353. ) {
  1354. if (childVal && "development" !== 'production') {
  1355. assertObjectType(key, childVal, vm);
  1356. }
  1357. if (!parentVal) { return childVal }
  1358. var ret = Object.create(null);
  1359. extend(ret, parentVal);
  1360. if (childVal) { extend(ret, childVal); }
  1361. return ret
  1362. };
  1363. strats.provide = mergeDataOrFn;
  1364. /**
  1365. * Default strategy.
  1366. */
  1367. var defaultStrat = function (parentVal, childVal) {
  1368. return childVal === undefined
  1369. ? parentVal
  1370. : childVal
  1371. };
  1372. /**
  1373. * Validate component names
  1374. */
  1375. function checkComponents (options) {
  1376. for (var key in options.components) {
  1377. validateComponentName(key);
  1378. }
  1379. }
  1380. function validateComponentName (name) {
  1381. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  1382. warn(
  1383. 'Invalid component name: "' + name + '". Component names ' +
  1384. 'should conform to valid custom element name in html5 specification.'
  1385. );
  1386. }
  1387. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  1388. warn(
  1389. 'Do not use built-in or reserved HTML elements as component ' +
  1390. 'id: ' + name
  1391. );
  1392. }
  1393. }
  1394. /**
  1395. * Ensure all props option syntax are normalized into the
  1396. * Object-based format.
  1397. */
  1398. function normalizeProps (options, vm) {
  1399. var props = options.props;
  1400. if (!props) { return }
  1401. var res = {};
  1402. var i, val, name;
  1403. if (Array.isArray(props)) {
  1404. i = props.length;
  1405. while (i--) {
  1406. val = props[i];
  1407. if (typeof val === 'string') {
  1408. name = camelize(val);
  1409. res[name] = { type: null };
  1410. } else {
  1411. warn('props must be strings when using array syntax.');
  1412. }
  1413. }
  1414. } else if (isPlainObject(props)) {
  1415. for (var key in props) {
  1416. val = props[key];
  1417. name = camelize(key);
  1418. res[name] = isPlainObject(val)
  1419. ? val
  1420. : { type: val };
  1421. }
  1422. } else {
  1423. warn(
  1424. "Invalid value for option \"props\": expected an Array or an Object, " +
  1425. "but got " + (toRawType(props)) + ".",
  1426. vm
  1427. );
  1428. }
  1429. options.props = res;
  1430. }
  1431. /**
  1432. * Normalize all injections into Object-based format
  1433. */
  1434. function normalizeInject (options, vm) {
  1435. var inject = options.inject;
  1436. if (!inject) { return }
  1437. var normalized = options.inject = {};
  1438. if (Array.isArray(inject)) {
  1439. for (var i = 0; i < inject.length; i++) {
  1440. normalized[inject[i]] = { from: inject[i] };
  1441. }
  1442. } else if (isPlainObject(inject)) {
  1443. for (var key in inject) {
  1444. var val = inject[key];
  1445. normalized[key] = isPlainObject(val)
  1446. ? extend({ from: key }, val)
  1447. : { from: val };
  1448. }
  1449. } else {
  1450. warn(
  1451. "Invalid value for option \"inject\": expected an Array or an Object, " +
  1452. "but got " + (toRawType(inject)) + ".",
  1453. vm
  1454. );
  1455. }
  1456. }
  1457. /**
  1458. * Normalize raw function directives into object format.
  1459. */
  1460. function normalizeDirectives (options) {
  1461. var dirs = options.directives;
  1462. if (dirs) {
  1463. for (var key in dirs) {
  1464. var def$$1 = dirs[key];
  1465. if (typeof def$$1 === 'function') {
  1466. dirs[key] = { bind: def$$1, update: def$$1 };
  1467. }
  1468. }
  1469. }
  1470. }
  1471. function assertObjectType (name, value, vm) {
  1472. if (!isPlainObject(value)) {
  1473. warn(
  1474. "Invalid value for option \"" + name + "\": expected an Object, " +
  1475. "but got " + (toRawType(value)) + ".",
  1476. vm
  1477. );
  1478. }
  1479. }
  1480. /**
  1481. * Merge two option objects into a new one.
  1482. * Core utility used in both instantiation and inheritance.
  1483. */
  1484. function mergeOptions (
  1485. parent,
  1486. child,
  1487. vm
  1488. ) {
  1489. {
  1490. checkComponents(child);
  1491. }
  1492. if (typeof child === 'function') {
  1493. child = child.options;
  1494. }
  1495. normalizeProps(child, vm);
  1496. normalizeInject(child, vm);
  1497. normalizeDirectives(child);
  1498. // Apply extends and mixins on the child options,
  1499. // but only if it is a raw options object that isn't
  1500. // the result of another mergeOptions call.
  1501. // Only merged options has the _base property.
  1502. if (!child._base) {
  1503. if (child.extends) {
  1504. parent = mergeOptions(parent, child.extends, vm);
  1505. }
  1506. if (child.mixins) {
  1507. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1508. parent = mergeOptions(parent, child.mixins[i], vm);
  1509. }
  1510. }
  1511. }
  1512. var options = {};
  1513. var key;
  1514. for (key in parent) {
  1515. mergeField(key);
  1516. }
  1517. for (key in child) {
  1518. if (!hasOwn(parent, key)) {
  1519. mergeField(key);
  1520. }
  1521. }
  1522. function mergeField (key) {
  1523. var strat = strats[key] || defaultStrat;
  1524. options[key] = strat(parent[key], child[key], vm, key);
  1525. }
  1526. return options
  1527. }
  1528. /**
  1529. * Resolve an asset.
  1530. * This function is used because child instances need access
  1531. * to assets defined in its ancestor chain.
  1532. */
  1533. function resolveAsset (
  1534. options,
  1535. type,
  1536. id,
  1537. warnMissing
  1538. ) {
  1539. /* istanbul ignore if */
  1540. if (typeof id !== 'string') {
  1541. return
  1542. }
  1543. var assets = options[type];
  1544. // check local registration variations first
  1545. if (hasOwn(assets, id)) { return assets[id] }
  1546. var camelizedId = camelize(id);
  1547. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  1548. var PascalCaseId = capitalize(camelizedId);
  1549. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  1550. // fallback to prototype chain
  1551. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1552. if (warnMissing && !res) {
  1553. warn(
  1554. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1555. options
  1556. );
  1557. }
  1558. return res
  1559. }
  1560. /* */
  1561. function validateProp (
  1562. key,
  1563. propOptions,
  1564. propsData,
  1565. vm
  1566. ) {
  1567. var prop = propOptions[key];
  1568. var absent = !hasOwn(propsData, key);
  1569. var value = propsData[key];
  1570. // boolean casting
  1571. var booleanIndex = getTypeIndex(Boolean, prop.type);
  1572. if (booleanIndex > -1) {
  1573. if (absent && !hasOwn(prop, 'default')) {
  1574. value = false;
  1575. } else if (value === '' || value === hyphenate(key)) {
  1576. // only cast empty string / same name to boolean if
  1577. // boolean has higher priority
  1578. var stringIndex = getTypeIndex(String, prop.type);
  1579. if (stringIndex < 0 || booleanIndex < stringIndex) {
  1580. value = true;
  1581. }
  1582. }
  1583. }
  1584. // check default value
  1585. if (value === undefined) {
  1586. value = getPropDefaultValue(vm, prop, key);
  1587. // since the default value is a fresh copy,
  1588. // make sure to observe it.
  1589. var prevShouldObserve = shouldObserve;
  1590. toggleObserving(true);
  1591. observe(value);
  1592. toggleObserving(prevShouldObserve);
  1593. }
  1594. {
  1595. assertProp(prop, key, value, vm, absent);
  1596. }
  1597. return value
  1598. }
  1599. /**
  1600. * Get the default value of a prop.
  1601. */
  1602. function getPropDefaultValue (vm, prop, key) {
  1603. // no default, return undefined
  1604. if (!hasOwn(prop, 'default')) {
  1605. return undefined
  1606. }
  1607. var def = prop.default;
  1608. // warn against non-factory defaults for Object & Array
  1609. if (isObject(def)) {
  1610. warn(
  1611. 'Invalid default value for prop "' + key + '": ' +
  1612. 'Props with type Object/Array must use a factory function ' +
  1613. 'to return the default value.',
  1614. vm
  1615. );
  1616. }
  1617. // the raw prop value was also undefined from previous render,
  1618. // return previous default value to avoid unnecessary watcher trigger
  1619. if (vm && vm.$options.propsData &&
  1620. vm.$options.propsData[key] === undefined &&
  1621. vm._props[key] !== undefined
  1622. ) {
  1623. return vm._props[key]
  1624. }
  1625. // call factory function for non-Function types
  1626. // a value is Function if its prototype is function even across different execution context
  1627. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1628. ? def.call(vm)
  1629. : def
  1630. }
  1631. /**
  1632. * Assert whether a prop is valid.
  1633. */
  1634. function assertProp (
  1635. prop,
  1636. name,
  1637. value,
  1638. vm,
  1639. absent
  1640. ) {
  1641. if (prop.required && absent) {
  1642. warn(
  1643. 'Missing required prop: "' + name + '"',
  1644. vm
  1645. );
  1646. return
  1647. }
  1648. if (value == null && !prop.required) {
  1649. return
  1650. }
  1651. var type = prop.type;
  1652. var valid = !type || type === true;
  1653. var expectedTypes = [];
  1654. if (type) {
  1655. if (!Array.isArray(type)) {
  1656. type = [type];
  1657. }
  1658. for (var i = 0; i < type.length && !valid; i++) {
  1659. var assertedType = assertType(value, type[i]);
  1660. expectedTypes.push(assertedType.expectedType || '');
  1661. valid = assertedType.valid;
  1662. }
  1663. }
  1664. if (!valid) {
  1665. warn(
  1666. getInvalidTypeMessage(name, value, expectedTypes),
  1667. vm
  1668. );
  1669. return
  1670. }
  1671. var validator = prop.validator;
  1672. if (validator) {
  1673. if (!validator(value)) {
  1674. warn(
  1675. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1676. vm
  1677. );
  1678. }
  1679. }
  1680. }
  1681. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  1682. function assertType (value, type) {
  1683. var valid;
  1684. var expectedType = getType(type);
  1685. if (simpleCheckRE.test(expectedType)) {
  1686. var t = typeof value;
  1687. valid = t === expectedType.toLowerCase();
  1688. // for primitive wrapper objects
  1689. if (!valid && t === 'object') {
  1690. valid = value instanceof type;
  1691. }
  1692. } else if (expectedType === 'Object') {
  1693. valid = isPlainObject(value);
  1694. } else if (expectedType === 'Array') {
  1695. valid = Array.isArray(value);
  1696. } else {
  1697. valid = value instanceof type;
  1698. }
  1699. return {
  1700. valid: valid,
  1701. expectedType: expectedType
  1702. }
  1703. }
  1704. /**
  1705. * Use function string name to check built-in types,
  1706. * because a simple equality check will fail when running
  1707. * across different vms / iframes.
  1708. */
  1709. function getType (fn) {
  1710. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  1711. return match ? match[1] : ''
  1712. }
  1713. function isSameType (a, b) {
  1714. return getType(a) === getType(b)
  1715. }
  1716. function getTypeIndex (type, expectedTypes) {
  1717. if (!Array.isArray(expectedTypes)) {
  1718. return isSameType(expectedTypes, type) ? 0 : -1
  1719. }
  1720. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  1721. if (isSameType(expectedTypes[i], type)) {
  1722. return i
  1723. }
  1724. }
  1725. return -1
  1726. }
  1727. function getInvalidTypeMessage (name, value, expectedTypes) {
  1728. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  1729. " Expected " + (expectedTypes.map(capitalize).join(', '));
  1730. var expectedType = expectedTypes[0];
  1731. var receivedType = toRawType(value);
  1732. var expectedValue = styleValue(value, expectedType);
  1733. var receivedValue = styleValue(value, receivedType);
  1734. // check if we need to specify expected value
  1735. if (expectedTypes.length === 1 &&
  1736. isExplicable(expectedType) &&
  1737. !isBoolean(expectedType, receivedType)) {
  1738. message += " with value " + expectedValue;
  1739. }
  1740. message += ", got " + receivedType + " ";
  1741. // check if we need to specify received value
  1742. if (isExplicable(receivedType)) {
  1743. message += "with value " + receivedValue + ".";
  1744. }
  1745. return message
  1746. }
  1747. function styleValue (value, type) {
  1748. if (type === 'String') {
  1749. return ("\"" + value + "\"")
  1750. } else if (type === 'Number') {
  1751. return ("" + (Number(value)))
  1752. } else {
  1753. return ("" + value)
  1754. }
  1755. }
  1756. function isExplicable (value) {
  1757. var explicitTypes = ['string', 'number', 'boolean'];
  1758. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  1759. }
  1760. function isBoolean () {
  1761. var args = [], len = arguments.length;
  1762. while ( len-- ) args[ len ] = arguments[ len ];
  1763. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  1764. }
  1765. /* */
  1766. function handleError (err, vm, info) {
  1767. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  1768. // See: https://github.com/vuejs/vuex/issues/1505
  1769. pushTarget();
  1770. try {
  1771. if (vm) {
  1772. var cur = vm;
  1773. while ((cur = cur.$parent)) {
  1774. var hooks = cur.$options.errorCaptured;
  1775. if (hooks) {
  1776. for (var i = 0; i < hooks.length; i++) {
  1777. try {
  1778. var capture = hooks[i].call(cur, err, vm, info) === false;
  1779. if (capture) { return }
  1780. } catch (e) {
  1781. globalHandleError(e, cur, 'errorCaptured hook');
  1782. }
  1783. }
  1784. }
  1785. }
  1786. }
  1787. globalHandleError(err, vm, info);
  1788. } finally {
  1789. popTarget();
  1790. }
  1791. }
  1792. function invokeWithErrorHandling (
  1793. handler,
  1794. context,
  1795. args,
  1796. vm,
  1797. info
  1798. ) {
  1799. var res;
  1800. try {
  1801. res = args ? handler.apply(context, args) : handler.call(context);
  1802. if (res && !res._isVue && isPromise(res)) {
  1803. // issue #9511
  1804. // reassign to res to avoid catch triggering multiple times when nested calls
  1805. res = res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  1806. }
  1807. } catch (e) {
  1808. handleError(e, vm, info);
  1809. }
  1810. return res
  1811. }
  1812. function globalHandleError (err, vm, info) {
  1813. logError(err, vm, info);
  1814. }
  1815. function logError (err, vm, info) {
  1816. {
  1817. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  1818. }
  1819. /* istanbul ignore else */
  1820. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  1821. console.error(err);
  1822. } else {
  1823. throw err
  1824. }
  1825. }
  1826. /* */
  1827. var callbacks = [];
  1828. function flushCallbacks () {
  1829. var copies = callbacks.slice(0);
  1830. callbacks.length = 0;
  1831. for (var i = 0; i < copies.length; i++) {
  1832. copies[i]();
  1833. }
  1834. }
  1835. // The nextTick behavior leverages the microtask queue, which can be accessed
  1836. // via either native Promise.then or MutationObserver.
  1837. // MutationObserver has wider support, however it is seriously bugged in
  1838. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  1839. // completely stops working after triggering a few times... so, if native
  1840. // Promise is available, we will use it:
  1841. /* istanbul ignore next, $flow-disable-line */
  1842. if (typeof Promise !== 'undefined' && isNative(Promise)) ; else if (!isIE && typeof MutationObserver !== 'undefined' && (
  1843. isNative(MutationObserver) ||
  1844. // PhantomJS and iOS 7.x
  1845. MutationObserver.toString() === '[object MutationObserverConstructor]'
  1846. )) {
  1847. // Use MutationObserver where native Promise is not available,
  1848. // e.g. PhantomJS, iOS7, Android 4.4
  1849. // (#6466 MutationObserver is unreliable in IE11)
  1850. var counter = 1;
  1851. var observer = new MutationObserver(flushCallbacks);
  1852. var textNode = document.createTextNode(String(counter));
  1853. observer.observe(textNode, {
  1854. characterData: true
  1855. });
  1856. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) ;
  1857. /* */
  1858. /* */
  1859. function genClassForVnode (vnode) {
  1860. var data = vnode.data;
  1861. var parentNode = vnode;
  1862. var childNode = vnode;
  1863. while (isDef(childNode.componentInstance)) {
  1864. childNode = childNode.componentInstance._vnode;
  1865. if (childNode && childNode.data) {
  1866. data = mergeClassData(childNode.data, data);
  1867. }
  1868. }
  1869. while (isDef(parentNode = parentNode.parent)) {
  1870. if (parentNode && parentNode.data) {
  1871. data = mergeClassData(data, parentNode.data);
  1872. }
  1873. }
  1874. return renderClass(data.staticClass, data.class)
  1875. }
  1876. function mergeClassData (child, parent) {
  1877. return {
  1878. staticClass: concat(child.staticClass, parent.staticClass),
  1879. class: isDef(child.class)
  1880. ? [child.class, parent.class]
  1881. : parent.class
  1882. }
  1883. }
  1884. function renderClass (
  1885. staticClass,
  1886. dynamicClass
  1887. ) {
  1888. if (isDef(staticClass) || isDef(dynamicClass)) {
  1889. return concat(staticClass, stringifyClass(dynamicClass))
  1890. }
  1891. /* istanbul ignore next */
  1892. return ''
  1893. }
  1894. function concat (a, b) {
  1895. return a ? b ? (a + ' ' + b) : a : (b || '')
  1896. }
  1897. function stringifyClass (value) {
  1898. if (Array.isArray(value)) {
  1899. return stringifyArray(value)
  1900. }
  1901. if (isObject(value)) {
  1902. return stringifyObject(value)
  1903. }
  1904. if (typeof value === 'string') {
  1905. return value
  1906. }
  1907. /* istanbul ignore next */
  1908. return ''
  1909. }
  1910. function stringifyArray (value) {
  1911. var res = '';
  1912. var stringified;
  1913. for (var i = 0, l = value.length; i < l; i++) {
  1914. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  1915. if (res) { res += ' '; }
  1916. res += stringified;
  1917. }
  1918. }
  1919. return res
  1920. }
  1921. function stringifyObject (value) {
  1922. var res = '';
  1923. for (var key in value) {
  1924. if (value[key]) {
  1925. if (res) { res += ' '; }
  1926. res += key;
  1927. }
  1928. }
  1929. return res
  1930. }
  1931. /* */
  1932. var isHTMLTag = makeMap(
  1933. 'html,body,base,head,link,meta,style,title,' +
  1934. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  1935. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  1936. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  1937. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  1938. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  1939. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  1940. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  1941. 'output,progress,select,textarea,' +
  1942. 'details,dialog,menu,menuitem,summary,' +
  1943. 'content,element,shadow,template,blockquote,iframe,tfoot'
  1944. );
  1945. // this map is intentionally selective, only covering SVG elements that may
  1946. // contain child elements.
  1947. var isSVG = makeMap(
  1948. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  1949. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  1950. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  1951. true
  1952. );
  1953. var isPreTag = function (tag) { return tag === 'pre'; };
  1954. var isReservedTag = function (tag) {
  1955. return isHTMLTag(tag) || isSVG(tag)
  1956. };
  1957. function getTagNamespace (tag) {
  1958. if (isSVG(tag)) {
  1959. return 'svg'
  1960. }
  1961. // basic support for MathML
  1962. // note it doesn't support other MathML elements being component roots
  1963. if (tag === 'math') {
  1964. return 'math'
  1965. }
  1966. }
  1967. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  1968. /* */
  1969. /* */
  1970. function renderClass$1 (node) {
  1971. var classList = genClassForVnode(node);
  1972. if (classList !== '') {
  1973. return (" class=\"" + (escape(classList)) + "\"")
  1974. }
  1975. }
  1976. /* */
  1977. var parseStyleText = cached(function (cssText) {
  1978. var res = {};
  1979. var listDelimiter = /;(?![^(]*\))/g;
  1980. var propertyDelimiter = /:(.+)/;
  1981. cssText.split(listDelimiter).forEach(function (item) {
  1982. if (item) {
  1983. var tmp = item.split(propertyDelimiter);
  1984. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  1985. }
  1986. });
  1987. return res
  1988. });
  1989. // merge static and dynamic style data on the same vnode
  1990. function normalizeStyleData (data) {
  1991. var style = normalizeStyleBinding(data.style);
  1992. // static style is pre-processed into an object during compilation
  1993. // and is always a fresh object, so it's safe to merge into it
  1994. return data.staticStyle
  1995. ? extend(data.staticStyle, style)
  1996. : style
  1997. }
  1998. // normalize possible array / string values into Object
  1999. function normalizeStyleBinding (bindingStyle) {
  2000. if (Array.isArray(bindingStyle)) {
  2001. return toObject(bindingStyle)
  2002. }
  2003. if (typeof bindingStyle === 'string') {
  2004. return parseStyleText(bindingStyle)
  2005. }
  2006. return bindingStyle
  2007. }
  2008. /**
  2009. * parent component style should be after child's
  2010. * so that parent component's style could override it
  2011. */
  2012. function getStyle (vnode, checkChild) {
  2013. var res = {};
  2014. var styleData;
  2015. if (checkChild) {
  2016. var childNode = vnode;
  2017. while (childNode.componentInstance) {
  2018. childNode = childNode.componentInstance._vnode;
  2019. if (
  2020. childNode && childNode.data &&
  2021. (styleData = normalizeStyleData(childNode.data))
  2022. ) {
  2023. extend(res, styleData);
  2024. }
  2025. }
  2026. }
  2027. if ((styleData = normalizeStyleData(vnode.data))) {
  2028. extend(res, styleData);
  2029. }
  2030. var parentNode = vnode;
  2031. while ((parentNode = parentNode.parent)) {
  2032. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  2033. extend(res, styleData);
  2034. }
  2035. }
  2036. return res
  2037. }
  2038. /* */
  2039. function genStyle (style) {
  2040. var styleText = '';
  2041. for (var key in style) {
  2042. var value = style[key];
  2043. var hyphenatedKey = hyphenate(key);
  2044. if (Array.isArray(value)) {
  2045. for (var i = 0, len = value.length; i < len; i++) {
  2046. styleText += normalizeValue(hyphenatedKey, value[i]);
  2047. }
  2048. } else {
  2049. styleText += normalizeValue(hyphenatedKey, value);
  2050. }
  2051. }
  2052. return styleText
  2053. }
  2054. function normalizeValue(key, value) {
  2055. if (
  2056. typeof value === 'string' ||
  2057. (typeof value === 'number' && noUnitNumericStyleProps[key]) ||
  2058. value === 0
  2059. ) {
  2060. return (key + ":" + value + ";")
  2061. } else {
  2062. // invalid values
  2063. return ""
  2064. }
  2065. }
  2066. function renderStyle (vnode) {
  2067. var styleText = genStyle(getStyle(vnode, false));
  2068. if (styleText !== '') {
  2069. return (" style=" + (JSON.stringify(escape(styleText))))
  2070. }
  2071. }
  2072. var modules = [
  2073. renderAttrs,
  2074. renderDOMProps,
  2075. renderClass$1,
  2076. renderStyle
  2077. ];
  2078. /* */
  2079. function show (node, dir) {
  2080. if (!dir.value) {
  2081. var style = node.data.style || (node.data.style = {});
  2082. if (Array.isArray(style)) {
  2083. style.push({ display: 'none' });
  2084. } else {
  2085. style.display = 'none';
  2086. }
  2087. }
  2088. }
  2089. /* */
  2090. // this is only applied for <select v-model> because it is the only edge case
  2091. // that must be done at runtime instead of compile time.
  2092. function model (node, dir) {
  2093. if (!node.children) { return }
  2094. var value = dir.value;
  2095. var isMultiple = node.data.attrs && node.data.attrs.multiple;
  2096. for (var i = 0, l = node.children.length; i < l; i++) {
  2097. var option = node.children[i];
  2098. if (option.tag === 'option') {
  2099. if (isMultiple) {
  2100. var selected =
  2101. Array.isArray(value) &&
  2102. (looseIndexOf(value, getValue(option)) > -1);
  2103. if (selected) {
  2104. setSelected(option);
  2105. }
  2106. } else {
  2107. if (looseEqual(value, getValue(option))) {
  2108. setSelected(option);
  2109. return
  2110. }
  2111. }
  2112. }
  2113. }
  2114. }
  2115. function getValue (option) {
  2116. var data = option.data || {};
  2117. return (
  2118. (data.attrs && data.attrs.value) ||
  2119. (data.domProps && data.domProps.value) ||
  2120. (option.children && option.children[0] && option.children[0].text)
  2121. )
  2122. }
  2123. function setSelected (option) {
  2124. var data = option.data || (option.data = {});
  2125. var attrs = data.attrs || (data.attrs = {});
  2126. attrs.selected = '';
  2127. }
  2128. var baseDirectives = {
  2129. show: show,
  2130. model: model
  2131. };
  2132. /* */
  2133. var isUnaryTag = makeMap(
  2134. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  2135. 'link,meta,param,source,track,wbr'
  2136. );
  2137. // Elements that you can, intentionally, leave open
  2138. // (and which close themselves)
  2139. var canBeLeftOpenTag = makeMap(
  2140. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  2141. );
  2142. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  2143. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  2144. var isNonPhrasingTag = makeMap(
  2145. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  2146. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  2147. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  2148. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  2149. 'title,tr,track'
  2150. );
  2151. /* */
  2152. var MAX_STACK_DEPTH = 800;
  2153. var noop$1 = function (_) { return _; };
  2154. var defer = typeof process !== 'undefined' && process.nextTick
  2155. ? process.nextTick
  2156. : typeof Promise !== 'undefined'
  2157. ? function (fn) { return Promise.resolve().then(fn); }
  2158. : typeof setTimeout !== 'undefined'
  2159. ? setTimeout
  2160. : noop$1;
  2161. if (defer === noop$1) {
  2162. throw new Error(
  2163. 'Your JavaScript runtime does not support any asynchronous primitives ' +
  2164. 'that are required by vue-server-renderer. Please use a polyfill for ' +
  2165. 'either Promise or setTimeout.'
  2166. )
  2167. }
  2168. function createWriteFunction (
  2169. write,
  2170. onError
  2171. ) {
  2172. var stackDepth = 0;
  2173. var cachedWrite = function (text, next) {
  2174. if (text && cachedWrite.caching) {
  2175. cachedWrite.cacheBuffer[cachedWrite.cacheBuffer.length - 1] += text;
  2176. }
  2177. var waitForNext = write(text, next);
  2178. if (waitForNext !== true) {
  2179. if (stackDepth >= MAX_STACK_DEPTH) {
  2180. defer(function () {
  2181. try { next(); } catch (e) {
  2182. onError(e);
  2183. }
  2184. });
  2185. } else {
  2186. stackDepth++;
  2187. next();
  2188. stackDepth--;
  2189. }
  2190. }
  2191. };
  2192. cachedWrite.caching = false;
  2193. cachedWrite.cacheBuffer = [];
  2194. cachedWrite.componentBuffer = [];
  2195. return cachedWrite
  2196. }
  2197. /* */
  2198. /**
  2199. * Original RenderStream implementation by Sasha Aickin (@aickin)
  2200. * Licensed under the Apache License, Version 2.0
  2201. * http://www.apache.org/licenses/LICENSE-2.0
  2202. *
  2203. * Modified by Evan You (@yyx990803)
  2204. */
  2205. var stream = require('stream');
  2206. var RenderStream = /*@__PURE__*/(function (superclass) {
  2207. function RenderStream (render) {
  2208. var this$1 = this;
  2209. superclass.call(this);
  2210. this.buffer = '';
  2211. this.render = render;
  2212. this.expectedSize = 0;
  2213. this.write = createWriteFunction(function (text, next) {
  2214. var n = this$1.expectedSize;
  2215. this$1.buffer += text;
  2216. if (this$1.buffer.length >= n) {
  2217. this$1.next = next;
  2218. this$1.pushBySize(n);
  2219. return true // we will decide when to call next
  2220. }
  2221. return false
  2222. }, function (err) {
  2223. this$1.emit('error', err);
  2224. });
  2225. this.end = function () {
  2226. this$1.emit('beforeEnd');
  2227. // the rendering is finished; we should push out the last of the buffer.
  2228. this$1.done = true;
  2229. this$1.push(this$1.buffer);
  2230. };
  2231. }
  2232. if ( superclass ) RenderStream.__proto__ = superclass;
  2233. RenderStream.prototype = Object.create( superclass && superclass.prototype );
  2234. RenderStream.prototype.constructor = RenderStream;
  2235. RenderStream.prototype.pushBySize = function pushBySize (n) {
  2236. var bufferToPush = this.buffer.substring(0, n);
  2237. this.buffer = this.buffer.substring(n);
  2238. this.push(bufferToPush);
  2239. };
  2240. RenderStream.prototype.tryRender = function tryRender () {
  2241. try {
  2242. this.render(this.write, this.end);
  2243. } catch (e) {
  2244. this.emit('error', e);
  2245. }
  2246. };
  2247. RenderStream.prototype.tryNext = function tryNext () {
  2248. try {
  2249. this.next();
  2250. } catch (e) {
  2251. this.emit('error', e);
  2252. }
  2253. };
  2254. RenderStream.prototype._read = function _read (n) {
  2255. this.expectedSize = n;
  2256. // it's possible that the last chunk added bumped the buffer up to > 2 * n,
  2257. // which means we will need to go through multiple read calls to drain it
  2258. // down to < n.
  2259. if (isTrue(this.done)) {
  2260. this.push(null);
  2261. return
  2262. }
  2263. if (this.buffer.length >= n) {
  2264. this.pushBySize(n);
  2265. return
  2266. }
  2267. if (isUndef(this.next)) {
  2268. // start the rendering chain.
  2269. this.tryRender();
  2270. } else {
  2271. // continue with the rendering.
  2272. this.tryNext();
  2273. }
  2274. };
  2275. return RenderStream;
  2276. }(stream.Readable));
  2277. /* */
  2278. var RenderContext = function RenderContext (options) {
  2279. this.userContext = options.userContext;
  2280. this.activeInstance = options.activeInstance;
  2281. this.renderStates = [];
  2282. this.write = options.write;
  2283. this.done = options.done;
  2284. this.renderNode = options.renderNode;
  2285. this.isUnaryTag = options.isUnaryTag;
  2286. this.modules = options.modules;
  2287. this.directives = options.directives;
  2288. var cache = options.cache;
  2289. if (cache && (!cache.get || !cache.set)) {
  2290. throw new Error('renderer cache must implement at least get & set.')
  2291. }
  2292. this.cache = cache;
  2293. this.get = cache && normalizeAsync(cache, 'get');
  2294. this.has = cache && normalizeAsync(cache, 'has');
  2295. this.next = this.next.bind(this);
  2296. };
  2297. RenderContext.prototype.next = function next () {
  2298. // eslint-disable-next-line
  2299. while (true) {
  2300. var lastState = this.renderStates[this.renderStates.length - 1];
  2301. if (isUndef(lastState)) {
  2302. return this.done()
  2303. }
  2304. /* eslint-disable no-case-declarations */
  2305. switch (lastState.type) {
  2306. case 'Element':
  2307. case 'Fragment':
  2308. var children = lastState.children;
  2309. var total = lastState.total;
  2310. var rendered = lastState.rendered++;
  2311. if (rendered < total) {
  2312. return this.renderNode(children[rendered], false, this)
  2313. } else {
  2314. this.renderStates.pop();
  2315. if (lastState.type === 'Element') {
  2316. return this.write(lastState.endTag, this.next)
  2317. }
  2318. }
  2319. break
  2320. case 'Component':
  2321. this.renderStates.pop();
  2322. this.activeInstance = lastState.prevActive;
  2323. break
  2324. case 'ComponentWithCache':
  2325. this.renderStates.pop();
  2326. var buffer = lastState.buffer;
  2327. var bufferIndex = lastState.bufferIndex;
  2328. var componentBuffer = lastState.componentBuffer;
  2329. var key = lastState.key;
  2330. var result = {
  2331. html: buffer[bufferIndex],
  2332. components: componentBuffer[bufferIndex]
  2333. };
  2334. this.cache.set(key, result);
  2335. if (bufferIndex === 0) {
  2336. // this is a top-level cached component,
  2337. // exit caching mode.
  2338. this.write.caching = false;
  2339. } else {
  2340. // parent component is also being cached,
  2341. // merge self into parent's result
  2342. buffer[bufferIndex - 1] += result.html;
  2343. var prev = componentBuffer[bufferIndex - 1];
  2344. result.components.forEach(function (c) { return prev.add(c); });
  2345. }
  2346. buffer.length = bufferIndex;
  2347. componentBuffer.length = bufferIndex;
  2348. break
  2349. }
  2350. }
  2351. };
  2352. function normalizeAsync (cache, method) {
  2353. var fn = cache[method];
  2354. if (isUndef(fn)) {
  2355. return
  2356. } else if (fn.length > 1) {
  2357. return function (key, cb) { return fn.call(cache, key, cb); }
  2358. } else {
  2359. return function (key, cb) { return cb(fn.call(cache, key)); }
  2360. }
  2361. }
  2362. /* */
  2363. var validDivisionCharRE = /[\w).+\-_$\]]/;
  2364. function parseFilters (exp) {
  2365. var inSingle = false;
  2366. var inDouble = false;
  2367. var inTemplateString = false;
  2368. var inRegex = false;
  2369. var curly = 0;
  2370. var square = 0;
  2371. var paren = 0;
  2372. var lastFilterIndex = 0;
  2373. var c, prev, i, expression, filters;
  2374. for (i = 0; i < exp.length; i++) {
  2375. prev = c;
  2376. c = exp.charCodeAt(i);
  2377. if (inSingle) {
  2378. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  2379. } else if (inDouble) {
  2380. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  2381. } else if (inTemplateString) {
  2382. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  2383. } else if (inRegex) {
  2384. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  2385. } else if (
  2386. c === 0x7C && // pipe
  2387. exp.charCodeAt(i + 1) !== 0x7C &&
  2388. exp.charCodeAt(i - 1) !== 0x7C &&
  2389. !curly && !square && !paren
  2390. ) {
  2391. if (expression === undefined) {
  2392. // first filter, end of expression
  2393. lastFilterIndex = i + 1;
  2394. expression = exp.slice(0, i).trim();
  2395. } else {
  2396. pushFilter();
  2397. }
  2398. } else {
  2399. switch (c) {
  2400. case 0x22: inDouble = true; break // "
  2401. case 0x27: inSingle = true; break // '
  2402. case 0x60: inTemplateString = true; break // `
  2403. case 0x28: paren++; break // (
  2404. case 0x29: paren--; break // )
  2405. case 0x5B: square++; break // [
  2406. case 0x5D: square--; break // ]
  2407. case 0x7B: curly++; break // {
  2408. case 0x7D: curly--; break // }
  2409. }
  2410. if (c === 0x2f) { // /
  2411. var j = i - 1;
  2412. var p = (void 0);
  2413. // find first non-whitespace prev char
  2414. for (; j >= 0; j--) {
  2415. p = exp.charAt(j);
  2416. if (p !== ' ') { break }
  2417. }
  2418. if (!p || !validDivisionCharRE.test(p)) {
  2419. inRegex = true;
  2420. }
  2421. }
  2422. }
  2423. }
  2424. if (expression === undefined) {
  2425. expression = exp.slice(0, i).trim();
  2426. } else if (lastFilterIndex !== 0) {
  2427. pushFilter();
  2428. }
  2429. function pushFilter () {
  2430. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  2431. lastFilterIndex = i + 1;
  2432. }
  2433. if (filters) {
  2434. for (i = 0; i < filters.length; i++) {
  2435. expression = wrapFilter(expression, filters[i]);
  2436. }
  2437. }
  2438. return expression
  2439. }
  2440. function wrapFilter (exp, filter) {
  2441. var i = filter.indexOf('(');
  2442. if (i < 0) {
  2443. // _f: resolveFilter
  2444. return ("_f(\"" + filter + "\")(" + exp + ")")
  2445. } else {
  2446. var name = filter.slice(0, i);
  2447. var args = filter.slice(i + 1);
  2448. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  2449. }
  2450. }
  2451. /* */
  2452. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  2453. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  2454. var buildRegex = cached(function (delimiters) {
  2455. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  2456. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  2457. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  2458. });
  2459. function parseText (
  2460. text,
  2461. delimiters
  2462. ) {
  2463. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  2464. if (!tagRE.test(text)) {
  2465. return
  2466. }
  2467. var tokens = [];
  2468. var rawTokens = [];
  2469. var lastIndex = tagRE.lastIndex = 0;
  2470. var match, index, tokenValue;
  2471. while ((match = tagRE.exec(text))) {
  2472. index = match.index;
  2473. // push text token
  2474. if (index > lastIndex) {
  2475. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  2476. tokens.push(JSON.stringify(tokenValue));
  2477. }
  2478. // tag token
  2479. var exp = parseFilters(match[1].trim());
  2480. tokens.push(("_s(" + exp + ")"));
  2481. rawTokens.push({ '@binding': exp });
  2482. lastIndex = index + match[0].length;
  2483. }
  2484. if (lastIndex < text.length) {
  2485. rawTokens.push(tokenValue = text.slice(lastIndex));
  2486. tokens.push(JSON.stringify(tokenValue));
  2487. }
  2488. return {
  2489. expression: tokens.join('+'),
  2490. tokens: rawTokens
  2491. }
  2492. }
  2493. /* */
  2494. /* eslint-disable no-unused-vars */
  2495. function baseWarn (msg, range) {
  2496. console.error(("[Vue compiler]: " + msg));
  2497. }
  2498. /* eslint-enable no-unused-vars */
  2499. function pluckModuleFunction (
  2500. modules,
  2501. key
  2502. ) {
  2503. return modules
  2504. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  2505. : []
  2506. }
  2507. function addProp (el, name, value, range, dynamic) {
  2508. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  2509. el.plain = false;
  2510. }
  2511. function addAttr (el, name, value, range, dynamic) {
  2512. var attrs = dynamic
  2513. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  2514. : (el.attrs || (el.attrs = []));
  2515. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  2516. el.plain = false;
  2517. }
  2518. // add a raw attr (use this in preTransforms)
  2519. function addRawAttr (el, name, value, range) {
  2520. el.attrsMap[name] = value;
  2521. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  2522. }
  2523. function addDirective (
  2524. el,
  2525. name,
  2526. rawName,
  2527. value,
  2528. arg,
  2529. isDynamicArg,
  2530. modifiers,
  2531. range
  2532. ) {
  2533. (el.directives || (el.directives = [])).push(rangeSetItem({
  2534. name: name,
  2535. rawName: rawName,
  2536. value: value,
  2537. arg: arg,
  2538. isDynamicArg: isDynamicArg,
  2539. modifiers: modifiers
  2540. }, range));
  2541. el.plain = false;
  2542. }
  2543. function prependModifierMarker (symbol, name, dynamic) {
  2544. return dynamic
  2545. ? ("_p(" + name + ",\"" + symbol + "\")")
  2546. : symbol + name // mark the event as captured
  2547. }
  2548. function addHandler (
  2549. el,
  2550. name,
  2551. value,
  2552. modifiers,
  2553. important,
  2554. warn,
  2555. range,
  2556. dynamic
  2557. ) {
  2558. modifiers = modifiers || emptyObject;
  2559. // warn prevent and passive modifier
  2560. /* istanbul ignore if */
  2561. if (
  2562. warn &&
  2563. modifiers.prevent && modifiers.passive
  2564. ) {
  2565. warn(
  2566. 'passive and prevent can\'t be used together. ' +
  2567. 'Passive handler can\'t prevent default event.',
  2568. range
  2569. );
  2570. }
  2571. // normalize click.right and click.middle since they don't actually fire
  2572. // this is technically browser-specific, but at least for now browsers are
  2573. // the only target envs that have right/middle clicks.
  2574. if (modifiers.right) {
  2575. if (dynamic) {
  2576. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  2577. } else if (name === 'click') {
  2578. name = 'contextmenu';
  2579. delete modifiers.right;
  2580. }
  2581. } else if (modifiers.middle) {
  2582. if (dynamic) {
  2583. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  2584. } else if (name === 'click') {
  2585. name = 'mouseup';
  2586. }
  2587. }
  2588. // check capture modifier
  2589. if (modifiers.capture) {
  2590. delete modifiers.capture;
  2591. name = prependModifierMarker('!', name, dynamic);
  2592. }
  2593. if (modifiers.once) {
  2594. delete modifiers.once;
  2595. name = prependModifierMarker('~', name, dynamic);
  2596. }
  2597. /* istanbul ignore if */
  2598. if (modifiers.passive) {
  2599. delete modifiers.passive;
  2600. name = prependModifierMarker('&', name, dynamic);
  2601. }
  2602. var events;
  2603. if (modifiers.native) {
  2604. delete modifiers.native;
  2605. events = el.nativeEvents || (el.nativeEvents = {});
  2606. } else {
  2607. events = el.events || (el.events = {});
  2608. }
  2609. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  2610. if (modifiers !== emptyObject) {
  2611. newHandler.modifiers = modifiers;
  2612. }
  2613. var handlers = events[name];
  2614. /* istanbul ignore if */
  2615. if (Array.isArray(handlers)) {
  2616. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  2617. } else if (handlers) {
  2618. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  2619. } else {
  2620. events[name] = newHandler;
  2621. }
  2622. el.plain = false;
  2623. }
  2624. function getRawBindingAttr (
  2625. el,
  2626. name
  2627. ) {
  2628. return el.rawAttrsMap[':' + name] ||
  2629. el.rawAttrsMap['v-bind:' + name] ||
  2630. el.rawAttrsMap[name]
  2631. }
  2632. function getBindingAttr (
  2633. el,
  2634. name,
  2635. getStatic
  2636. ) {
  2637. var dynamicValue =
  2638. getAndRemoveAttr(el, ':' + name) ||
  2639. getAndRemoveAttr(el, 'v-bind:' + name);
  2640. if (dynamicValue != null) {
  2641. return parseFilters(dynamicValue)
  2642. } else if (getStatic !== false) {
  2643. var staticValue = getAndRemoveAttr(el, name);
  2644. if (staticValue != null) {
  2645. return JSON.stringify(staticValue)
  2646. }
  2647. }
  2648. }
  2649. // note: this only removes the attr from the Array (attrsList) so that it
  2650. // doesn't get processed by processAttrs.
  2651. // By default it does NOT remove it from the map (attrsMap) because the map is
  2652. // needed during codegen.
  2653. function getAndRemoveAttr (
  2654. el,
  2655. name,
  2656. removeFromMap
  2657. ) {
  2658. var val;
  2659. if ((val = el.attrsMap[name]) != null) {
  2660. var list = el.attrsList;
  2661. for (var i = 0, l = list.length; i < l; i++) {
  2662. if (list[i].name === name) {
  2663. list.splice(i, 1);
  2664. break
  2665. }
  2666. }
  2667. }
  2668. if (removeFromMap) {
  2669. delete el.attrsMap[name];
  2670. }
  2671. return val
  2672. }
  2673. function getAndRemoveAttrByRegex (
  2674. el,
  2675. name
  2676. ) {
  2677. var list = el.attrsList;
  2678. for (var i = 0, l = list.length; i < l; i++) {
  2679. var attr = list[i];
  2680. if (name.test(attr.name)) {
  2681. list.splice(i, 1);
  2682. return attr
  2683. }
  2684. }
  2685. }
  2686. function rangeSetItem (
  2687. item,
  2688. range
  2689. ) {
  2690. if (range) {
  2691. if (range.start != null) {
  2692. item.start = range.start;
  2693. }
  2694. if (range.end != null) {
  2695. item.end = range.end;
  2696. }
  2697. }
  2698. return item
  2699. }
  2700. /* */
  2701. function transformNode (el, options) {
  2702. var warn = options.warn || baseWarn;
  2703. var staticClass = getAndRemoveAttr(el, 'class');
  2704. if (staticClass) {
  2705. var res = parseText(staticClass, options.delimiters);
  2706. if (res) {
  2707. warn(
  2708. "class=\"" + staticClass + "\": " +
  2709. 'Interpolation inside attributes has been removed. ' +
  2710. 'Use v-bind or the colon shorthand instead. For example, ' +
  2711. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  2712. el.rawAttrsMap['class']
  2713. );
  2714. }
  2715. }
  2716. if (staticClass) {
  2717. el.staticClass = JSON.stringify(staticClass);
  2718. }
  2719. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  2720. if (classBinding) {
  2721. el.classBinding = classBinding;
  2722. }
  2723. }
  2724. function genData (el) {
  2725. var data = '';
  2726. if (el.staticClass) {
  2727. data += "staticClass:" + (el.staticClass) + ",";
  2728. }
  2729. if (el.classBinding) {
  2730. data += "class:" + (el.classBinding) + ",";
  2731. }
  2732. return data
  2733. }
  2734. var klass = {
  2735. staticKeys: ['staticClass'],
  2736. transformNode: transformNode,
  2737. genData: genData
  2738. };
  2739. /* */
  2740. function transformNode$1 (el, options) {
  2741. var warn = options.warn || baseWarn;
  2742. var staticStyle = getAndRemoveAttr(el, 'style');
  2743. if (staticStyle) {
  2744. /* istanbul ignore if */
  2745. {
  2746. var res = parseText(staticStyle, options.delimiters);
  2747. if (res) {
  2748. warn(
  2749. "style=\"" + staticStyle + "\": " +
  2750. 'Interpolation inside attributes has been removed. ' +
  2751. 'Use v-bind or the colon shorthand instead. For example, ' +
  2752. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  2753. el.rawAttrsMap['style']
  2754. );
  2755. }
  2756. }
  2757. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  2758. }
  2759. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  2760. if (styleBinding) {
  2761. el.styleBinding = styleBinding;
  2762. }
  2763. }
  2764. function genData$1 (el) {
  2765. var data = '';
  2766. if (el.staticStyle) {
  2767. data += "staticStyle:" + (el.staticStyle) + ",";
  2768. }
  2769. if (el.styleBinding) {
  2770. data += "style:(" + (el.styleBinding) + "),";
  2771. }
  2772. return data
  2773. }
  2774. var style = {
  2775. staticKeys: ['staticStyle'],
  2776. transformNode: transformNode$1,
  2777. genData: genData$1
  2778. };
  2779. /**
  2780. * Not type-checking this file because it's mostly vendor code.
  2781. */
  2782. // Regular Expressions for parsing tags and attributes
  2783. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  2784. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  2785. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  2786. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  2787. var startTagOpen = new RegExp(("^<" + qnameCapture));
  2788. var startTagClose = /^\s*(\/?)>/;
  2789. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  2790. var doctype = /^<!DOCTYPE [^>]+>/i;
  2791. // #7298: escape - to avoid being pased as HTML comment when inlined in page
  2792. var comment = /^<!\--/;
  2793. var conditionalComment = /^<!\[/;
  2794. // Special Elements (can contain anything)
  2795. var isPlainTextElement = makeMap('script,style,textarea', true);
  2796. var reCache = {};
  2797. var decodingMap = {
  2798. '&lt;': '<',
  2799. '&gt;': '>',
  2800. '&quot;': '"',
  2801. '&amp;': '&',
  2802. '&#10;': '\n',
  2803. '&#9;': '\t',
  2804. '&#39;': "'"
  2805. };
  2806. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  2807. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  2808. // #5992
  2809. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  2810. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  2811. function decodeAttr (value, shouldDecodeNewlines) {
  2812. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  2813. return value.replace(re, function (match) { return decodingMap[match]; })
  2814. }
  2815. function parseHTML (html, options) {
  2816. var stack = [];
  2817. var expectHTML = options.expectHTML;
  2818. var isUnaryTag$$1 = options.isUnaryTag || no;
  2819. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  2820. var index = 0;
  2821. var last, lastTag;
  2822. while (html) {
  2823. last = html;
  2824. // Make sure we're not in a plaintext content element like script/style
  2825. if (!lastTag || !isPlainTextElement(lastTag)) {
  2826. var textEnd = html.indexOf('<');
  2827. if (textEnd === 0) {
  2828. // Comment:
  2829. if (comment.test(html)) {
  2830. var commentEnd = html.indexOf('-->');
  2831. if (commentEnd >= 0) {
  2832. if (options.shouldKeepComment) {
  2833. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  2834. }
  2835. advance(commentEnd + 3);
  2836. continue
  2837. }
  2838. }
  2839. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  2840. if (conditionalComment.test(html)) {
  2841. var conditionalEnd = html.indexOf(']>');
  2842. if (conditionalEnd >= 0) {
  2843. advance(conditionalEnd + 2);
  2844. continue
  2845. }
  2846. }
  2847. // Doctype:
  2848. var doctypeMatch = html.match(doctype);
  2849. if (doctypeMatch) {
  2850. advance(doctypeMatch[0].length);
  2851. continue
  2852. }
  2853. // End tag:
  2854. var endTagMatch = html.match(endTag);
  2855. if (endTagMatch) {
  2856. var curIndex = index;
  2857. advance(endTagMatch[0].length);
  2858. parseEndTag(endTagMatch[1], curIndex, index);
  2859. continue
  2860. }
  2861. // Start tag:
  2862. var startTagMatch = parseStartTag();
  2863. if (startTagMatch) {
  2864. handleStartTag(startTagMatch);
  2865. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  2866. advance(1);
  2867. }
  2868. continue
  2869. }
  2870. }
  2871. var text = (void 0), rest = (void 0), next = (void 0);
  2872. if (textEnd >= 0) {
  2873. rest = html.slice(textEnd);
  2874. while (
  2875. !endTag.test(rest) &&
  2876. !startTagOpen.test(rest) &&
  2877. !comment.test(rest) &&
  2878. !conditionalComment.test(rest)
  2879. ) {
  2880. // < in plain text, be forgiving and treat it as text
  2881. next = rest.indexOf('<', 1);
  2882. if (next < 0) { break }
  2883. textEnd += next;
  2884. rest = html.slice(textEnd);
  2885. }
  2886. text = html.substring(0, textEnd);
  2887. }
  2888. if (textEnd < 0) {
  2889. text = html;
  2890. }
  2891. if (text) {
  2892. advance(text.length);
  2893. }
  2894. if (options.chars && text) {
  2895. options.chars(text, index - text.length, index);
  2896. }
  2897. } else {
  2898. var endTagLength = 0;
  2899. var stackedTag = lastTag.toLowerCase();
  2900. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  2901. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  2902. endTagLength = endTag.length;
  2903. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  2904. text = text
  2905. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  2906. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  2907. }
  2908. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  2909. text = text.slice(1);
  2910. }
  2911. if (options.chars) {
  2912. options.chars(text);
  2913. }
  2914. return ''
  2915. });
  2916. index += html.length - rest$1.length;
  2917. html = rest$1;
  2918. parseEndTag(stackedTag, index - endTagLength, index);
  2919. }
  2920. if (html === last) {
  2921. options.chars && options.chars(html);
  2922. if (!stack.length && options.warn) {
  2923. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  2924. }
  2925. break
  2926. }
  2927. }
  2928. // Clean up any remaining tags
  2929. parseEndTag();
  2930. function advance (n) {
  2931. index += n;
  2932. html = html.substring(n);
  2933. }
  2934. function parseStartTag () {
  2935. var start = html.match(startTagOpen);
  2936. if (start) {
  2937. var match = {
  2938. tagName: start[1],
  2939. attrs: [],
  2940. start: index
  2941. };
  2942. advance(start[0].length);
  2943. var end, attr;
  2944. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  2945. attr.start = index;
  2946. advance(attr[0].length);
  2947. attr.end = index;
  2948. match.attrs.push(attr);
  2949. }
  2950. if (end) {
  2951. match.unarySlash = end[1];
  2952. advance(end[0].length);
  2953. match.end = index;
  2954. return match
  2955. }
  2956. }
  2957. }
  2958. function handleStartTag (match) {
  2959. var tagName = match.tagName;
  2960. var unarySlash = match.unarySlash;
  2961. if (expectHTML) {
  2962. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  2963. parseEndTag(lastTag);
  2964. }
  2965. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  2966. parseEndTag(tagName);
  2967. }
  2968. }
  2969. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  2970. var l = match.attrs.length;
  2971. var attrs = new Array(l);
  2972. for (var i = 0; i < l; i++) {
  2973. var args = match.attrs[i];
  2974. var value = args[3] || args[4] || args[5] || '';
  2975. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  2976. ? options.shouldDecodeNewlinesForHref
  2977. : options.shouldDecodeNewlines;
  2978. attrs[i] = {
  2979. name: args[1],
  2980. value: decodeAttr(value, shouldDecodeNewlines)
  2981. };
  2982. if (options.outputSourceRange) {
  2983. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  2984. attrs[i].end = args.end;
  2985. }
  2986. }
  2987. if (!unary) {
  2988. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  2989. lastTag = tagName;
  2990. }
  2991. if (options.start) {
  2992. options.start(tagName, attrs, unary, match.start, match.end);
  2993. }
  2994. }
  2995. function parseEndTag (tagName, start, end) {
  2996. var pos, lowerCasedTagName;
  2997. if (start == null) { start = index; }
  2998. if (end == null) { end = index; }
  2999. // Find the closest opened tag of the same type
  3000. if (tagName) {
  3001. lowerCasedTagName = tagName.toLowerCase();
  3002. for (pos = stack.length - 1; pos >= 0; pos--) {
  3003. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  3004. break
  3005. }
  3006. }
  3007. } else {
  3008. // If no tag name is provided, clean shop
  3009. pos = 0;
  3010. }
  3011. if (pos >= 0) {
  3012. // Close all the open elements, up the stack
  3013. for (var i = stack.length - 1; i >= pos; i--) {
  3014. if (i > pos || !tagName &&
  3015. options.warn
  3016. ) {
  3017. options.warn(
  3018. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  3019. { start: stack[i].start, end: stack[i].end }
  3020. );
  3021. }
  3022. if (options.end) {
  3023. options.end(stack[i].tag, start, end);
  3024. }
  3025. }
  3026. // Remove the open elements from the stack
  3027. stack.length = pos;
  3028. lastTag = pos && stack[pos - 1].tag;
  3029. } else if (lowerCasedTagName === 'br') {
  3030. if (options.start) {
  3031. options.start(tagName, [], true, start, end);
  3032. }
  3033. } else if (lowerCasedTagName === 'p') {
  3034. if (options.start) {
  3035. options.start(tagName, [], false, start, end);
  3036. }
  3037. if (options.end) {
  3038. options.end(tagName, start, end);
  3039. }
  3040. }
  3041. }
  3042. }
  3043. /* */
  3044. /**
  3045. * Cross-platform code generation for component v-model
  3046. */
  3047. function genComponentModel (
  3048. el,
  3049. value,
  3050. modifiers
  3051. ) {
  3052. var ref = modifiers || {};
  3053. var number = ref.number;
  3054. var trim = ref.trim;
  3055. var baseValueExpression = '$$v';
  3056. var valueExpression = baseValueExpression;
  3057. if (trim) {
  3058. valueExpression =
  3059. "(typeof " + baseValueExpression + " === 'string'" +
  3060. "? " + baseValueExpression + ".trim()" +
  3061. ": " + baseValueExpression + ")";
  3062. }
  3063. if (number) {
  3064. valueExpression = "_n(" + valueExpression + ")";
  3065. }
  3066. var assignment = genAssignmentCode(value, valueExpression);
  3067. el.model = {
  3068. value: ("(" + value + ")"),
  3069. expression: JSON.stringify(value),
  3070. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  3071. };
  3072. }
  3073. /**
  3074. * Cross-platform codegen helper for generating v-model value assignment code.
  3075. */
  3076. function genAssignmentCode (
  3077. value,
  3078. assignment
  3079. ) {
  3080. var res = parseModel(value);
  3081. if (res.key === null) {
  3082. return (value + "=" + assignment)
  3083. } else {
  3084. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  3085. }
  3086. }
  3087. /**
  3088. * Parse a v-model expression into a base path and a final key segment.
  3089. * Handles both dot-path and possible square brackets.
  3090. *
  3091. * Possible cases:
  3092. *
  3093. * - test
  3094. * - test[key]
  3095. * - test[test1[key]]
  3096. * - test["a"][key]
  3097. * - xxx.test[a[a].test1[key]]
  3098. * - test.xxx.a["asa"][test1[key]]
  3099. *
  3100. */
  3101. var len, str, chr, index, expressionPos, expressionEndPos;
  3102. function parseModel (val) {
  3103. // Fix https://github.com/vuejs/vue/pull/7730
  3104. // allow v-model="obj.val " (trailing whitespace)
  3105. val = val.trim();
  3106. len = val.length;
  3107. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  3108. index = val.lastIndexOf('.');
  3109. if (index > -1) {
  3110. return {
  3111. exp: val.slice(0, index),
  3112. key: '"' + val.slice(index + 1) + '"'
  3113. }
  3114. } else {
  3115. return {
  3116. exp: val,
  3117. key: null
  3118. }
  3119. }
  3120. }
  3121. str = val;
  3122. index = expressionPos = expressionEndPos = 0;
  3123. while (!eof()) {
  3124. chr = next();
  3125. /* istanbul ignore if */
  3126. if (isStringStart(chr)) {
  3127. parseString(chr);
  3128. } else if (chr === 0x5B) {
  3129. parseBracket(chr);
  3130. }
  3131. }
  3132. return {
  3133. exp: val.slice(0, expressionPos),
  3134. key: val.slice(expressionPos + 1, expressionEndPos)
  3135. }
  3136. }
  3137. function next () {
  3138. return str.charCodeAt(++index)
  3139. }
  3140. function eof () {
  3141. return index >= len
  3142. }
  3143. function isStringStart (chr) {
  3144. return chr === 0x22 || chr === 0x27
  3145. }
  3146. function parseBracket (chr) {
  3147. var inBracket = 1;
  3148. expressionPos = index;
  3149. while (!eof()) {
  3150. chr = next();
  3151. if (isStringStart(chr)) {
  3152. parseString(chr);
  3153. continue
  3154. }
  3155. if (chr === 0x5B) { inBracket++; }
  3156. if (chr === 0x5D) { inBracket--; }
  3157. if (inBracket === 0) {
  3158. expressionEndPos = index;
  3159. break
  3160. }
  3161. }
  3162. }
  3163. function parseString (chr) {
  3164. var stringQuote = chr;
  3165. while (!eof()) {
  3166. chr = next();
  3167. if (chr === stringQuote) {
  3168. break
  3169. }
  3170. }
  3171. }
  3172. /* */
  3173. var onRE = /^@|^v-on:/;
  3174. var dirRE = /^v-|^@|^:/;
  3175. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  3176. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  3177. var stripParensRE = /^\(|\)$/g;
  3178. var dynamicArgRE = /^\[.*\]$/;
  3179. var argRE = /:(.*)$/;
  3180. var bindRE = /^:|^\.|^v-bind:/;
  3181. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  3182. var slotRE = /^v-slot(:|$)|^#/;
  3183. var lineBreakRE = /[\r\n]/;
  3184. var whitespaceRE = /\s+/g;
  3185. var invalidAttributeRE = /[\s"'<>\/=]/;
  3186. var decodeHTMLCached = cached(he.decode);
  3187. var emptySlotScopeToken = "_empty_";
  3188. // configurable state
  3189. var warn$1;
  3190. var delimiters;
  3191. var transforms;
  3192. var preTransforms;
  3193. var postTransforms;
  3194. var platformIsPreTag;
  3195. var platformMustUseProp;
  3196. var platformGetTagNamespace;
  3197. var maybeComponent;
  3198. function createASTElement (
  3199. tag,
  3200. attrs,
  3201. parent
  3202. ) {
  3203. return {
  3204. type: 1,
  3205. tag: tag,
  3206. attrsList: attrs,
  3207. attrsMap: makeAttrsMap(attrs),
  3208. rawAttrsMap: {},
  3209. parent: parent,
  3210. children: []
  3211. }
  3212. }
  3213. /**
  3214. * Convert HTML string to AST.
  3215. */
  3216. function parse (
  3217. template,
  3218. options
  3219. ) {
  3220. warn$1 = options.warn || baseWarn;
  3221. platformIsPreTag = options.isPreTag || no;
  3222. platformMustUseProp = options.mustUseProp || no;
  3223. platformGetTagNamespace = options.getTagNamespace || no;
  3224. var isReservedTag = options.isReservedTag || no;
  3225. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  3226. transforms = pluckModuleFunction(options.modules, 'transformNode');
  3227. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  3228. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  3229. delimiters = options.delimiters;
  3230. var stack = [];
  3231. var preserveWhitespace = options.preserveWhitespace !== false;
  3232. var whitespaceOption = options.whitespace;
  3233. var root;
  3234. var currentParent;
  3235. var inVPre = false;
  3236. var inPre = false;
  3237. var warned = false;
  3238. function warnOnce (msg, range) {
  3239. if (!warned) {
  3240. warned = true;
  3241. warn$1(msg, range);
  3242. }
  3243. }
  3244. function closeElement (element) {
  3245. trimEndingWhitespace(element);
  3246. if (!inVPre && !element.processed) {
  3247. element = processElement(element, options);
  3248. }
  3249. // tree management
  3250. if (!stack.length && element !== root) {
  3251. // allow root elements with v-if, v-else-if and v-else
  3252. if (root.if && (element.elseif || element.else)) {
  3253. {
  3254. checkRootConstraints(element);
  3255. }
  3256. addIfCondition(root, {
  3257. exp: element.elseif,
  3258. block: element
  3259. });
  3260. } else {
  3261. warnOnce(
  3262. "Component template should contain exactly one root element. " +
  3263. "If you are using v-if on multiple elements, " +
  3264. "use v-else-if to chain them instead.",
  3265. { start: element.start }
  3266. );
  3267. }
  3268. }
  3269. if (currentParent && !element.forbidden) {
  3270. if (element.elseif || element.else) {
  3271. processIfConditions(element, currentParent);
  3272. } else {
  3273. if (element.slotScope) {
  3274. // scoped slot
  3275. // keep it in the children list so that v-else(-if) conditions can
  3276. // find it as the prev node.
  3277. var name = element.slotTarget || '"default"'
  3278. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  3279. }
  3280. currentParent.children.push(element);
  3281. element.parent = currentParent;
  3282. }
  3283. }
  3284. // final children cleanup
  3285. // filter out scoped slots
  3286. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  3287. // remove trailing whitespace node again
  3288. trimEndingWhitespace(element);
  3289. // check pre state
  3290. if (element.pre) {
  3291. inVPre = false;
  3292. }
  3293. if (platformIsPreTag(element.tag)) {
  3294. inPre = false;
  3295. }
  3296. // apply post-transforms
  3297. for (var i = 0; i < postTransforms.length; i++) {
  3298. postTransforms[i](element, options);
  3299. }
  3300. }
  3301. function trimEndingWhitespace (el) {
  3302. // remove trailing whitespace node
  3303. if (!inPre) {
  3304. var lastNode;
  3305. while (
  3306. (lastNode = el.children[el.children.length - 1]) &&
  3307. lastNode.type === 3 &&
  3308. lastNode.text === ' '
  3309. ) {
  3310. el.children.pop();
  3311. }
  3312. }
  3313. }
  3314. function checkRootConstraints (el) {
  3315. if (el.tag === 'slot' || el.tag === 'template') {
  3316. warnOnce(
  3317. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  3318. 'contain multiple nodes.',
  3319. { start: el.start }
  3320. );
  3321. }
  3322. if (el.attrsMap.hasOwnProperty('v-for')) {
  3323. warnOnce(
  3324. 'Cannot use v-for on stateful component root element because ' +
  3325. 'it renders multiple elements.',
  3326. el.rawAttrsMap['v-for']
  3327. );
  3328. }
  3329. }
  3330. parseHTML(template, {
  3331. warn: warn$1,
  3332. expectHTML: options.expectHTML,
  3333. isUnaryTag: options.isUnaryTag,
  3334. canBeLeftOpenTag: options.canBeLeftOpenTag,
  3335. shouldDecodeNewlines: options.shouldDecodeNewlines,
  3336. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  3337. shouldKeepComment: options.comments,
  3338. outputSourceRange: options.outputSourceRange,
  3339. start: function start (tag, attrs, unary, start$1, end) {
  3340. // check namespace.
  3341. // inherit parent ns if there is one
  3342. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  3343. // handle IE svg bug
  3344. /* istanbul ignore if */
  3345. if (isIE && ns === 'svg') {
  3346. attrs = guardIESVGBug(attrs);
  3347. }
  3348. var element = createASTElement(tag, attrs, currentParent);
  3349. if (ns) {
  3350. element.ns = ns;
  3351. }
  3352. {
  3353. if (options.outputSourceRange) {
  3354. element.start = start$1;
  3355. element.end = end;
  3356. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  3357. cumulated[attr.name] = attr;
  3358. return cumulated
  3359. }, {});
  3360. }
  3361. attrs.forEach(function (attr) {
  3362. if (invalidAttributeRE.test(attr.name)) {
  3363. warn$1(
  3364. "Invalid dynamic argument expression: attribute names cannot contain " +
  3365. "spaces, quotes, <, >, / or =.",
  3366. {
  3367. start: attr.start + attr.name.indexOf("["),
  3368. end: attr.start + attr.name.length
  3369. }
  3370. );
  3371. }
  3372. });
  3373. }
  3374. if (isForbiddenTag(element) && !isServerRendering()) {
  3375. element.forbidden = true;
  3376. warn$1(
  3377. 'Templates should only be responsible for mapping the state to the ' +
  3378. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  3379. "<" + tag + ">" + ', as they will not be parsed.',
  3380. { start: element.start }
  3381. );
  3382. }
  3383. // apply pre-transforms
  3384. for (var i = 0; i < preTransforms.length; i++) {
  3385. element = preTransforms[i](element, options) || element;
  3386. }
  3387. if (!inVPre) {
  3388. processPre(element);
  3389. if (element.pre) {
  3390. inVPre = true;
  3391. }
  3392. }
  3393. if (platformIsPreTag(element.tag)) {
  3394. inPre = true;
  3395. }
  3396. if (inVPre) {
  3397. processRawAttrs(element);
  3398. } else if (!element.processed) {
  3399. // structural directives
  3400. processFor(element);
  3401. processIf(element);
  3402. processOnce(element);
  3403. }
  3404. if (!root) {
  3405. root = element;
  3406. {
  3407. checkRootConstraints(root);
  3408. }
  3409. }
  3410. if (!unary) {
  3411. currentParent = element;
  3412. stack.push(element);
  3413. } else {
  3414. closeElement(element);
  3415. }
  3416. },
  3417. end: function end (tag, start, end$1) {
  3418. var element = stack[stack.length - 1];
  3419. // pop stack
  3420. stack.length -= 1;
  3421. currentParent = stack[stack.length - 1];
  3422. if (options.outputSourceRange) {
  3423. element.end = end$1;
  3424. }
  3425. closeElement(element);
  3426. },
  3427. chars: function chars (text, start, end) {
  3428. if (!currentParent) {
  3429. {
  3430. if (text === template) {
  3431. warnOnce(
  3432. 'Component template requires a root element, rather than just text.',
  3433. { start: start }
  3434. );
  3435. } else if ((text = text.trim())) {
  3436. warnOnce(
  3437. ("text \"" + text + "\" outside root element will be ignored."),
  3438. { start: start }
  3439. );
  3440. }
  3441. }
  3442. return
  3443. }
  3444. // IE textarea placeholder bug
  3445. /* istanbul ignore if */
  3446. if (isIE &&
  3447. currentParent.tag === 'textarea' &&
  3448. currentParent.attrsMap.placeholder === text
  3449. ) {
  3450. return
  3451. }
  3452. var children = currentParent.children;
  3453. if (inPre || text.trim()) {
  3454. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  3455. } else if (!children.length) {
  3456. // remove the whitespace-only node right after an opening tag
  3457. text = '';
  3458. } else if (whitespaceOption) {
  3459. if (whitespaceOption === 'condense') {
  3460. // in condense mode, remove the whitespace node if it contains
  3461. // line break, otherwise condense to a single space
  3462. text = lineBreakRE.test(text) ? '' : ' ';
  3463. } else {
  3464. text = ' ';
  3465. }
  3466. } else {
  3467. text = preserveWhitespace ? ' ' : '';
  3468. }
  3469. if (text) {
  3470. if (whitespaceOption === 'condense') {
  3471. // condense consecutive whitespaces into single space
  3472. text = text.replace(whitespaceRE, ' ');
  3473. }
  3474. var res;
  3475. var child;
  3476. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  3477. child = {
  3478. type: 2,
  3479. expression: res.expression,
  3480. tokens: res.tokens,
  3481. text: text
  3482. };
  3483. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  3484. child = {
  3485. type: 3,
  3486. text: text
  3487. };
  3488. }
  3489. if (child) {
  3490. if (options.outputSourceRange) {
  3491. child.start = start;
  3492. child.end = end;
  3493. }
  3494. children.push(child);
  3495. }
  3496. }
  3497. },
  3498. comment: function comment (text, start, end) {
  3499. // adding anyting as a sibling to the root node is forbidden
  3500. // comments should still be allowed, but ignored
  3501. if (currentParent) {
  3502. var child = {
  3503. type: 3,
  3504. text: text,
  3505. isComment: true
  3506. };
  3507. if (options.outputSourceRange) {
  3508. child.start = start;
  3509. child.end = end;
  3510. }
  3511. currentParent.children.push(child);
  3512. }
  3513. }
  3514. });
  3515. return root
  3516. }
  3517. function processPre (el) {
  3518. if (getAndRemoveAttr(el, 'v-pre') != null) {
  3519. el.pre = true;
  3520. }
  3521. }
  3522. function processRawAttrs (el) {
  3523. var list = el.attrsList;
  3524. var len = list.length;
  3525. if (len) {
  3526. var attrs = el.attrs = new Array(len);
  3527. for (var i = 0; i < len; i++) {
  3528. attrs[i] = {
  3529. name: list[i].name,
  3530. value: JSON.stringify(list[i].value)
  3531. };
  3532. if (list[i].start != null) {
  3533. attrs[i].start = list[i].start;
  3534. attrs[i].end = list[i].end;
  3535. }
  3536. }
  3537. } else if (!el.pre) {
  3538. // non root node in pre blocks with no attributes
  3539. el.plain = true;
  3540. }
  3541. }
  3542. function processElement (
  3543. element,
  3544. options
  3545. ) {
  3546. processKey(element);
  3547. // determine whether this is a plain element after
  3548. // removing structural attributes
  3549. element.plain = (
  3550. !element.key &&
  3551. !element.scopedSlots &&
  3552. !element.attrsList.length
  3553. );
  3554. processRef(element);
  3555. processSlotContent(element);
  3556. processSlotOutlet(element);
  3557. processComponent(element);
  3558. for (var i = 0; i < transforms.length; i++) {
  3559. element = transforms[i](element, options) || element;
  3560. }
  3561. processAttrs(element);
  3562. return element
  3563. }
  3564. function processKey (el) {
  3565. var exp = getBindingAttr(el, 'key');
  3566. if (exp) {
  3567. {
  3568. if (el.tag === 'template') {
  3569. warn$1(
  3570. "<template> cannot be keyed. Place the key on real elements instead.",
  3571. getRawBindingAttr(el, 'key')
  3572. );
  3573. }
  3574. if (el.for) {
  3575. var iterator = el.iterator2 || el.iterator1;
  3576. var parent = el.parent;
  3577. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  3578. warn$1(
  3579. "Do not use v-for index as key on <transition-group> children, " +
  3580. "this is the same as not using keys.",
  3581. getRawBindingAttr(el, 'key'),
  3582. true /* tip */
  3583. );
  3584. }
  3585. }
  3586. }
  3587. el.key = exp;
  3588. }
  3589. }
  3590. function processRef (el) {
  3591. var ref = getBindingAttr(el, 'ref');
  3592. if (ref) {
  3593. el.ref = ref;
  3594. el.refInFor = checkInFor(el);
  3595. }
  3596. }
  3597. function processFor (el) {
  3598. var exp;
  3599. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  3600. var res = parseFor(exp);
  3601. if (res) {
  3602. extend(el, res);
  3603. } else {
  3604. warn$1(
  3605. ("Invalid v-for expression: " + exp),
  3606. el.rawAttrsMap['v-for']
  3607. );
  3608. }
  3609. }
  3610. }
  3611. function parseFor (exp) {
  3612. var inMatch = exp.match(forAliasRE);
  3613. if (!inMatch) { return }
  3614. var res = {};
  3615. res.for = inMatch[2].trim();
  3616. var alias = inMatch[1].trim().replace(stripParensRE, '');
  3617. var iteratorMatch = alias.match(forIteratorRE);
  3618. if (iteratorMatch) {
  3619. res.alias = alias.replace(forIteratorRE, '').trim();
  3620. res.iterator1 = iteratorMatch[1].trim();
  3621. if (iteratorMatch[2]) {
  3622. res.iterator2 = iteratorMatch[2].trim();
  3623. }
  3624. } else {
  3625. res.alias = alias;
  3626. }
  3627. return res
  3628. }
  3629. function processIf (el) {
  3630. var exp = getAndRemoveAttr(el, 'v-if');
  3631. if (exp) {
  3632. el.if = exp;
  3633. addIfCondition(el, {
  3634. exp: exp,
  3635. block: el
  3636. });
  3637. } else {
  3638. if (getAndRemoveAttr(el, 'v-else') != null) {
  3639. el.else = true;
  3640. }
  3641. var elseif = getAndRemoveAttr(el, 'v-else-if');
  3642. if (elseif) {
  3643. el.elseif = elseif;
  3644. }
  3645. }
  3646. }
  3647. function processIfConditions (el, parent) {
  3648. var prev = findPrevElement(parent.children);
  3649. if (prev && prev.if) {
  3650. addIfCondition(prev, {
  3651. exp: el.elseif,
  3652. block: el
  3653. });
  3654. } else {
  3655. warn$1(
  3656. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  3657. "used on element <" + (el.tag) + "> without corresponding v-if.",
  3658. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  3659. );
  3660. }
  3661. }
  3662. function findPrevElement (children) {
  3663. var i = children.length;
  3664. while (i--) {
  3665. if (children[i].type === 1) {
  3666. return children[i]
  3667. } else {
  3668. if (children[i].text !== ' ') {
  3669. warn$1(
  3670. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  3671. "will be ignored.",
  3672. children[i]
  3673. );
  3674. }
  3675. children.pop();
  3676. }
  3677. }
  3678. }
  3679. function addIfCondition (el, condition) {
  3680. if (!el.ifConditions) {
  3681. el.ifConditions = [];
  3682. }
  3683. el.ifConditions.push(condition);
  3684. }
  3685. function processOnce (el) {
  3686. var once$$1 = getAndRemoveAttr(el, 'v-once');
  3687. if (once$$1 != null) {
  3688. el.once = true;
  3689. }
  3690. }
  3691. // handle content being passed to a component as slot,
  3692. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  3693. function processSlotContent (el) {
  3694. var slotScope;
  3695. if (el.tag === 'template') {
  3696. slotScope = getAndRemoveAttr(el, 'scope');
  3697. /* istanbul ignore if */
  3698. if (slotScope) {
  3699. warn$1(
  3700. "the \"scope\" attribute for scoped slots have been deprecated and " +
  3701. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  3702. "can also be used on plain elements in addition to <template> to " +
  3703. "denote scoped slots.",
  3704. el.rawAttrsMap['scope'],
  3705. true
  3706. );
  3707. }
  3708. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  3709. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  3710. /* istanbul ignore if */
  3711. if (el.attrsMap['v-for']) {
  3712. warn$1(
  3713. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  3714. "(v-for takes higher priority). Use a wrapper <template> for the " +
  3715. "scoped slot to make it clearer.",
  3716. el.rawAttrsMap['slot-scope'],
  3717. true
  3718. );
  3719. }
  3720. el.slotScope = slotScope;
  3721. }
  3722. // slot="xxx"
  3723. var slotTarget = getBindingAttr(el, 'slot');
  3724. if (slotTarget) {
  3725. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  3726. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  3727. // preserve slot as an attribute for native shadow DOM compat
  3728. // only for non-scoped slots.
  3729. if (el.tag !== 'template' && !el.slotScope) {
  3730. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  3731. }
  3732. }
  3733. // 2.6 v-slot syntax
  3734. {
  3735. if (el.tag === 'template') {
  3736. // v-slot on <template>
  3737. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  3738. if (slotBinding) {
  3739. {
  3740. if (el.slotTarget || el.slotScope) {
  3741. warn$1(
  3742. "Unexpected mixed usage of different slot syntaxes.",
  3743. el
  3744. );
  3745. }
  3746. if (el.parent && !maybeComponent(el.parent)) {
  3747. warn$1(
  3748. "<template v-slot> can only appear at the root level inside " +
  3749. "the receiving the component",
  3750. el
  3751. );
  3752. }
  3753. }
  3754. var ref = getSlotName(slotBinding);
  3755. var name = ref.name;
  3756. var dynamic = ref.dynamic;
  3757. el.slotTarget = name;
  3758. el.slotTargetDynamic = dynamic;
  3759. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  3760. }
  3761. } else {
  3762. // v-slot on component, denotes default slot
  3763. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  3764. if (slotBinding$1) {
  3765. {
  3766. if (!maybeComponent(el)) {
  3767. warn$1(
  3768. "v-slot can only be used on components or <template>.",
  3769. slotBinding$1
  3770. );
  3771. }
  3772. if (el.slotScope || el.slotTarget) {
  3773. warn$1(
  3774. "Unexpected mixed usage of different slot syntaxes.",
  3775. el
  3776. );
  3777. }
  3778. if (el.scopedSlots) {
  3779. warn$1(
  3780. "To avoid scope ambiguity, the default slot should also use " +
  3781. "<template> syntax when there are other named slots.",
  3782. slotBinding$1
  3783. );
  3784. }
  3785. }
  3786. // add the component's children to its default slot
  3787. var slots = el.scopedSlots || (el.scopedSlots = {});
  3788. var ref$1 = getSlotName(slotBinding$1);
  3789. var name$1 = ref$1.name;
  3790. var dynamic$1 = ref$1.dynamic;
  3791. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  3792. slotContainer.slotTarget = name$1;
  3793. slotContainer.slotTargetDynamic = dynamic$1;
  3794. slotContainer.children = el.children.filter(function (c) {
  3795. if (!c.slotScope) {
  3796. c.parent = slotContainer;
  3797. return true
  3798. }
  3799. });
  3800. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  3801. // remove children as they are returned from scopedSlots now
  3802. el.children = [];
  3803. // mark el non-plain so data gets generated
  3804. el.plain = false;
  3805. }
  3806. }
  3807. }
  3808. }
  3809. function getSlotName (binding) {
  3810. var name = binding.name.replace(slotRE, '');
  3811. if (!name) {
  3812. if (binding.name[0] !== '#') {
  3813. name = 'default';
  3814. } else {
  3815. warn$1(
  3816. "v-slot shorthand syntax requires a slot name.",
  3817. binding
  3818. );
  3819. }
  3820. }
  3821. return dynamicArgRE.test(name)
  3822. // dynamic [name]
  3823. ? { name: name.slice(1, -1), dynamic: true }
  3824. // static name
  3825. : { name: ("\"" + name + "\""), dynamic: false }
  3826. }
  3827. // handle <slot/> outlets
  3828. function processSlotOutlet (el) {
  3829. if (el.tag === 'slot') {
  3830. el.slotName = getBindingAttr(el, 'name');
  3831. if (el.key) {
  3832. warn$1(
  3833. "`key` does not work on <slot> because slots are abstract outlets " +
  3834. "and can possibly expand into multiple elements. " +
  3835. "Use the key on a wrapping element instead.",
  3836. getRawBindingAttr(el, 'key')
  3837. );
  3838. }
  3839. }
  3840. }
  3841. function processComponent (el) {
  3842. var binding;
  3843. if ((binding = getBindingAttr(el, 'is'))) {
  3844. el.component = binding;
  3845. }
  3846. if (getAndRemoveAttr(el, 'inline-template') != null) {
  3847. el.inlineTemplate = true;
  3848. }
  3849. }
  3850. function processAttrs (el) {
  3851. var list = el.attrsList;
  3852. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  3853. for (i = 0, l = list.length; i < l; i++) {
  3854. name = rawName = list[i].name;
  3855. value = list[i].value;
  3856. if (dirRE.test(name)) {
  3857. // mark element as dynamic
  3858. el.hasBindings = true;
  3859. // modifiers
  3860. modifiers = parseModifiers(name.replace(dirRE, ''));
  3861. // support .foo shorthand syntax for the .prop modifier
  3862. if (modifiers) {
  3863. name = name.replace(modifierRE, '');
  3864. }
  3865. if (bindRE.test(name)) { // v-bind
  3866. name = name.replace(bindRE, '');
  3867. value = parseFilters(value);
  3868. isDynamic = dynamicArgRE.test(name);
  3869. if (isDynamic) {
  3870. name = name.slice(1, -1);
  3871. }
  3872. if (
  3873. value.trim().length === 0
  3874. ) {
  3875. warn$1(
  3876. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  3877. );
  3878. }
  3879. if (modifiers) {
  3880. if (modifiers.prop && !isDynamic) {
  3881. name = camelize(name);
  3882. if (name === 'innerHtml') { name = 'innerHTML'; }
  3883. }
  3884. if (modifiers.camel && !isDynamic) {
  3885. name = camelize(name);
  3886. }
  3887. if (modifiers.sync) {
  3888. syncGen = genAssignmentCode(value, "$event");
  3889. if (!isDynamic) {
  3890. addHandler(
  3891. el,
  3892. ("update:" + (camelize(name))),
  3893. syncGen,
  3894. null,
  3895. false,
  3896. warn$1,
  3897. list[i]
  3898. );
  3899. if (hyphenate(name) !== camelize(name)) {
  3900. addHandler(
  3901. el,
  3902. ("update:" + (hyphenate(name))),
  3903. syncGen,
  3904. null,
  3905. false,
  3906. warn$1,
  3907. list[i]
  3908. );
  3909. }
  3910. } else {
  3911. // handler w/ dynamic event name
  3912. addHandler(
  3913. el,
  3914. ("\"update:\"+(" + name + ")"),
  3915. syncGen,
  3916. null,
  3917. false,
  3918. warn$1,
  3919. list[i],
  3920. true // dynamic
  3921. );
  3922. }
  3923. }
  3924. }
  3925. if ((modifiers && modifiers.prop) || (
  3926. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  3927. )) {
  3928. addProp(el, name, value, list[i], isDynamic);
  3929. } else {
  3930. addAttr(el, name, value, list[i], isDynamic);
  3931. }
  3932. } else if (onRE.test(name)) { // v-on
  3933. name = name.replace(onRE, '');
  3934. isDynamic = dynamicArgRE.test(name);
  3935. if (isDynamic) {
  3936. name = name.slice(1, -1);
  3937. }
  3938. addHandler(el, name, value, modifiers, false, warn$1, list[i], isDynamic);
  3939. } else { // normal directives
  3940. name = name.replace(dirRE, '');
  3941. // parse arg
  3942. var argMatch = name.match(argRE);
  3943. var arg = argMatch && argMatch[1];
  3944. isDynamic = false;
  3945. if (arg) {
  3946. name = name.slice(0, -(arg.length + 1));
  3947. if (dynamicArgRE.test(arg)) {
  3948. arg = arg.slice(1, -1);
  3949. isDynamic = true;
  3950. }
  3951. }
  3952. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  3953. if (name === 'model') {
  3954. checkForAliasModel(el, value);
  3955. }
  3956. }
  3957. } else {
  3958. // literal attribute
  3959. {
  3960. var res = parseText(value, delimiters);
  3961. if (res) {
  3962. warn$1(
  3963. name + "=\"" + value + "\": " +
  3964. 'Interpolation inside attributes has been removed. ' +
  3965. 'Use v-bind or the colon shorthand instead. For example, ' +
  3966. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  3967. list[i]
  3968. );
  3969. }
  3970. }
  3971. addAttr(el, name, JSON.stringify(value), list[i]);
  3972. // #6887 firefox doesn't update muted state if set via attribute
  3973. // even immediately after element creation
  3974. if (!el.component &&
  3975. name === 'muted' &&
  3976. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  3977. addProp(el, name, 'true', list[i]);
  3978. }
  3979. }
  3980. }
  3981. }
  3982. function checkInFor (el) {
  3983. var parent = el;
  3984. while (parent) {
  3985. if (parent.for !== undefined) {
  3986. return true
  3987. }
  3988. parent = parent.parent;
  3989. }
  3990. return false
  3991. }
  3992. function parseModifiers (name) {
  3993. var match = name.match(modifierRE);
  3994. if (match) {
  3995. var ret = {};
  3996. match.forEach(function (m) { ret[m.slice(1)] = true; });
  3997. return ret
  3998. }
  3999. }
  4000. function makeAttrsMap (attrs) {
  4001. var map = {};
  4002. for (var i = 0, l = attrs.length; i < l; i++) {
  4003. if (
  4004. map[attrs[i].name] && !isIE && !isEdge
  4005. ) {
  4006. warn$1('duplicate attribute: ' + attrs[i].name, attrs[i]);
  4007. }
  4008. map[attrs[i].name] = attrs[i].value;
  4009. }
  4010. return map
  4011. }
  4012. // for script (e.g. type="x/template") or style, do not decode content
  4013. function isTextTag (el) {
  4014. return el.tag === 'script' || el.tag === 'style'
  4015. }
  4016. function isForbiddenTag (el) {
  4017. return (
  4018. el.tag === 'style' ||
  4019. (el.tag === 'script' && (
  4020. !el.attrsMap.type ||
  4021. el.attrsMap.type === 'text/javascript'
  4022. ))
  4023. )
  4024. }
  4025. var ieNSBug = /^xmlns:NS\d+/;
  4026. var ieNSPrefix = /^NS\d+:/;
  4027. /* istanbul ignore next */
  4028. function guardIESVGBug (attrs) {
  4029. var res = [];
  4030. for (var i = 0; i < attrs.length; i++) {
  4031. var attr = attrs[i];
  4032. if (!ieNSBug.test(attr.name)) {
  4033. attr.name = attr.name.replace(ieNSPrefix, '');
  4034. res.push(attr);
  4035. }
  4036. }
  4037. return res
  4038. }
  4039. function checkForAliasModel (el, value) {
  4040. var _el = el;
  4041. while (_el) {
  4042. if (_el.for && _el.alias === value) {
  4043. warn$1(
  4044. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  4045. "You are binding v-model directly to a v-for iteration alias. " +
  4046. "This will not be able to modify the v-for source array because " +
  4047. "writing to the alias is like modifying a function local variable. " +
  4048. "Consider using an array of objects and use v-model on an object property instead.",
  4049. el.rawAttrsMap['v-model']
  4050. );
  4051. }
  4052. _el = _el.parent;
  4053. }
  4054. }
  4055. /* */
  4056. function preTransformNode (el, options) {
  4057. if (el.tag === 'input') {
  4058. var map = el.attrsMap;
  4059. if (!map['v-model']) {
  4060. return
  4061. }
  4062. var typeBinding;
  4063. if (map[':type'] || map['v-bind:type']) {
  4064. typeBinding = getBindingAttr(el, 'type');
  4065. }
  4066. if (!map.type && !typeBinding && map['v-bind']) {
  4067. typeBinding = "(" + (map['v-bind']) + ").type";
  4068. }
  4069. if (typeBinding) {
  4070. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  4071. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  4072. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  4073. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  4074. // 1. checkbox
  4075. var branch0 = cloneASTElement(el);
  4076. // process for on the main node
  4077. processFor(branch0);
  4078. addRawAttr(branch0, 'type', 'checkbox');
  4079. processElement(branch0, options);
  4080. branch0.processed = true; // prevent it from double-processed
  4081. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  4082. addIfCondition(branch0, {
  4083. exp: branch0.if,
  4084. block: branch0
  4085. });
  4086. // 2. add radio else-if condition
  4087. var branch1 = cloneASTElement(el);
  4088. getAndRemoveAttr(branch1, 'v-for', true);
  4089. addRawAttr(branch1, 'type', 'radio');
  4090. processElement(branch1, options);
  4091. addIfCondition(branch0, {
  4092. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  4093. block: branch1
  4094. });
  4095. // 3. other
  4096. var branch2 = cloneASTElement(el);
  4097. getAndRemoveAttr(branch2, 'v-for', true);
  4098. addRawAttr(branch2, ':type', typeBinding);
  4099. processElement(branch2, options);
  4100. addIfCondition(branch0, {
  4101. exp: ifCondition,
  4102. block: branch2
  4103. });
  4104. if (hasElse) {
  4105. branch0.else = true;
  4106. } else if (elseIfCondition) {
  4107. branch0.elseif = elseIfCondition;
  4108. }
  4109. return branch0
  4110. }
  4111. }
  4112. }
  4113. function cloneASTElement (el) {
  4114. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  4115. }
  4116. var model$1 = {
  4117. preTransformNode: preTransformNode
  4118. };
  4119. var modules$1 = [
  4120. klass,
  4121. style,
  4122. model$1
  4123. ];
  4124. /* */
  4125. var warn$2;
  4126. // in some cases, the event used has to be determined at runtime
  4127. // so we used some reserved tokens during compile.
  4128. var RANGE_TOKEN = '__r';
  4129. function model$2 (
  4130. el,
  4131. dir,
  4132. _warn
  4133. ) {
  4134. warn$2 = _warn;
  4135. var value = dir.value;
  4136. var modifiers = dir.modifiers;
  4137. var tag = el.tag;
  4138. var type = el.attrsMap.type;
  4139. {
  4140. // inputs with type="file" are read only and setting the input's
  4141. // value will throw an error.
  4142. if (tag === 'input' && type === 'file') {
  4143. warn$2(
  4144. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  4145. "File inputs are read only. Use a v-on:change listener instead.",
  4146. el.rawAttrsMap['v-model']
  4147. );
  4148. }
  4149. }
  4150. if (el.component) {
  4151. genComponentModel(el, value, modifiers);
  4152. // component v-model doesn't need extra runtime
  4153. return false
  4154. } else if (tag === 'select') {
  4155. genSelect(el, value, modifiers);
  4156. } else if (tag === 'input' && type === 'checkbox') {
  4157. genCheckboxModel(el, value, modifiers);
  4158. } else if (tag === 'input' && type === 'radio') {
  4159. genRadioModel(el, value, modifiers);
  4160. } else if (tag === 'input' || tag === 'textarea') {
  4161. genDefaultModel(el, value, modifiers);
  4162. } else {
  4163. genComponentModel(el, value, modifiers);
  4164. // component v-model doesn't need extra runtime
  4165. return false
  4166. }
  4167. // ensure runtime directive metadata
  4168. return true
  4169. }
  4170. function genCheckboxModel (
  4171. el,
  4172. value,
  4173. modifiers
  4174. ) {
  4175. var number = modifiers && modifiers.number;
  4176. var valueBinding = getBindingAttr(el, 'value') || 'null';
  4177. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  4178. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  4179. addProp(el, 'checked',
  4180. "Array.isArray(" + value + ")" +
  4181. "?_i(" + value + "," + valueBinding + ")>-1" + (
  4182. trueValueBinding === 'true'
  4183. ? (":(" + value + ")")
  4184. : (":_q(" + value + "," + trueValueBinding + ")")
  4185. )
  4186. );
  4187. addHandler(el, 'change',
  4188. "var $$a=" + value + "," +
  4189. '$$el=$event.target,' +
  4190. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  4191. 'if(Array.isArray($$a)){' +
  4192. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  4193. '$$i=_i($$a,$$v);' +
  4194. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  4195. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  4196. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  4197. null, true
  4198. );
  4199. }
  4200. function genRadioModel (
  4201. el,
  4202. value,
  4203. modifiers
  4204. ) {
  4205. var number = modifiers && modifiers.number;
  4206. var valueBinding = getBindingAttr(el, 'value') || 'null';
  4207. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  4208. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  4209. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  4210. }
  4211. function genSelect (
  4212. el,
  4213. value,
  4214. modifiers
  4215. ) {
  4216. var number = modifiers && modifiers.number;
  4217. var selectedVal = "Array.prototype.filter" +
  4218. ".call($event.target.options,function(o){return o.selected})" +
  4219. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  4220. "return " + (number ? '_n(val)' : 'val') + "})";
  4221. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  4222. var code = "var $$selectedVal = " + selectedVal + ";";
  4223. code = code + " " + (genAssignmentCode(value, assignment));
  4224. addHandler(el, 'change', code, null, true);
  4225. }
  4226. function genDefaultModel (
  4227. el,
  4228. value,
  4229. modifiers
  4230. ) {
  4231. var type = el.attrsMap.type;
  4232. // warn if v-bind:value conflicts with v-model
  4233. // except for inputs with v-bind:type
  4234. {
  4235. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  4236. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  4237. if (value$1 && !typeBinding) {
  4238. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  4239. warn$2(
  4240. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  4241. 'because the latter already expands to a value binding internally',
  4242. el.rawAttrsMap[binding]
  4243. );
  4244. }
  4245. }
  4246. var ref = modifiers || {};
  4247. var lazy = ref.lazy;
  4248. var number = ref.number;
  4249. var trim = ref.trim;
  4250. var needCompositionGuard = !lazy && type !== 'range';
  4251. var event = lazy
  4252. ? 'change'
  4253. : type === 'range'
  4254. ? RANGE_TOKEN
  4255. : 'input';
  4256. var valueExpression = '$event.target.value';
  4257. if (trim) {
  4258. valueExpression = "$event.target.value.trim()";
  4259. }
  4260. if (number) {
  4261. valueExpression = "_n(" + valueExpression + ")";
  4262. }
  4263. var code = genAssignmentCode(value, valueExpression);
  4264. if (needCompositionGuard) {
  4265. code = "if($event.target.composing)return;" + code;
  4266. }
  4267. addProp(el, 'value', ("(" + value + ")"));
  4268. addHandler(el, event, code, null, true);
  4269. if (trim || number) {
  4270. addHandler(el, 'blur', '$forceUpdate()');
  4271. }
  4272. }
  4273. /* */
  4274. function text (el, dir) {
  4275. if (dir.value) {
  4276. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  4277. }
  4278. }
  4279. /* */
  4280. function html (el, dir) {
  4281. if (dir.value) {
  4282. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  4283. }
  4284. }
  4285. var directives = {
  4286. model: model$2,
  4287. text: text,
  4288. html: html
  4289. };
  4290. /* */
  4291. var baseOptions = {
  4292. expectHTML: true,
  4293. modules: modules$1,
  4294. directives: directives,
  4295. isPreTag: isPreTag,
  4296. isUnaryTag: isUnaryTag,
  4297. mustUseProp: mustUseProp,
  4298. canBeLeftOpenTag: canBeLeftOpenTag,
  4299. isReservedTag: isReservedTag,
  4300. getTagNamespace: getTagNamespace,
  4301. staticKeys: genStaticKeys(modules$1)
  4302. };
  4303. /* */
  4304. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  4305. var fnInvokeRE = /\([^)]*?\);*$/;
  4306. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  4307. // KeyboardEvent.keyCode aliases
  4308. var keyCodes = {
  4309. esc: 27,
  4310. tab: 9,
  4311. enter: 13,
  4312. space: 32,
  4313. up: 38,
  4314. left: 37,
  4315. right: 39,
  4316. down: 40,
  4317. 'delete': [8, 46]
  4318. };
  4319. // KeyboardEvent.key aliases
  4320. var keyNames = {
  4321. // #7880: IE11 and Edge use `Esc` for Escape key name.
  4322. esc: ['Esc', 'Escape'],
  4323. tab: 'Tab',
  4324. enter: 'Enter',
  4325. // #9112: IE11 uses `Spacebar` for Space key name.
  4326. space: [' ', 'Spacebar'],
  4327. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  4328. up: ['Up', 'ArrowUp'],
  4329. left: ['Left', 'ArrowLeft'],
  4330. right: ['Right', 'ArrowRight'],
  4331. down: ['Down', 'ArrowDown'],
  4332. // #9112: IE11 uses `Del` for Delete key name.
  4333. 'delete': ['Backspace', 'Delete', 'Del']
  4334. };
  4335. // #4868: modifiers that prevent the execution of the listener
  4336. // need to explicitly return null so that we can determine whether to remove
  4337. // the listener for .once
  4338. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  4339. var modifierCode = {
  4340. stop: '$event.stopPropagation();',
  4341. prevent: '$event.preventDefault();',
  4342. self: genGuard("$event.target !== $event.currentTarget"),
  4343. ctrl: genGuard("!$event.ctrlKey"),
  4344. shift: genGuard("!$event.shiftKey"),
  4345. alt: genGuard("!$event.altKey"),
  4346. meta: genGuard("!$event.metaKey"),
  4347. left: genGuard("'button' in $event && $event.button !== 0"),
  4348. middle: genGuard("'button' in $event && $event.button !== 1"),
  4349. right: genGuard("'button' in $event && $event.button !== 2")
  4350. };
  4351. function genHandlers (
  4352. events,
  4353. isNative
  4354. ) {
  4355. var prefix = isNative ? 'nativeOn:' : 'on:';
  4356. var staticHandlers = "";
  4357. var dynamicHandlers = "";
  4358. for (var name in events) {
  4359. var handlerCode = genHandler(events[name]);
  4360. if (events[name] && events[name].dynamic) {
  4361. dynamicHandlers += name + "," + handlerCode + ",";
  4362. } else {
  4363. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  4364. }
  4365. }
  4366. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  4367. if (dynamicHandlers) {
  4368. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  4369. } else {
  4370. return prefix + staticHandlers
  4371. }
  4372. }
  4373. function genHandler (handler) {
  4374. if (!handler) {
  4375. return 'function(){}'
  4376. }
  4377. if (Array.isArray(handler)) {
  4378. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  4379. }
  4380. var isMethodPath = simplePathRE.test(handler.value);
  4381. var isFunctionExpression = fnExpRE.test(handler.value);
  4382. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  4383. if (!handler.modifiers) {
  4384. if (isMethodPath || isFunctionExpression) {
  4385. return handler.value
  4386. }
  4387. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  4388. } else {
  4389. var code = '';
  4390. var genModifierCode = '';
  4391. var keys = [];
  4392. for (var key in handler.modifiers) {
  4393. if (modifierCode[key]) {
  4394. genModifierCode += modifierCode[key];
  4395. // left/right
  4396. if (keyCodes[key]) {
  4397. keys.push(key);
  4398. }
  4399. } else if (key === 'exact') {
  4400. var modifiers = (handler.modifiers);
  4401. genModifierCode += genGuard(
  4402. ['ctrl', 'shift', 'alt', 'meta']
  4403. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  4404. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  4405. .join('||')
  4406. );
  4407. } else {
  4408. keys.push(key);
  4409. }
  4410. }
  4411. if (keys.length) {
  4412. code += genKeyFilter(keys);
  4413. }
  4414. // Make sure modifiers like prevent and stop get executed after key filtering
  4415. if (genModifierCode) {
  4416. code += genModifierCode;
  4417. }
  4418. var handlerCode = isMethodPath
  4419. ? ("return " + (handler.value) + "($event)")
  4420. : isFunctionExpression
  4421. ? ("return (" + (handler.value) + ")($event)")
  4422. : isFunctionInvocation
  4423. ? ("return " + (handler.value))
  4424. : handler.value;
  4425. return ("function($event){" + code + handlerCode + "}")
  4426. }
  4427. }
  4428. function genKeyFilter (keys) {
  4429. return (
  4430. // make sure the key filters only apply to KeyboardEvents
  4431. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  4432. // key events that do not have keyCode property...
  4433. "if(!$event.type.indexOf('key')&&" +
  4434. (keys.map(genFilterCode).join('&&')) + ")return null;"
  4435. )
  4436. }
  4437. function genFilterCode (key) {
  4438. var keyVal = parseInt(key, 10);
  4439. if (keyVal) {
  4440. return ("$event.keyCode!==" + keyVal)
  4441. }
  4442. var keyCode = keyCodes[key];
  4443. var keyName = keyNames[key];
  4444. return (
  4445. "_k($event.keyCode," +
  4446. (JSON.stringify(key)) + "," +
  4447. (JSON.stringify(keyCode)) + "," +
  4448. "$event.key," +
  4449. "" + (JSON.stringify(keyName)) +
  4450. ")"
  4451. )
  4452. }
  4453. /* */
  4454. function on (el, dir) {
  4455. if (dir.modifiers) {
  4456. warn("v-on without argument does not support modifiers.");
  4457. }
  4458. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  4459. }
  4460. /* */
  4461. function bind$1 (el, dir) {
  4462. el.wrapData = function (code) {
  4463. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  4464. };
  4465. }
  4466. /* */
  4467. var baseDirectives$1 = {
  4468. on: on,
  4469. bind: bind$1,
  4470. cloak: noop
  4471. };
  4472. /* */
  4473. var CodegenState = function CodegenState (options) {
  4474. this.options = options;
  4475. this.warn = options.warn || baseWarn;
  4476. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  4477. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  4478. this.directives = extend(extend({}, baseDirectives$1), options.directives);
  4479. var isReservedTag = options.isReservedTag || no;
  4480. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  4481. this.onceId = 0;
  4482. this.staticRenderFns = [];
  4483. this.pre = false;
  4484. };
  4485. function generate (
  4486. ast,
  4487. options
  4488. ) {
  4489. var state = new CodegenState(options);
  4490. var code = ast ? genElement(ast, state) : '_c("div")';
  4491. return {
  4492. render: ("with(this){return " + code + "}"),
  4493. staticRenderFns: state.staticRenderFns
  4494. }
  4495. }
  4496. function genElement (el, state) {
  4497. if (el.parent) {
  4498. el.pre = el.pre || el.parent.pre;
  4499. }
  4500. if (el.staticRoot && !el.staticProcessed) {
  4501. return genStatic(el, state)
  4502. } else if (el.once && !el.onceProcessed) {
  4503. return genOnce(el, state)
  4504. } else if (el.for && !el.forProcessed) {
  4505. return genFor(el, state)
  4506. } else if (el.if && !el.ifProcessed) {
  4507. return genIf(el, state)
  4508. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  4509. return genChildren(el, state) || 'void 0'
  4510. } else if (el.tag === 'slot') {
  4511. return genSlot(el, state)
  4512. } else {
  4513. // component or element
  4514. var code;
  4515. if (el.component) {
  4516. code = genComponent(el.component, el, state);
  4517. } else {
  4518. var data;
  4519. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  4520. data = genData$2(el, state);
  4521. }
  4522. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  4523. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  4524. }
  4525. // module transforms
  4526. for (var i = 0; i < state.transforms.length; i++) {
  4527. code = state.transforms[i](el, code);
  4528. }
  4529. return code
  4530. }
  4531. }
  4532. // hoist static sub-trees out
  4533. function genStatic (el, state) {
  4534. el.staticProcessed = true;
  4535. // Some elements (templates) need to behave differently inside of a v-pre
  4536. // node. All pre nodes are static roots, so we can use this as a location to
  4537. // wrap a state change and reset it upon exiting the pre node.
  4538. var originalPreState = state.pre;
  4539. if (el.pre) {
  4540. state.pre = el.pre;
  4541. }
  4542. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  4543. state.pre = originalPreState;
  4544. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  4545. }
  4546. // v-once
  4547. function genOnce (el, state) {
  4548. el.onceProcessed = true;
  4549. if (el.if && !el.ifProcessed) {
  4550. return genIf(el, state)
  4551. } else if (el.staticInFor) {
  4552. var key = '';
  4553. var parent = el.parent;
  4554. while (parent) {
  4555. if (parent.for) {
  4556. key = parent.key;
  4557. break
  4558. }
  4559. parent = parent.parent;
  4560. }
  4561. if (!key) {
  4562. state.warn(
  4563. "v-once can only be used inside v-for that is keyed. ",
  4564. el.rawAttrsMap['v-once']
  4565. );
  4566. return genElement(el, state)
  4567. }
  4568. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  4569. } else {
  4570. return genStatic(el, state)
  4571. }
  4572. }
  4573. function genIf (
  4574. el,
  4575. state,
  4576. altGen,
  4577. altEmpty
  4578. ) {
  4579. el.ifProcessed = true; // avoid recursion
  4580. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  4581. }
  4582. function genIfConditions (
  4583. conditions,
  4584. state,
  4585. altGen,
  4586. altEmpty
  4587. ) {
  4588. if (!conditions.length) {
  4589. return altEmpty || '_e()'
  4590. }
  4591. var condition = conditions.shift();
  4592. if (condition.exp) {
  4593. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  4594. } else {
  4595. return ("" + (genTernaryExp(condition.block)))
  4596. }
  4597. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  4598. function genTernaryExp (el) {
  4599. return altGen
  4600. ? altGen(el, state)
  4601. : el.once
  4602. ? genOnce(el, state)
  4603. : genElement(el, state)
  4604. }
  4605. }
  4606. function genFor (
  4607. el,
  4608. state,
  4609. altGen,
  4610. altHelper
  4611. ) {
  4612. var exp = el.for;
  4613. var alias = el.alias;
  4614. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  4615. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  4616. if (state.maybeComponent(el) &&
  4617. el.tag !== 'slot' &&
  4618. el.tag !== 'template' &&
  4619. !el.key
  4620. ) {
  4621. state.warn(
  4622. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  4623. "v-for should have explicit keys. " +
  4624. "See https://vuejs.org/guide/list.html#key for more info.",
  4625. el.rawAttrsMap['v-for'],
  4626. true /* tip */
  4627. );
  4628. }
  4629. el.forProcessed = true; // avoid recursion
  4630. return (altHelper || '_l') + "((" + exp + ")," +
  4631. "function(" + alias + iterator1 + iterator2 + "){" +
  4632. "return " + ((altGen || genElement)(el, state)) +
  4633. '})'
  4634. }
  4635. function genData$2 (el, state) {
  4636. var data = '{';
  4637. // directives first.
  4638. // directives may mutate the el's other properties before they are generated.
  4639. var dirs = genDirectives(el, state);
  4640. if (dirs) { data += dirs + ','; }
  4641. // key
  4642. if (el.key) {
  4643. data += "key:" + (el.key) + ",";
  4644. }
  4645. // ref
  4646. if (el.ref) {
  4647. data += "ref:" + (el.ref) + ",";
  4648. }
  4649. if (el.refInFor) {
  4650. data += "refInFor:true,";
  4651. }
  4652. // pre
  4653. if (el.pre) {
  4654. data += "pre:true,";
  4655. }
  4656. // record original tag name for components using "is" attribute
  4657. if (el.component) {
  4658. data += "tag:\"" + (el.tag) + "\",";
  4659. }
  4660. // module data generation functions
  4661. for (var i = 0; i < state.dataGenFns.length; i++) {
  4662. data += state.dataGenFns[i](el);
  4663. }
  4664. // attributes
  4665. if (el.attrs) {
  4666. data += "attrs:" + (genProps(el.attrs)) + ",";
  4667. }
  4668. // DOM props
  4669. if (el.props) {
  4670. data += "domProps:" + (genProps(el.props)) + ",";
  4671. }
  4672. // event handlers
  4673. if (el.events) {
  4674. data += (genHandlers(el.events, false)) + ",";
  4675. }
  4676. if (el.nativeEvents) {
  4677. data += (genHandlers(el.nativeEvents, true)) + ",";
  4678. }
  4679. // slot target
  4680. // only for non-scoped slots
  4681. if (el.slotTarget && !el.slotScope) {
  4682. data += "slot:" + (el.slotTarget) + ",";
  4683. }
  4684. // scoped slots
  4685. if (el.scopedSlots) {
  4686. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  4687. }
  4688. // component v-model
  4689. if (el.model) {
  4690. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  4691. }
  4692. // inline-template
  4693. if (el.inlineTemplate) {
  4694. var inlineTemplate = genInlineTemplate(el, state);
  4695. if (inlineTemplate) {
  4696. data += inlineTemplate + ",";
  4697. }
  4698. }
  4699. data = data.replace(/,$/, '') + '}';
  4700. // v-bind dynamic argument wrap
  4701. // v-bind with dynamic arguments must be applied using the same v-bind object
  4702. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  4703. if (el.dynamicAttrs) {
  4704. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  4705. }
  4706. // v-bind data wrap
  4707. if (el.wrapData) {
  4708. data = el.wrapData(data);
  4709. }
  4710. // v-on data wrap
  4711. if (el.wrapListeners) {
  4712. data = el.wrapListeners(data);
  4713. }
  4714. return data
  4715. }
  4716. function genDirectives (el, state) {
  4717. var dirs = el.directives;
  4718. if (!dirs) { return }
  4719. var res = 'directives:[';
  4720. var hasRuntime = false;
  4721. var i, l, dir, needRuntime;
  4722. for (i = 0, l = dirs.length; i < l; i++) {
  4723. dir = dirs[i];
  4724. needRuntime = true;
  4725. var gen = state.directives[dir.name];
  4726. if (gen) {
  4727. // compile-time directive that manipulates AST.
  4728. // returns true if it also needs a runtime counterpart.
  4729. needRuntime = !!gen(el, dir, state.warn);
  4730. }
  4731. if (needRuntime) {
  4732. hasRuntime = true;
  4733. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  4734. }
  4735. }
  4736. if (hasRuntime) {
  4737. return res.slice(0, -1) + ']'
  4738. }
  4739. }
  4740. function genInlineTemplate (el, state) {
  4741. var ast = el.children[0];
  4742. if (el.children.length !== 1 || ast.type !== 1) {
  4743. state.warn(
  4744. 'Inline-template components must have exactly one child element.',
  4745. { start: el.start }
  4746. );
  4747. }
  4748. if (ast && ast.type === 1) {
  4749. var inlineRenderFns = generate(ast, state.options);
  4750. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  4751. }
  4752. }
  4753. function genScopedSlots (
  4754. el,
  4755. slots,
  4756. state
  4757. ) {
  4758. // by default scoped slots are considered "stable", this allows child
  4759. // components with only scoped slots to skip forced updates from parent.
  4760. // but in some cases we have to bail-out of this optimization
  4761. // for example if the slot contains dynamic names, has v-if or v-for on them...
  4762. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  4763. var slot = slots[key];
  4764. return (
  4765. slot.slotTargetDynamic ||
  4766. slot.if ||
  4767. slot.for ||
  4768. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  4769. )
  4770. });
  4771. // #9534: if a component with scoped slots is inside a conditional branch,
  4772. // it's possible for the same component to be reused but with different
  4773. // compiled slot content. To avoid that, we generate a unique key based on
  4774. // the generated code of all the slot contents.
  4775. var needsKey = !!el.if;
  4776. // OR when it is inside another scoped slot or v-for (the reactivity may be
  4777. // disconnected due to the intermediate scope variable)
  4778. // #9438, #9506
  4779. // TODO: this can be further optimized by properly analyzing in-scope bindings
  4780. // and skip force updating ones that do not actually use scope variables.
  4781. if (!needsForceUpdate) {
  4782. var parent = el.parent;
  4783. while (parent) {
  4784. if (
  4785. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  4786. parent.for
  4787. ) {
  4788. needsForceUpdate = true;
  4789. break
  4790. }
  4791. if (parent.if) {
  4792. needsKey = true;
  4793. }
  4794. parent = parent.parent;
  4795. }
  4796. }
  4797. var generatedSlots = Object.keys(slots)
  4798. .map(function (key) { return genScopedSlot(slots[key], state); })
  4799. .join(',');
  4800. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  4801. }
  4802. function hash(str) {
  4803. var hash = 5381;
  4804. var i = str.length;
  4805. while(i) {
  4806. hash = (hash * 33) ^ str.charCodeAt(--i);
  4807. }
  4808. return hash >>> 0
  4809. }
  4810. function containsSlotChild (el) {
  4811. if (el.type === 1) {
  4812. if (el.tag === 'slot') {
  4813. return true
  4814. }
  4815. return el.children.some(containsSlotChild)
  4816. }
  4817. return false
  4818. }
  4819. function genScopedSlot (
  4820. el,
  4821. state
  4822. ) {
  4823. var isLegacySyntax = el.attrsMap['slot-scope'];
  4824. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  4825. return genIf(el, state, genScopedSlot, "null")
  4826. }
  4827. if (el.for && !el.forProcessed) {
  4828. return genFor(el, state, genScopedSlot)
  4829. }
  4830. var slotScope = el.slotScope === emptySlotScopeToken
  4831. ? ""
  4832. : String(el.slotScope);
  4833. var fn = "function(" + slotScope + "){" +
  4834. "return " + (el.tag === 'template'
  4835. ? el.if && isLegacySyntax
  4836. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  4837. : genChildren(el, state) || 'undefined'
  4838. : genElement(el, state)) + "}";
  4839. // reverse proxy v-slot without scope on this.$slots
  4840. var reverseProxy = slotScope ? "" : ",proxy:true";
  4841. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  4842. }
  4843. function genChildren (
  4844. el,
  4845. state,
  4846. checkSkip,
  4847. altGenElement,
  4848. altGenNode
  4849. ) {
  4850. var children = el.children;
  4851. if (children.length) {
  4852. var el$1 = children[0];
  4853. // optimize single v-for
  4854. if (children.length === 1 &&
  4855. el$1.for &&
  4856. el$1.tag !== 'template' &&
  4857. el$1.tag !== 'slot'
  4858. ) {
  4859. var normalizationType = checkSkip
  4860. ? state.maybeComponent(el$1) ? ",1" : ",0"
  4861. : "";
  4862. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  4863. }
  4864. var normalizationType$1 = checkSkip
  4865. ? getNormalizationType(children, state.maybeComponent)
  4866. : 0;
  4867. var gen = altGenNode || genNode;
  4868. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  4869. }
  4870. }
  4871. // determine the normalization needed for the children array.
  4872. // 0: no normalization needed
  4873. // 1: simple normalization needed (possible 1-level deep nested array)
  4874. // 2: full normalization needed
  4875. function getNormalizationType (
  4876. children,
  4877. maybeComponent
  4878. ) {
  4879. var res = 0;
  4880. for (var i = 0; i < children.length; i++) {
  4881. var el = children[i];
  4882. if (el.type !== 1) {
  4883. continue
  4884. }
  4885. if (needsNormalization(el) ||
  4886. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  4887. res = 2;
  4888. break
  4889. }
  4890. if (maybeComponent(el) ||
  4891. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  4892. res = 1;
  4893. }
  4894. }
  4895. return res
  4896. }
  4897. function needsNormalization (el) {
  4898. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  4899. }
  4900. function genNode (node, state) {
  4901. if (node.type === 1) {
  4902. return genElement(node, state)
  4903. } else if (node.type === 3 && node.isComment) {
  4904. return genComment(node)
  4905. } else {
  4906. return genText(node)
  4907. }
  4908. }
  4909. function genText (text) {
  4910. return ("_v(" + (text.type === 2
  4911. ? text.expression // no need for () because already wrapped in _s()
  4912. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  4913. }
  4914. function genComment (comment) {
  4915. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  4916. }
  4917. function genSlot (el, state) {
  4918. var slotName = el.slotName || '"default"';
  4919. var children = genChildren(el, state);
  4920. var res = "_t(" + slotName + (children ? ("," + children) : '');
  4921. var attrs = el.attrs || el.dynamicAttrs
  4922. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  4923. // slot props are camelized
  4924. name: camelize(attr.name),
  4925. value: attr.value,
  4926. dynamic: attr.dynamic
  4927. }); }))
  4928. : null;
  4929. var bind$$1 = el.attrsMap['v-bind'];
  4930. if ((attrs || bind$$1) && !children) {
  4931. res += ",null";
  4932. }
  4933. if (attrs) {
  4934. res += "," + attrs;
  4935. }
  4936. if (bind$$1) {
  4937. res += (attrs ? '' : ',null') + "," + bind$$1;
  4938. }
  4939. return res + ')'
  4940. }
  4941. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  4942. function genComponent (
  4943. componentName,
  4944. el,
  4945. state
  4946. ) {
  4947. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  4948. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  4949. }
  4950. function genProps (props) {
  4951. var staticProps = "";
  4952. var dynamicProps = "";
  4953. for (var i = 0; i < props.length; i++) {
  4954. var prop = props[i];
  4955. var value = transformSpecialNewlines(prop.value);
  4956. if (prop.dynamic) {
  4957. dynamicProps += (prop.name) + "," + value + ",";
  4958. } else {
  4959. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  4960. }
  4961. }
  4962. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  4963. if (dynamicProps) {
  4964. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  4965. } else {
  4966. return staticProps
  4967. }
  4968. }
  4969. // #3895, #4268
  4970. function transformSpecialNewlines (text) {
  4971. return text
  4972. .replace(/\u2028/g, '\\u2028')
  4973. .replace(/\u2029/g, '\\u2029')
  4974. }
  4975. /* */
  4976. var plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
  4977. // let the model AST transform translate v-model into appropriate
  4978. // props bindings
  4979. function applyModelTransform (el, state) {
  4980. if (el.directives) {
  4981. for (var i = 0; i < el.directives.length; i++) {
  4982. var dir = el.directives[i];
  4983. if (dir.name === 'model') {
  4984. state.directives.model(el, dir, state.warn);
  4985. // remove value for textarea as its converted to text
  4986. if (el.tag === 'textarea' && el.props) {
  4987. el.props = el.props.filter(function (p) { return p.name !== 'value'; });
  4988. }
  4989. break
  4990. }
  4991. }
  4992. }
  4993. }
  4994. function genAttrSegments (
  4995. attrs
  4996. ) {
  4997. return attrs.map(function (ref) {
  4998. var name = ref.name;
  4999. var value = ref.value;
  5000. return genAttrSegment(name, value);
  5001. })
  5002. }
  5003. function genDOMPropSegments (
  5004. props,
  5005. attrs
  5006. ) {
  5007. var segments = [];
  5008. props.forEach(function (ref) {
  5009. var name = ref.name;
  5010. var value = ref.value;
  5011. name = propsToAttrMap[name] || name.toLowerCase();
  5012. if (isRenderableAttr(name) &&
  5013. !(attrs && attrs.some(function (a) { return a.name === name; }))
  5014. ) {
  5015. segments.push(genAttrSegment(name, value));
  5016. }
  5017. });
  5018. return segments
  5019. }
  5020. function genAttrSegment (name, value) {
  5021. if (plainStringRE.test(value)) {
  5022. // force double quote
  5023. value = value.replace(/^'|'$/g, '"');
  5024. // force enumerated attr to "true"
  5025. if (isEnumeratedAttr(name) && value !== "\"false\"") {
  5026. value = "\"true\"";
  5027. }
  5028. return {
  5029. type: RAW,
  5030. value: isBooleanAttr(name)
  5031. ? (" " + name + "=\"" + name + "\"")
  5032. : value === '""'
  5033. ? (" " + name)
  5034. : (" " + name + "=\"" + (JSON.parse(value)) + "\"")
  5035. }
  5036. } else {
  5037. return {
  5038. type: EXPRESSION,
  5039. value: ("_ssrAttr(" + (JSON.stringify(name)) + "," + value + ")")
  5040. }
  5041. }
  5042. }
  5043. function genClassSegments (
  5044. staticClass,
  5045. classBinding
  5046. ) {
  5047. if (staticClass && !classBinding) {
  5048. return [{ type: RAW, value: (" class=\"" + (JSON.parse(staticClass)) + "\"") }]
  5049. } else {
  5050. return [{
  5051. type: EXPRESSION,
  5052. value: ("_ssrClass(" + (staticClass || 'null') + "," + (classBinding || 'null') + ")")
  5053. }]
  5054. }
  5055. }
  5056. function genStyleSegments (
  5057. staticStyle,
  5058. parsedStaticStyle,
  5059. styleBinding,
  5060. vShowExpression
  5061. ) {
  5062. if (staticStyle && !styleBinding && !vShowExpression) {
  5063. return [{ type: RAW, value: (" style=" + (JSON.stringify(staticStyle))) }]
  5064. } else {
  5065. return [{
  5066. type: EXPRESSION,
  5067. value: ("_ssrStyle(" + (parsedStaticStyle || 'null') + "," + (styleBinding || 'null') + ", " + (vShowExpression
  5068. ? ("{ display: (" + vShowExpression + ") ? '' : 'none' }")
  5069. : 'null') + ")")
  5070. }]
  5071. }
  5072. }
  5073. /* */
  5074. // optimizability constants
  5075. var optimizability = {
  5076. FALSE: 0, // whole sub tree un-optimizable
  5077. FULL: 1, // whole sub tree optimizable
  5078. SELF: 2, // self optimizable but has some un-optimizable children
  5079. CHILDREN: 3, // self un-optimizable but have fully optimizable children
  5080. PARTIAL: 4 // self un-optimizable with some un-optimizable children
  5081. };
  5082. var isPlatformReservedTag;
  5083. function optimize (root, options) {
  5084. if (!root) { return }
  5085. isPlatformReservedTag = options.isReservedTag || no;
  5086. walk(root, true);
  5087. }
  5088. function walk (node, isRoot) {
  5089. if (isUnOptimizableTree(node)) {
  5090. node.ssrOptimizability = optimizability.FALSE;
  5091. return
  5092. }
  5093. // root node or nodes with custom directives should always be a VNode
  5094. var selfUnoptimizable = isRoot || hasCustomDirective(node);
  5095. var check = function (child) {
  5096. if (child.ssrOptimizability !== optimizability.FULL) {
  5097. node.ssrOptimizability = selfUnoptimizable
  5098. ? optimizability.PARTIAL
  5099. : optimizability.SELF;
  5100. }
  5101. };
  5102. if (selfUnoptimizable) {
  5103. node.ssrOptimizability = optimizability.CHILDREN;
  5104. }
  5105. if (node.type === 1) {
  5106. for (var i = 0, l = node.children.length; i < l; i++) {
  5107. var child = node.children[i];
  5108. walk(child);
  5109. check(child);
  5110. }
  5111. if (node.ifConditions) {
  5112. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  5113. var block = node.ifConditions[i$1].block;
  5114. walk(block, isRoot);
  5115. check(block);
  5116. }
  5117. }
  5118. if (node.ssrOptimizability == null ||
  5119. (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))
  5120. ) {
  5121. node.ssrOptimizability = optimizability.FULL;
  5122. } else {
  5123. node.children = optimizeSiblings(node);
  5124. }
  5125. } else {
  5126. node.ssrOptimizability = optimizability.FULL;
  5127. }
  5128. }
  5129. function optimizeSiblings (el) {
  5130. var children = el.children;
  5131. var optimizedChildren = [];
  5132. var currentOptimizableGroup = [];
  5133. var pushGroup = function () {
  5134. if (currentOptimizableGroup.length) {
  5135. optimizedChildren.push({
  5136. type: 1,
  5137. parent: el,
  5138. tag: 'template',
  5139. attrsList: [],
  5140. attrsMap: {},
  5141. rawAttrsMap: {},
  5142. children: currentOptimizableGroup,
  5143. ssrOptimizability: optimizability.FULL
  5144. });
  5145. }
  5146. currentOptimizableGroup = [];
  5147. };
  5148. for (var i = 0; i < children.length; i++) {
  5149. var c = children[i];
  5150. if (c.ssrOptimizability === optimizability.FULL) {
  5151. currentOptimizableGroup.push(c);
  5152. } else {
  5153. // wrap fully-optimizable adjacent siblings inside a template tag
  5154. // so that they can be optimized into a single ssrNode by codegen
  5155. pushGroup();
  5156. optimizedChildren.push(c);
  5157. }
  5158. }
  5159. pushGroup();
  5160. return optimizedChildren
  5161. }
  5162. function isUnOptimizableTree (node) {
  5163. if (node.type === 2 || node.type === 3) { // text or expression
  5164. return false
  5165. }
  5166. return (
  5167. isBuiltInTag(node.tag) || // built-in (slot, component)
  5168. !isPlatformReservedTag(node.tag) || // custom component
  5169. !!node.component || // "is" component
  5170. isSelectWithModel(node) // <select v-model> requires runtime inspection
  5171. )
  5172. }
  5173. var isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
  5174. function hasCustomDirective (node) {
  5175. return (
  5176. node.type === 1 &&
  5177. node.directives &&
  5178. node.directives.some(function (d) { return !isBuiltInDir(d.name); })
  5179. )
  5180. }
  5181. // <select v-model> cannot be optimized because it requires a runtime check
  5182. // to determine proper selected option
  5183. function isSelectWithModel (node) {
  5184. return (
  5185. node.type === 1 &&
  5186. node.tag === 'select' &&
  5187. node.directives != null &&
  5188. node.directives.some(function (d) { return d.name === 'model'; })
  5189. )
  5190. }
  5191. /* */
  5192. // segment types
  5193. var RAW = 0;
  5194. var INTERPOLATION = 1;
  5195. var EXPRESSION = 2;
  5196. function generate$1 (
  5197. ast,
  5198. options
  5199. ) {
  5200. var state = new CodegenState(options);
  5201. var code = ast ? genSSRElement(ast, state) : '_c("div")';
  5202. return {
  5203. render: ("with(this){return " + code + "}"),
  5204. staticRenderFns: state.staticRenderFns
  5205. }
  5206. }
  5207. function genSSRElement (el, state) {
  5208. if (el.for && !el.forProcessed) {
  5209. return genFor(el, state, genSSRElement)
  5210. } else if (el.if && !el.ifProcessed) {
  5211. return genIf(el, state, genSSRElement)
  5212. } else if (el.tag === 'template' && !el.slotTarget) {
  5213. return el.ssrOptimizability === optimizability.FULL
  5214. ? genChildrenAsStringNode(el, state)
  5215. : genSSRChildren(el, state) || 'void 0'
  5216. }
  5217. switch (el.ssrOptimizability) {
  5218. case optimizability.FULL:
  5219. // stringify whole tree
  5220. return genStringElement(el, state)
  5221. case optimizability.SELF:
  5222. // stringify self and check children
  5223. return genStringElementWithChildren(el, state)
  5224. case optimizability.CHILDREN:
  5225. // generate self as VNode and stringify children
  5226. return genNormalElement(el, state, true)
  5227. case optimizability.PARTIAL:
  5228. // generate self as VNode and check children
  5229. return genNormalElement(el, state, false)
  5230. default:
  5231. // bail whole tree
  5232. return genElement(el, state)
  5233. }
  5234. }
  5235. function genNormalElement (el, state, stringifyChildren) {
  5236. var data = el.plain ? undefined : genData$2(el, state);
  5237. var children = stringifyChildren
  5238. ? ("[" + (genChildrenAsStringNode(el, state)) + "]")
  5239. : genSSRChildren(el, state, true);
  5240. return ("_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")")
  5241. }
  5242. function genSSRChildren (el, state, checkSkip) {
  5243. return genChildren(el, state, checkSkip, genSSRElement, genSSRNode)
  5244. }
  5245. function genSSRNode (el, state) {
  5246. return el.type === 1
  5247. ? genSSRElement(el, state)
  5248. : genText(el)
  5249. }
  5250. function genChildrenAsStringNode (el, state) {
  5251. return el.children.length
  5252. ? ("_ssrNode(" + (flattenSegments(childrenToSegments(el, state))) + ")")
  5253. : ''
  5254. }
  5255. function genStringElement (el, state) {
  5256. return ("_ssrNode(" + (elementToString(el, state)) + ")")
  5257. }
  5258. function genStringElementWithChildren (el, state) {
  5259. var children = genSSRChildren(el, state, true);
  5260. return ("_ssrNode(" + (flattenSegments(elementToOpenTagSegments(el, state))) + ",\"</" + (el.tag) + ">\"" + (children ? ("," + children) : '') + ")")
  5261. }
  5262. function elementToString (el, state) {
  5263. return ("(" + (flattenSegments(elementToSegments(el, state))) + ")")
  5264. }
  5265. function elementToSegments (el, state) {
  5266. // v-for / v-if
  5267. if (el.for && !el.forProcessed) {
  5268. el.forProcessed = true;
  5269. return [{
  5270. type: EXPRESSION,
  5271. value: genFor(el, state, elementToString, '_ssrList')
  5272. }]
  5273. } else if (el.if && !el.ifProcessed) {
  5274. el.ifProcessed = true;
  5275. return [{
  5276. type: EXPRESSION,
  5277. value: genIf(el, state, elementToString, '"<!---->"')
  5278. }]
  5279. } else if (el.tag === 'template') {
  5280. return childrenToSegments(el, state)
  5281. }
  5282. var openSegments = elementToOpenTagSegments(el, state);
  5283. var childrenSegments = childrenToSegments(el, state);
  5284. var ref = state.options;
  5285. var isUnaryTag = ref.isUnaryTag;
  5286. var close = (isUnaryTag && isUnaryTag(el.tag))
  5287. ? []
  5288. : [{ type: RAW, value: ("</" + (el.tag) + ">") }];
  5289. return openSegments.concat(childrenSegments, close)
  5290. }
  5291. function elementToOpenTagSegments (el, state) {
  5292. applyModelTransform(el, state);
  5293. var binding;
  5294. var segments = [{ type: RAW, value: ("<" + (el.tag)) }];
  5295. // attrs
  5296. if (el.attrs) {
  5297. segments.push.apply(segments, genAttrSegments(el.attrs));
  5298. }
  5299. // domProps
  5300. if (el.props) {
  5301. segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
  5302. }
  5303. // v-bind="object"
  5304. if ((binding = el.attrsMap['v-bind'])) {
  5305. segments.push({ type: EXPRESSION, value: ("_ssrAttrs(" + binding + ")") });
  5306. }
  5307. // v-bind.prop="object"
  5308. if ((binding = el.attrsMap['v-bind.prop'])) {
  5309. segments.push({ type: EXPRESSION, value: ("_ssrDOMProps(" + binding + ")") });
  5310. }
  5311. // class
  5312. if (el.staticClass || el.classBinding) {
  5313. segments.push.apply(
  5314. segments,
  5315. genClassSegments(el.staticClass, el.classBinding)
  5316. );
  5317. }
  5318. // style & v-show
  5319. if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
  5320. segments.push.apply(
  5321. segments,
  5322. genStyleSegments(
  5323. el.attrsMap.style,
  5324. el.staticStyle,
  5325. el.styleBinding,
  5326. el.attrsMap['v-show']
  5327. )
  5328. );
  5329. }
  5330. // _scopedId
  5331. if (state.options.scopeId) {
  5332. segments.push({ type: RAW, value: (" " + (state.options.scopeId)) });
  5333. }
  5334. segments.push({ type: RAW, value: ">" });
  5335. return segments
  5336. }
  5337. function childrenToSegments (el, state) {
  5338. var binding;
  5339. if ((binding = el.attrsMap['v-html'])) {
  5340. return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
  5341. }
  5342. if ((binding = el.attrsMap['v-text'])) {
  5343. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  5344. }
  5345. if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
  5346. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  5347. }
  5348. return el.children
  5349. ? nodesToSegments(el.children, state)
  5350. : []
  5351. }
  5352. function nodesToSegments (
  5353. children,
  5354. state
  5355. ) {
  5356. var segments = [];
  5357. for (var i = 0; i < children.length; i++) {
  5358. var c = children[i];
  5359. if (c.type === 1) {
  5360. segments.push.apply(segments, elementToSegments(c, state));
  5361. } else if (c.type === 2) {
  5362. segments.push({ type: INTERPOLATION, value: c.expression });
  5363. } else if (c.type === 3) {
  5364. var text = escape(c.text);
  5365. if (c.isComment) {
  5366. text = '<!--' + text + '-->';
  5367. }
  5368. segments.push({ type: RAW, value: text });
  5369. }
  5370. }
  5371. return segments
  5372. }
  5373. function flattenSegments (segments) {
  5374. var mergedSegments = [];
  5375. var textBuffer = '';
  5376. var pushBuffer = function () {
  5377. if (textBuffer) {
  5378. mergedSegments.push(JSON.stringify(textBuffer));
  5379. textBuffer = '';
  5380. }
  5381. };
  5382. for (var i = 0; i < segments.length; i++) {
  5383. var s = segments[i];
  5384. if (s.type === RAW) {
  5385. textBuffer += s.value;
  5386. } else if (s.type === INTERPOLATION) {
  5387. pushBuffer();
  5388. mergedSegments.push(("_ssrEscape(" + (s.value) + ")"));
  5389. } else if (s.type === EXPRESSION) {
  5390. pushBuffer();
  5391. mergedSegments.push(("(" + (s.value) + ")"));
  5392. }
  5393. }
  5394. pushBuffer();
  5395. return mergedSegments.join('+')
  5396. }
  5397. /* */
  5398. // these keywords should not appear inside expressions, but operators like
  5399. // typeof, instanceof and in are allowed
  5400. var prohibitedKeywordRE = new RegExp('\\b' + (
  5401. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  5402. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  5403. 'extends,finally,continue,debugger,function,arguments'
  5404. ).split(',').join('\\b|\\b') + '\\b');
  5405. // these unary operators should not be used as property/method names
  5406. var unaryOperatorsRE = new RegExp('\\b' + (
  5407. 'delete,typeof,void'
  5408. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  5409. // strip strings in expressions
  5410. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  5411. // detect problematic expressions in a template
  5412. function detectErrors (ast, warn) {
  5413. if (ast) {
  5414. checkNode(ast, warn);
  5415. }
  5416. }
  5417. function checkNode (node, warn) {
  5418. if (node.type === 1) {
  5419. for (var name in node.attrsMap) {
  5420. if (dirRE.test(name)) {
  5421. var value = node.attrsMap[name];
  5422. if (value) {
  5423. var range = node.rawAttrsMap[name];
  5424. if (name === 'v-for') {
  5425. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  5426. } else if (onRE.test(name)) {
  5427. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  5428. } else {
  5429. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  5430. }
  5431. }
  5432. }
  5433. }
  5434. if (node.children) {
  5435. for (var i = 0; i < node.children.length; i++) {
  5436. checkNode(node.children[i], warn);
  5437. }
  5438. }
  5439. } else if (node.type === 2) {
  5440. checkExpression(node.expression, node.text, warn, node);
  5441. }
  5442. }
  5443. function checkEvent (exp, text, warn, range) {
  5444. var stipped = exp.replace(stripStringRE, '');
  5445. var keywordMatch = stipped.match(unaryOperatorsRE);
  5446. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  5447. warn(
  5448. "avoid using JavaScript unary operator as property name: " +
  5449. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  5450. range
  5451. );
  5452. }
  5453. checkExpression(exp, text, warn, range);
  5454. }
  5455. function checkFor (node, text, warn, range) {
  5456. checkExpression(node.for || '', text, warn, range);
  5457. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  5458. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  5459. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  5460. }
  5461. function checkIdentifier (
  5462. ident,
  5463. type,
  5464. text,
  5465. warn,
  5466. range
  5467. ) {
  5468. if (typeof ident === 'string') {
  5469. try {
  5470. new Function(("var " + ident + "=_"));
  5471. } catch (e) {
  5472. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  5473. }
  5474. }
  5475. }
  5476. function checkExpression (exp, text, warn, range) {
  5477. try {
  5478. new Function(("return " + exp));
  5479. } catch (e) {
  5480. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  5481. if (keywordMatch) {
  5482. warn(
  5483. "avoid using JavaScript keyword as property name: " +
  5484. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  5485. range
  5486. );
  5487. } else {
  5488. warn(
  5489. "invalid expression: " + (e.message) + " in\n\n" +
  5490. " " + exp + "\n\n" +
  5491. " Raw expression: " + (text.trim()) + "\n",
  5492. range
  5493. );
  5494. }
  5495. }
  5496. }
  5497. /* */
  5498. var range = 2;
  5499. function generateCodeFrame (
  5500. source,
  5501. start,
  5502. end
  5503. ) {
  5504. if ( start === void 0 ) start = 0;
  5505. if ( end === void 0 ) end = source.length;
  5506. var lines = source.split(/\r?\n/);
  5507. var count = 0;
  5508. var res = [];
  5509. for (var i = 0; i < lines.length; i++) {
  5510. count += lines[i].length + 1;
  5511. if (count >= start) {
  5512. for (var j = i - range; j <= i + range || end > count; j++) {
  5513. if (j < 0 || j >= lines.length) { continue }
  5514. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  5515. var lineLength = lines[j].length;
  5516. if (j === i) {
  5517. // push underline
  5518. var pad = start - (count - lineLength) + 1;
  5519. var length = end > count ? lineLength - pad : end - start;
  5520. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  5521. } else if (j > i) {
  5522. if (end > count) {
  5523. var length$1 = Math.min(end - count, lineLength);
  5524. res.push(" | " + repeat$1("^", length$1));
  5525. }
  5526. count += lineLength + 1;
  5527. }
  5528. }
  5529. break
  5530. }
  5531. }
  5532. return res.join('\n')
  5533. }
  5534. function repeat$1 (str, n) {
  5535. var result = '';
  5536. if (n > 0) {
  5537. while (true) { // eslint-disable-line
  5538. if (n & 1) { result += str; }
  5539. n >>>= 1;
  5540. if (n <= 0) { break }
  5541. str += str;
  5542. }
  5543. }
  5544. return result
  5545. }
  5546. /* */
  5547. function createFunction (code, errors) {
  5548. try {
  5549. return new Function(code)
  5550. } catch (err) {
  5551. errors.push({ err: err, code: code });
  5552. return noop
  5553. }
  5554. }
  5555. function createCompileToFunctionFn (compile) {
  5556. var cache = Object.create(null);
  5557. return function compileToFunctions (
  5558. template,
  5559. options,
  5560. vm
  5561. ) {
  5562. options = extend({}, options);
  5563. var warn$$1 = options.warn || warn;
  5564. delete options.warn;
  5565. /* istanbul ignore if */
  5566. {
  5567. // detect possible CSP restriction
  5568. try {
  5569. new Function('return 1');
  5570. } catch (e) {
  5571. if (e.toString().match(/unsafe-eval|CSP/)) {
  5572. warn$$1(
  5573. 'It seems you are using the standalone build of Vue.js in an ' +
  5574. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  5575. 'The template compiler cannot work in this environment. Consider ' +
  5576. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  5577. 'templates into render functions.'
  5578. );
  5579. }
  5580. }
  5581. }
  5582. // check cache
  5583. var key = options.delimiters
  5584. ? String(options.delimiters) + template
  5585. : template;
  5586. if (cache[key]) {
  5587. return cache[key]
  5588. }
  5589. // compile
  5590. var compiled = compile(template, options);
  5591. // check compilation errors/tips
  5592. {
  5593. if (compiled.errors && compiled.errors.length) {
  5594. if (options.outputSourceRange) {
  5595. compiled.errors.forEach(function (e) {
  5596. warn$$1(
  5597. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  5598. generateCodeFrame(template, e.start, e.end),
  5599. vm
  5600. );
  5601. });
  5602. } else {
  5603. warn$$1(
  5604. "Error compiling template:\n\n" + template + "\n\n" +
  5605. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  5606. vm
  5607. );
  5608. }
  5609. }
  5610. if (compiled.tips && compiled.tips.length) {
  5611. if (options.outputSourceRange) {
  5612. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  5613. } else {
  5614. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  5615. }
  5616. }
  5617. }
  5618. // turn code into functions
  5619. var res = {};
  5620. var fnGenErrors = [];
  5621. res.render = createFunction(compiled.render, fnGenErrors);
  5622. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  5623. return createFunction(code, fnGenErrors)
  5624. });
  5625. // check function generation errors.
  5626. // this should only happen if there is a bug in the compiler itself.
  5627. // mostly for codegen development use
  5628. /* istanbul ignore if */
  5629. {
  5630. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  5631. warn$$1(
  5632. "Failed to generate render function:\n\n" +
  5633. fnGenErrors.map(function (ref) {
  5634. var err = ref.err;
  5635. var code = ref.code;
  5636. return ((err.toString()) + " in\n\n" + code + "\n");
  5637. }).join('\n'),
  5638. vm
  5639. );
  5640. }
  5641. }
  5642. return (cache[key] = res)
  5643. }
  5644. }
  5645. /* */
  5646. function createCompilerCreator (baseCompile) {
  5647. return function createCompiler (baseOptions) {
  5648. function compile (
  5649. template,
  5650. options
  5651. ) {
  5652. var finalOptions = Object.create(baseOptions);
  5653. var errors = [];
  5654. var tips = [];
  5655. var warn = function (msg, range, tip) {
  5656. (tip ? tips : errors).push(msg);
  5657. };
  5658. if (options) {
  5659. if (options.outputSourceRange) {
  5660. // $flow-disable-line
  5661. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  5662. warn = function (msg, range, tip) {
  5663. var data = { msg: msg };
  5664. if (range) {
  5665. if (range.start != null) {
  5666. data.start = range.start + leadingSpaceLength;
  5667. }
  5668. if (range.end != null) {
  5669. data.end = range.end + leadingSpaceLength;
  5670. }
  5671. }
  5672. (tip ? tips : errors).push(data);
  5673. };
  5674. }
  5675. // merge custom modules
  5676. if (options.modules) {
  5677. finalOptions.modules =
  5678. (baseOptions.modules || []).concat(options.modules);
  5679. }
  5680. // merge custom directives
  5681. if (options.directives) {
  5682. finalOptions.directives = extend(
  5683. Object.create(baseOptions.directives || null),
  5684. options.directives
  5685. );
  5686. }
  5687. // copy other options
  5688. for (var key in options) {
  5689. if (key !== 'modules' && key !== 'directives') {
  5690. finalOptions[key] = options[key];
  5691. }
  5692. }
  5693. }
  5694. finalOptions.warn = warn;
  5695. var compiled = baseCompile(template.trim(), finalOptions);
  5696. {
  5697. detectErrors(compiled.ast, warn);
  5698. }
  5699. compiled.errors = errors;
  5700. compiled.tips = tips;
  5701. return compiled
  5702. }
  5703. return {
  5704. compile: compile,
  5705. compileToFunctions: createCompileToFunctionFn(compile)
  5706. }
  5707. }
  5708. }
  5709. /* */
  5710. var createCompiler = createCompilerCreator(function baseCompile (
  5711. template,
  5712. options
  5713. ) {
  5714. var ast = parse(template.trim(), options);
  5715. optimize(ast, options);
  5716. var code = generate$1(ast, options);
  5717. return {
  5718. ast: ast,
  5719. render: code.render,
  5720. staticRenderFns: code.staticRenderFns
  5721. }
  5722. });
  5723. /* */
  5724. var ref = createCompiler(baseOptions);
  5725. var compile = ref.compile;
  5726. var compileToFunctions = ref.compileToFunctions;
  5727. /* */
  5728. // The template compiler attempts to minimize the need for normalization by
  5729. // statically analyzing the template at compile time.
  5730. //
  5731. // For plain HTML markup, normalization can be completely skipped because the
  5732. // generated render function is guaranteed to return Array<VNode>. There are
  5733. // two cases where extra normalization is needed:
  5734. // 1. When the children contains components - because a functional component
  5735. // may return an Array instead of a single root. In this case, just a simple
  5736. // normalization is needed - if any child is an Array, we flatten the whole
  5737. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  5738. // because functional components already normalize their own children.
  5739. function simpleNormalizeChildren (children) {
  5740. for (var i = 0; i < children.length; i++) {
  5741. if (Array.isArray(children[i])) {
  5742. return Array.prototype.concat.apply([], children)
  5743. }
  5744. }
  5745. return children
  5746. }
  5747. // 2. When the children contains constructs that always generated nested Arrays,
  5748. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  5749. // with hand-written render functions / JSX. In such cases a full normalization
  5750. // is needed to cater to all possible types of children values.
  5751. function normalizeChildren (children) {
  5752. return isPrimitive(children)
  5753. ? [createTextVNode(children)]
  5754. : Array.isArray(children)
  5755. ? normalizeArrayChildren(children)
  5756. : undefined
  5757. }
  5758. function isTextNode (node) {
  5759. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  5760. }
  5761. function normalizeArrayChildren (children, nestedIndex) {
  5762. var res = [];
  5763. var i, c, lastIndex, last;
  5764. for (i = 0; i < children.length; i++) {
  5765. c = children[i];
  5766. if (isUndef(c) || typeof c === 'boolean') { continue }
  5767. lastIndex = res.length - 1;
  5768. last = res[lastIndex];
  5769. // nested
  5770. if (Array.isArray(c)) {
  5771. if (c.length > 0) {
  5772. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  5773. // merge adjacent text nodes
  5774. if (isTextNode(c[0]) && isTextNode(last)) {
  5775. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  5776. c.shift();
  5777. }
  5778. res.push.apply(res, c);
  5779. }
  5780. } else if (isPrimitive(c)) {
  5781. if (isTextNode(last)) {
  5782. // merge adjacent text nodes
  5783. // this is necessary for SSR hydration because text nodes are
  5784. // essentially merged when rendered to HTML strings
  5785. res[lastIndex] = createTextVNode(last.text + c);
  5786. } else if (c !== '') {
  5787. // convert primitive to vnode
  5788. res.push(createTextVNode(c));
  5789. }
  5790. } else {
  5791. if (isTextNode(c) && isTextNode(last)) {
  5792. // merge adjacent text nodes
  5793. res[lastIndex] = createTextVNode(last.text + c.text);
  5794. } else {
  5795. // default key for nested array children (likely generated by v-for)
  5796. if (isTrue(children._isVList) &&
  5797. isDef(c.tag) &&
  5798. isUndef(c.key) &&
  5799. isDef(nestedIndex)) {
  5800. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  5801. }
  5802. res.push(c);
  5803. }
  5804. }
  5805. }
  5806. return res
  5807. }
  5808. /* */
  5809. var ssrHelpers = {
  5810. _ssrEscape: escape,
  5811. _ssrNode: renderStringNode,
  5812. _ssrList: renderStringList,
  5813. _ssrAttr: renderAttr,
  5814. _ssrAttrs: renderAttrs$1,
  5815. _ssrDOMProps: renderDOMProps$1,
  5816. _ssrClass: renderSSRClass,
  5817. _ssrStyle: renderSSRStyle
  5818. };
  5819. function installSSRHelpers (vm) {
  5820. if (vm._ssrNode) {
  5821. return
  5822. }
  5823. var Vue = vm.constructor;
  5824. while (Vue.super) {
  5825. Vue = Vue.super;
  5826. }
  5827. extend(Vue.prototype, ssrHelpers);
  5828. if (Vue.FunctionalRenderContext) {
  5829. extend(Vue.FunctionalRenderContext.prototype, ssrHelpers);
  5830. }
  5831. }
  5832. var StringNode = function StringNode (
  5833. open,
  5834. close,
  5835. children,
  5836. normalizationType
  5837. ) {
  5838. this.isString = true;
  5839. this.open = open;
  5840. this.close = close;
  5841. if (children) {
  5842. this.children = normalizationType === 1
  5843. ? simpleNormalizeChildren(children)
  5844. : normalizationType === 2
  5845. ? normalizeChildren(children)
  5846. : children;
  5847. } else {
  5848. this.children = void 0;
  5849. }
  5850. };
  5851. function renderStringNode (
  5852. open,
  5853. close,
  5854. children,
  5855. normalizationType
  5856. ) {
  5857. return new StringNode(open, close, children, normalizationType)
  5858. }
  5859. function renderStringList (
  5860. val,
  5861. render
  5862. ) {
  5863. var ret = '';
  5864. var i, l, keys, key;
  5865. if (Array.isArray(val) || typeof val === 'string') {
  5866. for (i = 0, l = val.length; i < l; i++) {
  5867. ret += render(val[i], i);
  5868. }
  5869. } else if (typeof val === 'number') {
  5870. for (i = 0; i < val; i++) {
  5871. ret += render(i + 1, i);
  5872. }
  5873. } else if (isObject(val)) {
  5874. keys = Object.keys(val);
  5875. for (i = 0, l = keys.length; i < l; i++) {
  5876. key = keys[i];
  5877. ret += render(val[key], key, i);
  5878. }
  5879. }
  5880. return ret
  5881. }
  5882. function renderAttrs$1 (obj) {
  5883. var res = '';
  5884. for (var key in obj) {
  5885. if (isSSRUnsafeAttr(key)) {
  5886. continue
  5887. }
  5888. res += renderAttr(key, obj[key]);
  5889. }
  5890. return res
  5891. }
  5892. function renderDOMProps$1 (obj) {
  5893. var res = '';
  5894. for (var key in obj) {
  5895. var attr = propsToAttrMap[key] || key.toLowerCase();
  5896. if (isRenderableAttr(attr)) {
  5897. res += renderAttr(attr, obj[key]);
  5898. }
  5899. }
  5900. return res
  5901. }
  5902. function renderSSRClass (
  5903. staticClass,
  5904. dynamic
  5905. ) {
  5906. var res = renderClass(staticClass, dynamic);
  5907. return res === '' ? res : (" class=\"" + (escape(res)) + "\"")
  5908. }
  5909. function renderSSRStyle (
  5910. staticStyle,
  5911. dynamic,
  5912. extra
  5913. ) {
  5914. var style = {};
  5915. if (staticStyle) { extend(style, staticStyle); }
  5916. if (dynamic) { extend(style, normalizeStyleBinding(dynamic)); }
  5917. if (extra) { extend(style, extra); }
  5918. var res = genStyle(style);
  5919. return res === '' ? res : (" style=" + (JSON.stringify(escape(res))))
  5920. }
  5921. /* not type checking this file because flow doesn't play well with Proxy */
  5922. {
  5923. var allowedGlobals = makeMap(
  5924. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  5925. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  5926. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  5927. 'require' // for Webpack/Browserify
  5928. );
  5929. var hasProxy =
  5930. typeof Proxy !== 'undefined' && isNative(Proxy);
  5931. if (hasProxy) {
  5932. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  5933. config.keyCodes = new Proxy(config.keyCodes, {
  5934. set: function set (target, key, value) {
  5935. if (isBuiltInModifier(key)) {
  5936. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  5937. return false
  5938. } else {
  5939. target[key] = value;
  5940. return true
  5941. }
  5942. }
  5943. });
  5944. }
  5945. }
  5946. /* */
  5947. var seenObjects = new _Set();
  5948. /**
  5949. * Recursively traverse an object to evoke all converted
  5950. * getters, so that every nested property inside the object
  5951. * is collected as a "deep" dependency.
  5952. */
  5953. function traverse (val) {
  5954. _traverse(val, seenObjects);
  5955. seenObjects.clear();
  5956. }
  5957. function _traverse (val, seen) {
  5958. var i, keys;
  5959. var isA = Array.isArray(val);
  5960. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  5961. return
  5962. }
  5963. if (val.__ob__) {
  5964. var depId = val.__ob__.dep.id;
  5965. if (seen.has(depId)) {
  5966. return
  5967. }
  5968. seen.add(depId);
  5969. }
  5970. if (isA) {
  5971. i = val.length;
  5972. while (i--) { _traverse(val[i], seen); }
  5973. } else {
  5974. keys = Object.keys(val);
  5975. i = keys.length;
  5976. while (i--) { _traverse(val[keys[i]], seen); }
  5977. }
  5978. }
  5979. {
  5980. var perf = inBrowser && window.performance;
  5981. /* istanbul ignore if */
  5982. if (
  5983. perf &&
  5984. perf.mark &&
  5985. perf.measure &&
  5986. perf.clearMarks &&
  5987. perf.clearMeasures
  5988. ) ;
  5989. }
  5990. /* */
  5991. var normalizeEvent = cached(function (name) {
  5992. var passive = name.charAt(0) === '&';
  5993. name = passive ? name.slice(1) : name;
  5994. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  5995. name = once$$1 ? name.slice(1) : name;
  5996. var capture = name.charAt(0) === '!';
  5997. name = capture ? name.slice(1) : name;
  5998. return {
  5999. name: name,
  6000. once: once$$1,
  6001. capture: capture,
  6002. passive: passive
  6003. }
  6004. });
  6005. function createFnInvoker (fns, vm) {
  6006. function invoker () {
  6007. var arguments$1 = arguments;
  6008. var fns = invoker.fns;
  6009. if (Array.isArray(fns)) {
  6010. var cloned = fns.slice();
  6011. for (var i = 0; i < cloned.length; i++) {
  6012. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  6013. }
  6014. } else {
  6015. // return handler return value for single handlers
  6016. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  6017. }
  6018. }
  6019. invoker.fns = fns;
  6020. return invoker
  6021. }
  6022. function updateListeners (
  6023. on,
  6024. oldOn,
  6025. add,
  6026. remove$$1,
  6027. createOnceHandler,
  6028. vm
  6029. ) {
  6030. var name, def$$1, cur, old, event;
  6031. for (name in on) {
  6032. def$$1 = cur = on[name];
  6033. old = oldOn[name];
  6034. event = normalizeEvent(name);
  6035. if (isUndef(cur)) {
  6036. warn(
  6037. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  6038. vm
  6039. );
  6040. } else if (isUndef(old)) {
  6041. if (isUndef(cur.fns)) {
  6042. cur = on[name] = createFnInvoker(cur, vm);
  6043. }
  6044. if (isTrue(event.once)) {
  6045. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  6046. }
  6047. add(event.name, cur, event.capture, event.passive, event.params);
  6048. } else if (cur !== old) {
  6049. old.fns = cur;
  6050. on[name] = old;
  6051. }
  6052. }
  6053. for (name in oldOn) {
  6054. if (isUndef(on[name])) {
  6055. event = normalizeEvent(name);
  6056. remove$$1(event.name, oldOn[name], event.capture);
  6057. }
  6058. }
  6059. }
  6060. /* */
  6061. /* */
  6062. function extractPropsFromVNodeData (
  6063. data,
  6064. Ctor,
  6065. tag
  6066. ) {
  6067. // we are only extracting raw values here.
  6068. // validation and default values are handled in the child
  6069. // component itself.
  6070. var propOptions = Ctor.options.props;
  6071. if (isUndef(propOptions)) {
  6072. return
  6073. }
  6074. var res = {};
  6075. var attrs = data.attrs;
  6076. var props = data.props;
  6077. if (isDef(attrs) || isDef(props)) {
  6078. for (var key in propOptions) {
  6079. var altKey = hyphenate(key);
  6080. {
  6081. var keyInLowerCase = key.toLowerCase();
  6082. if (
  6083. key !== keyInLowerCase &&
  6084. attrs && hasOwn(attrs, keyInLowerCase)
  6085. ) {
  6086. tip(
  6087. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  6088. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  6089. " \"" + key + "\". " +
  6090. "Note that HTML attributes are case-insensitive and camelCased " +
  6091. "props need to use their kebab-case equivalents when using in-DOM " +
  6092. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  6093. );
  6094. }
  6095. }
  6096. checkProp(res, props, key, altKey, true) ||
  6097. checkProp(res, attrs, key, altKey, false);
  6098. }
  6099. }
  6100. return res
  6101. }
  6102. function checkProp (
  6103. res,
  6104. hash,
  6105. key,
  6106. altKey,
  6107. preserve
  6108. ) {
  6109. if (isDef(hash)) {
  6110. if (hasOwn(hash, key)) {
  6111. res[key] = hash[key];
  6112. if (!preserve) {
  6113. delete hash[key];
  6114. }
  6115. return true
  6116. } else if (hasOwn(hash, altKey)) {
  6117. res[key] = hash[altKey];
  6118. if (!preserve) {
  6119. delete hash[altKey];
  6120. }
  6121. return true
  6122. }
  6123. }
  6124. return false
  6125. }
  6126. /* */
  6127. var SIMPLE_NORMALIZE = 1;
  6128. var ALWAYS_NORMALIZE = 2;
  6129. // wrapper function for providing a more flexible interface
  6130. // without getting yelled at by flow
  6131. function createElement (
  6132. context,
  6133. tag,
  6134. data,
  6135. children,
  6136. normalizationType,
  6137. alwaysNormalize
  6138. ) {
  6139. if (Array.isArray(data) || isPrimitive(data)) {
  6140. normalizationType = children;
  6141. children = data;
  6142. data = undefined;
  6143. }
  6144. if (isTrue(alwaysNormalize)) {
  6145. normalizationType = ALWAYS_NORMALIZE;
  6146. }
  6147. return _createElement(context, tag, data, children, normalizationType)
  6148. }
  6149. function _createElement (
  6150. context,
  6151. tag,
  6152. data,
  6153. children,
  6154. normalizationType
  6155. ) {
  6156. if (isDef(data) && isDef((data).__ob__)) {
  6157. warn(
  6158. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  6159. 'Always create fresh vnode data objects in each render!',
  6160. context
  6161. );
  6162. return createEmptyVNode()
  6163. }
  6164. // object syntax in v-bind
  6165. if (isDef(data) && isDef(data.is)) {
  6166. tag = data.is;
  6167. }
  6168. if (!tag) {
  6169. // in case of component :is set to falsy value
  6170. return createEmptyVNode()
  6171. }
  6172. // warn against non-primitive key
  6173. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  6174. ) {
  6175. {
  6176. warn(
  6177. 'Avoid using non-primitive value as key, ' +
  6178. 'use string/number value instead.',
  6179. context
  6180. );
  6181. }
  6182. }
  6183. // support single function children as default scoped slot
  6184. if (Array.isArray(children) &&
  6185. typeof children[0] === 'function'
  6186. ) {
  6187. data = data || {};
  6188. data.scopedSlots = { default: children[0] };
  6189. children.length = 0;
  6190. }
  6191. if (normalizationType === ALWAYS_NORMALIZE) {
  6192. children = normalizeChildren(children);
  6193. } else if (normalizationType === SIMPLE_NORMALIZE) {
  6194. children = simpleNormalizeChildren(children);
  6195. }
  6196. var vnode, ns;
  6197. if (typeof tag === 'string') {
  6198. var Ctor;
  6199. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  6200. if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  6201. // component
  6202. vnode = createComponent(Ctor, data, context, children, tag);
  6203. } else {
  6204. // unknown or unlisted namespaced elements
  6205. // check at runtime because it may get assigned a namespace when its
  6206. // parent normalizes children
  6207. vnode = new VNode(
  6208. tag, data, children,
  6209. undefined, undefined, context
  6210. );
  6211. }
  6212. } else {
  6213. // direct component options / constructor
  6214. vnode = createComponent(tag, data, context, children);
  6215. }
  6216. if (Array.isArray(vnode)) {
  6217. return vnode
  6218. } else if (isDef(vnode)) {
  6219. if (isDef(ns)) { applyNS(vnode, ns); }
  6220. if (isDef(data)) { registerDeepBindings(data); }
  6221. return vnode
  6222. } else {
  6223. return createEmptyVNode()
  6224. }
  6225. }
  6226. function applyNS (vnode, ns, force) {
  6227. vnode.ns = ns;
  6228. if (vnode.tag === 'foreignObject') {
  6229. // use default namespace inside foreignObject
  6230. ns = undefined;
  6231. force = true;
  6232. }
  6233. if (isDef(vnode.children)) {
  6234. for (var i = 0, l = vnode.children.length; i < l; i++) {
  6235. var child = vnode.children[i];
  6236. if (isDef(child.tag) && (
  6237. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  6238. applyNS(child, ns, force);
  6239. }
  6240. }
  6241. }
  6242. }
  6243. // ref #5318
  6244. // necessary to ensure parent re-render when deep bindings like :style and
  6245. // :class are used on slot nodes
  6246. function registerDeepBindings (data) {
  6247. if (isObject(data.style)) {
  6248. traverse(data.style);
  6249. }
  6250. if (isObject(data.class)) {
  6251. traverse(data.class);
  6252. }
  6253. }
  6254. /* */
  6255. /**
  6256. * Runtime helper for rendering v-for lists.
  6257. */
  6258. function renderList (
  6259. val,
  6260. render
  6261. ) {
  6262. var ret, i, l, keys, key;
  6263. if (Array.isArray(val) || typeof val === 'string') {
  6264. ret = new Array(val.length);
  6265. for (i = 0, l = val.length; i < l; i++) {
  6266. ret[i] = render(val[i], i);
  6267. }
  6268. } else if (typeof val === 'number') {
  6269. ret = new Array(val);
  6270. for (i = 0; i < val; i++) {
  6271. ret[i] = render(i + 1, i);
  6272. }
  6273. } else if (isObject(val)) {
  6274. if (hasSymbol && val[Symbol.iterator]) {
  6275. ret = [];
  6276. var iterator = val[Symbol.iterator]();
  6277. var result = iterator.next();
  6278. while (!result.done) {
  6279. ret.push(render(result.value, ret.length));
  6280. result = iterator.next();
  6281. }
  6282. } else {
  6283. keys = Object.keys(val);
  6284. ret = new Array(keys.length);
  6285. for (i = 0, l = keys.length; i < l; i++) {
  6286. key = keys[i];
  6287. ret[i] = render(val[key], key, i);
  6288. }
  6289. }
  6290. }
  6291. if (!isDef(ret)) {
  6292. ret = [];
  6293. }
  6294. (ret)._isVList = true;
  6295. return ret
  6296. }
  6297. /* */
  6298. /**
  6299. * Runtime helper for rendering <slot>
  6300. */
  6301. function renderSlot (
  6302. name,
  6303. fallback,
  6304. props,
  6305. bindObject
  6306. ) {
  6307. var scopedSlotFn = this.$scopedSlots[name];
  6308. var nodes;
  6309. if (scopedSlotFn) { // scoped slot
  6310. props = props || {};
  6311. if (bindObject) {
  6312. if (!isObject(bindObject)) {
  6313. warn(
  6314. 'slot v-bind without argument expects an Object',
  6315. this
  6316. );
  6317. }
  6318. props = extend(extend({}, bindObject), props);
  6319. }
  6320. nodes = scopedSlotFn(props) || fallback;
  6321. } else {
  6322. nodes = this.$slots[name] || fallback;
  6323. }
  6324. var target = props && props.slot;
  6325. if (target) {
  6326. return this.$createElement('template', { slot: target }, nodes)
  6327. } else {
  6328. return nodes
  6329. }
  6330. }
  6331. /* */
  6332. /**
  6333. * Runtime helper for resolving filters
  6334. */
  6335. function resolveFilter (id) {
  6336. return resolveAsset(this.$options, 'filters', id, true) || identity
  6337. }
  6338. /* */
  6339. function isKeyNotMatch (expect, actual) {
  6340. if (Array.isArray(expect)) {
  6341. return expect.indexOf(actual) === -1
  6342. } else {
  6343. return expect !== actual
  6344. }
  6345. }
  6346. /**
  6347. * Runtime helper for checking keyCodes from config.
  6348. * exposed as Vue.prototype._k
  6349. * passing in eventKeyName as last argument separately for backwards compat
  6350. */
  6351. function checkKeyCodes (
  6352. eventKeyCode,
  6353. key,
  6354. builtInKeyCode,
  6355. eventKeyName,
  6356. builtInKeyName
  6357. ) {
  6358. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  6359. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  6360. return isKeyNotMatch(builtInKeyName, eventKeyName)
  6361. } else if (mappedKeyCode) {
  6362. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  6363. } else if (eventKeyName) {
  6364. return hyphenate(eventKeyName) !== key
  6365. }
  6366. }
  6367. /* */
  6368. /**
  6369. * Runtime helper for merging v-bind="object" into a VNode's data.
  6370. */
  6371. function bindObjectProps (
  6372. data,
  6373. tag,
  6374. value,
  6375. asProp,
  6376. isSync
  6377. ) {
  6378. if (value) {
  6379. if (!isObject(value)) {
  6380. warn(
  6381. 'v-bind without argument expects an Object or Array value',
  6382. this
  6383. );
  6384. } else {
  6385. if (Array.isArray(value)) {
  6386. value = toObject(value);
  6387. }
  6388. var hash;
  6389. var loop = function ( key ) {
  6390. if (
  6391. key === 'class' ||
  6392. key === 'style' ||
  6393. isReservedAttribute(key)
  6394. ) {
  6395. hash = data;
  6396. } else {
  6397. var type = data.attrs && data.attrs.type;
  6398. hash = asProp || config.mustUseProp(tag, type, key)
  6399. ? data.domProps || (data.domProps = {})
  6400. : data.attrs || (data.attrs = {});
  6401. }
  6402. var camelizedKey = camelize(key);
  6403. if (!(key in hash) && !(camelizedKey in hash)) {
  6404. hash[key] = value[key];
  6405. if (isSync) {
  6406. var on = data.on || (data.on = {});
  6407. on[("update:" + camelizedKey)] = function ($event) {
  6408. value[key] = $event;
  6409. };
  6410. }
  6411. }
  6412. };
  6413. for (var key in value) loop( key );
  6414. }
  6415. }
  6416. return data
  6417. }
  6418. /* */
  6419. /**
  6420. * Runtime helper for rendering static trees.
  6421. */
  6422. function renderStatic (
  6423. index,
  6424. isInFor
  6425. ) {
  6426. var cached = this._staticTrees || (this._staticTrees = []);
  6427. var tree = cached[index];
  6428. // if has already-rendered static tree and not inside v-for,
  6429. // we can reuse the same tree.
  6430. if (tree && !isInFor) {
  6431. return tree
  6432. }
  6433. // otherwise, render a fresh tree.
  6434. tree = cached[index] = this.$options.staticRenderFns[index].call(
  6435. this._renderProxy,
  6436. null,
  6437. this // for render fns generated for functional component templates
  6438. );
  6439. markStatic(tree, ("__static__" + index), false);
  6440. return tree
  6441. }
  6442. /**
  6443. * Runtime helper for v-once.
  6444. * Effectively it means marking the node as static with a unique key.
  6445. */
  6446. function markOnce (
  6447. tree,
  6448. index,
  6449. key
  6450. ) {
  6451. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  6452. return tree
  6453. }
  6454. function markStatic (
  6455. tree,
  6456. key,
  6457. isOnce
  6458. ) {
  6459. if (Array.isArray(tree)) {
  6460. for (var i = 0; i < tree.length; i++) {
  6461. if (tree[i] && typeof tree[i] !== 'string') {
  6462. markStaticNode(tree[i], (key + "_" + i), isOnce);
  6463. }
  6464. }
  6465. } else {
  6466. markStaticNode(tree, key, isOnce);
  6467. }
  6468. }
  6469. function markStaticNode (node, key, isOnce) {
  6470. node.isStatic = true;
  6471. node.key = key;
  6472. node.isOnce = isOnce;
  6473. }
  6474. /* */
  6475. function bindObjectListeners (data, value) {
  6476. if (value) {
  6477. if (!isPlainObject(value)) {
  6478. warn(
  6479. 'v-on without argument expects an Object value',
  6480. this
  6481. );
  6482. } else {
  6483. var on = data.on = data.on ? extend({}, data.on) : {};
  6484. for (var key in value) {
  6485. var existing = on[key];
  6486. var ours = value[key];
  6487. on[key] = existing ? [].concat(existing, ours) : ours;
  6488. }
  6489. }
  6490. }
  6491. return data
  6492. }
  6493. /* */
  6494. function resolveScopedSlots (
  6495. fns, // see flow/vnode
  6496. res,
  6497. // the following are added in 2.6
  6498. hasDynamicKeys,
  6499. contentHashKey
  6500. ) {
  6501. res = res || { $stable: !hasDynamicKeys };
  6502. for (var i = 0; i < fns.length; i++) {
  6503. var slot = fns[i];
  6504. if (Array.isArray(slot)) {
  6505. resolveScopedSlots(slot, res, hasDynamicKeys);
  6506. } else if (slot) {
  6507. // marker for reverse proxying v-slot without scope on this.$slots
  6508. if (slot.proxy) {
  6509. slot.fn.proxy = true;
  6510. }
  6511. res[slot.key] = slot.fn;
  6512. }
  6513. }
  6514. if (contentHashKey) {
  6515. (res).$key = contentHashKey;
  6516. }
  6517. return res
  6518. }
  6519. /* */
  6520. function bindDynamicKeys (baseObj, values) {
  6521. for (var i = 0; i < values.length; i += 2) {
  6522. var key = values[i];
  6523. if (typeof key === 'string' && key) {
  6524. baseObj[values[i]] = values[i + 1];
  6525. } else if (key !== '' && key !== null) {
  6526. // null is a speical value for explicitly removing a binding
  6527. warn(
  6528. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  6529. this
  6530. );
  6531. }
  6532. }
  6533. return baseObj
  6534. }
  6535. // helper to dynamically append modifier runtime markers to event names.
  6536. // ensure only append when value is already string, otherwise it will be cast
  6537. // to string and cause the type check to miss.
  6538. function prependModifier (value, symbol) {
  6539. return typeof value === 'string' ? symbol + value : value
  6540. }
  6541. /* */
  6542. function installRenderHelpers (target) {
  6543. target._o = markOnce;
  6544. target._n = toNumber;
  6545. target._s = toString;
  6546. target._l = renderList;
  6547. target._t = renderSlot;
  6548. target._q = looseEqual;
  6549. target._i = looseIndexOf;
  6550. target._m = renderStatic;
  6551. target._f = resolveFilter;
  6552. target._k = checkKeyCodes;
  6553. target._b = bindObjectProps;
  6554. target._v = createTextVNode;
  6555. target._e = createEmptyVNode;
  6556. target._u = resolveScopedSlots;
  6557. target._g = bindObjectListeners;
  6558. target._d = bindDynamicKeys;
  6559. target._p = prependModifier;
  6560. }
  6561. /* */
  6562. /**
  6563. * Runtime helper for resolving raw children VNodes into a slot object.
  6564. */
  6565. function resolveSlots (
  6566. children,
  6567. context
  6568. ) {
  6569. if (!children || !children.length) {
  6570. return {}
  6571. }
  6572. var slots = {};
  6573. for (var i = 0, l = children.length; i < l; i++) {
  6574. var child = children[i];
  6575. var data = child.data;
  6576. // remove slot attribute if the node is resolved as a Vue slot node
  6577. if (data && data.attrs && data.attrs.slot) {
  6578. delete data.attrs.slot;
  6579. }
  6580. // named slots should only be respected if the vnode was rendered in the
  6581. // same context.
  6582. if ((child.context === context || child.fnContext === context) &&
  6583. data && data.slot != null
  6584. ) {
  6585. var name = data.slot;
  6586. var slot = (slots[name] || (slots[name] = []));
  6587. if (child.tag === 'template') {
  6588. slot.push.apply(slot, child.children || []);
  6589. } else {
  6590. slot.push(child);
  6591. }
  6592. } else {
  6593. (slots.default || (slots.default = [])).push(child);
  6594. }
  6595. }
  6596. // ignore slots that contains only whitespace
  6597. for (var name$1 in slots) {
  6598. if (slots[name$1].every(isWhitespace)) {
  6599. delete slots[name$1];
  6600. }
  6601. }
  6602. return slots
  6603. }
  6604. function isWhitespace (node) {
  6605. return (node.isComment && !node.asyncFactory) || node.text === ' '
  6606. }
  6607. /* */
  6608. function normalizeScopedSlots (
  6609. slots,
  6610. normalSlots,
  6611. prevSlots
  6612. ) {
  6613. var res;
  6614. var isStable = slots ? !!slots.$stable : true;
  6615. var key = slots && slots.$key;
  6616. if (!slots) {
  6617. res = {};
  6618. } else if (slots._normalized) {
  6619. // fast path 1: child component re-render only, parent did not change
  6620. return slots._normalized
  6621. } else if (
  6622. isStable &&
  6623. prevSlots &&
  6624. prevSlots !== emptyObject &&
  6625. key === prevSlots.$key &&
  6626. Object.keys(normalSlots).length === 0
  6627. ) {
  6628. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  6629. // only need to normalize once
  6630. return prevSlots
  6631. } else {
  6632. res = {};
  6633. for (var key$1 in slots) {
  6634. if (slots[key$1] && key$1[0] !== '$') {
  6635. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  6636. }
  6637. }
  6638. }
  6639. // expose normal slots on scopedSlots
  6640. for (var key$2 in normalSlots) {
  6641. if (!(key$2 in res)) {
  6642. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  6643. }
  6644. }
  6645. // avoriaz seems to mock a non-extensible $scopedSlots object
  6646. // and when that is passed down this would cause an error
  6647. if (slots && Object.isExtensible(slots)) {
  6648. (slots)._normalized = res;
  6649. }
  6650. def(res, '$stable', isStable);
  6651. def(res, '$key', key);
  6652. return res
  6653. }
  6654. function normalizeScopedSlot(normalSlots, key, fn) {
  6655. var normalized = function () {
  6656. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  6657. res = res && typeof res === 'object' && !Array.isArray(res)
  6658. ? [res] // single vnode
  6659. : normalizeChildren(res);
  6660. return res && res.length === 0
  6661. ? undefined
  6662. : res
  6663. };
  6664. // this is a slot using the new v-slot syntax without scope. although it is
  6665. // compiled as a scoped slot, render fn users would expect it to be present
  6666. // on this.$slots because the usage is semantically a normal slot.
  6667. if (fn.proxy) {
  6668. Object.defineProperty(normalSlots, key, {
  6669. get: normalized,
  6670. enumerable: true,
  6671. configurable: true
  6672. });
  6673. }
  6674. return normalized
  6675. }
  6676. function proxyNormalSlot(slots, key) {
  6677. return function () { return slots[key]; }
  6678. }
  6679. /* */
  6680. var currentRenderingInstance = null;
  6681. /* */
  6682. function ensureCtor (comp, base) {
  6683. if (
  6684. comp.__esModule ||
  6685. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  6686. ) {
  6687. comp = comp.default;
  6688. }
  6689. return isObject(comp)
  6690. ? base.extend(comp)
  6691. : comp
  6692. }
  6693. function createAsyncPlaceholder (
  6694. factory,
  6695. data,
  6696. context,
  6697. children,
  6698. tag
  6699. ) {
  6700. var node = createEmptyVNode();
  6701. node.asyncFactory = factory;
  6702. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  6703. return node
  6704. }
  6705. function resolveAsyncComponent (
  6706. factory,
  6707. baseCtor
  6708. ) {
  6709. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  6710. return factory.errorComp
  6711. }
  6712. if (isDef(factory.resolved)) {
  6713. return factory.resolved
  6714. }
  6715. var owner = currentRenderingInstance;
  6716. if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  6717. // already pending
  6718. factory.owners.push(owner);
  6719. }
  6720. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  6721. return factory.loadingComp
  6722. }
  6723. if (!isDef(factory.owners)) {
  6724. var owners = factory.owners = [owner];
  6725. var sync = true
  6726. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  6727. var forceRender = function (renderCompleted) {
  6728. for (var i = 0, l = owners.length; i < l; i++) {
  6729. (owners[i]).$forceUpdate();
  6730. }
  6731. if (renderCompleted) {
  6732. owners.length = 0;
  6733. }
  6734. };
  6735. var resolve = once(function (res) {
  6736. // cache resolved
  6737. factory.resolved = ensureCtor(res, baseCtor);
  6738. // invoke callbacks only if this is not a synchronous resolve
  6739. // (async resolves are shimmed as synchronous during SSR)
  6740. if (!sync) {
  6741. forceRender(true);
  6742. } else {
  6743. owners.length = 0;
  6744. }
  6745. });
  6746. var reject = once(function (reason) {
  6747. warn(
  6748. "Failed to resolve async component: " + (String(factory)) +
  6749. (reason ? ("\nReason: " + reason) : '')
  6750. );
  6751. if (isDef(factory.errorComp)) {
  6752. factory.error = true;
  6753. forceRender(true);
  6754. }
  6755. });
  6756. var res = factory(resolve, reject);
  6757. if (isObject(res)) {
  6758. if (isPromise(res)) {
  6759. // () => Promise
  6760. if (isUndef(factory.resolved)) {
  6761. res.then(resolve, reject);
  6762. }
  6763. } else if (isPromise(res.component)) {
  6764. res.component.then(resolve, reject);
  6765. if (isDef(res.error)) {
  6766. factory.errorComp = ensureCtor(res.error, baseCtor);
  6767. }
  6768. if (isDef(res.loading)) {
  6769. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  6770. if (res.delay === 0) {
  6771. factory.loading = true;
  6772. } else {
  6773. setTimeout(function () {
  6774. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  6775. factory.loading = true;
  6776. forceRender(false);
  6777. }
  6778. }, res.delay || 200);
  6779. }
  6780. }
  6781. if (isDef(res.timeout)) {
  6782. setTimeout(function () {
  6783. if (isUndef(factory.resolved)) {
  6784. reject(
  6785. "timeout (" + (res.timeout) + "ms)"
  6786. );
  6787. }
  6788. }, res.timeout);
  6789. }
  6790. }
  6791. }
  6792. sync = false;
  6793. // return in case resolved synchronously
  6794. return factory.loading
  6795. ? factory.loadingComp
  6796. : factory.resolved
  6797. }
  6798. }
  6799. /* */
  6800. /* */
  6801. /* */
  6802. /* */
  6803. var target;
  6804. function add (event, fn) {
  6805. target.$on(event, fn);
  6806. }
  6807. function remove$1 (event, fn) {
  6808. target.$off(event, fn);
  6809. }
  6810. function createOnceHandler (event, fn) {
  6811. var _target = target;
  6812. return function onceHandler () {
  6813. var res = fn.apply(null, arguments);
  6814. if (res !== null) {
  6815. _target.$off(event, onceHandler);
  6816. }
  6817. }
  6818. }
  6819. function updateComponentListeners (
  6820. vm,
  6821. listeners,
  6822. oldListeners
  6823. ) {
  6824. target = vm;
  6825. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  6826. target = undefined;
  6827. }
  6828. /* */
  6829. var activeInstance = null;
  6830. function updateChildComponent (
  6831. vm,
  6832. propsData,
  6833. listeners,
  6834. parentVnode,
  6835. renderChildren
  6836. ) {
  6837. // determine whether component has slot children
  6838. // we need to do this before overwriting $options._renderChildren.
  6839. // check if there are dynamic scopedSlots (hand-written or compiled but with
  6840. // dynamic slot names). Static scoped slots compiled from template has the
  6841. // "$stable" marker.
  6842. var newScopedSlots = parentVnode.data.scopedSlots;
  6843. var oldScopedSlots = vm.$scopedSlots;
  6844. var hasDynamicScopedSlot = !!(
  6845. (newScopedSlots && !newScopedSlots.$stable) ||
  6846. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  6847. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  6848. );
  6849. // Any static slot children from the parent may have changed during parent's
  6850. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  6851. // update is necessary to ensure correctness.
  6852. var needsForceUpdate = !!(
  6853. renderChildren || // has new static slots
  6854. vm.$options._renderChildren || // has old static slots
  6855. hasDynamicScopedSlot
  6856. );
  6857. vm.$options._parentVnode = parentVnode;
  6858. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  6859. if (vm._vnode) { // update child tree's parent
  6860. vm._vnode.parent = parentVnode;
  6861. }
  6862. vm.$options._renderChildren = renderChildren;
  6863. // update $attrs and $listeners hash
  6864. // these are also reactive so they may trigger child update if the child
  6865. // used them during render
  6866. vm.$attrs = parentVnode.data.attrs || emptyObject;
  6867. vm.$listeners = listeners || emptyObject;
  6868. // update props
  6869. if (propsData && vm.$options.props) {
  6870. toggleObserving(false);
  6871. var props = vm._props;
  6872. var propKeys = vm.$options._propKeys || [];
  6873. for (var i = 0; i < propKeys.length; i++) {
  6874. var key = propKeys[i];
  6875. var propOptions = vm.$options.props; // wtf flow?
  6876. props[key] = validateProp(key, propOptions, propsData, vm);
  6877. }
  6878. toggleObserving(true);
  6879. // keep a copy of raw propsData
  6880. vm.$options.propsData = propsData;
  6881. }
  6882. // update listeners
  6883. listeners = listeners || emptyObject;
  6884. var oldListeners = vm.$options._parentListeners;
  6885. vm.$options._parentListeners = listeners;
  6886. updateComponentListeners(vm, listeners, oldListeners);
  6887. // resolve slots + force update if has children
  6888. if (needsForceUpdate) {
  6889. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  6890. vm.$forceUpdate();
  6891. }
  6892. }
  6893. function isInInactiveTree (vm) {
  6894. while (vm && (vm = vm.$parent)) {
  6895. if (vm._inactive) { return true }
  6896. }
  6897. return false
  6898. }
  6899. function activateChildComponent (vm, direct) {
  6900. if (direct) {
  6901. vm._directInactive = false;
  6902. if (isInInactiveTree(vm)) {
  6903. return
  6904. }
  6905. } else if (vm._directInactive) {
  6906. return
  6907. }
  6908. if (vm._inactive || vm._inactive === null) {
  6909. vm._inactive = false;
  6910. for (var i = 0; i < vm.$children.length; i++) {
  6911. activateChildComponent(vm.$children[i]);
  6912. }
  6913. callHook(vm, 'activated');
  6914. }
  6915. }
  6916. function deactivateChildComponent (vm, direct) {
  6917. if (direct) {
  6918. vm._directInactive = true;
  6919. if (isInInactiveTree(vm)) {
  6920. return
  6921. }
  6922. }
  6923. if (!vm._inactive) {
  6924. vm._inactive = true;
  6925. for (var i = 0; i < vm.$children.length; i++) {
  6926. deactivateChildComponent(vm.$children[i]);
  6927. }
  6928. callHook(vm, 'deactivated');
  6929. }
  6930. }
  6931. function callHook (vm, hook) {
  6932. // #7573 disable dep collection when invoking lifecycle hooks
  6933. pushTarget();
  6934. var handlers = vm.$options[hook];
  6935. var info = hook + " hook";
  6936. if (handlers) {
  6937. for (var i = 0, j = handlers.length; i < j; i++) {
  6938. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  6939. }
  6940. }
  6941. if (vm._hasHookEvent) {
  6942. vm.$emit('hook:' + hook);
  6943. }
  6944. popTarget();
  6945. }
  6946. /* */
  6947. // Async edge case fix requires storing an event listener's attach timestamp.
  6948. var getNow = Date.now;
  6949. // Determine what event timestamp the browser is using. Annoyingly, the
  6950. // timestamp can either be hi-res (relative to page load) or low-res
  6951. // (relative to UNIX epoch), so in order to compare time we have to use the
  6952. // same timestamp type when saving the flush timestamp.
  6953. if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
  6954. // if the low-res timestamp which is bigger than the event timestamp
  6955. // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
  6956. // and we need to use the hi-res version for event listeners as well.
  6957. getNow = function () { return performance.now(); };
  6958. }
  6959. /**
  6960. * Queue a kept-alive component that was activated during patch.
  6961. * The queue will be processed after the entire tree has been patched.
  6962. */
  6963. function queueActivatedComponent (vm) {
  6964. // setting _inactive to false here so that a render function can
  6965. // rely on checking whether it's in an inactive tree (e.g. router-view)
  6966. vm._inactive = false;
  6967. }
  6968. /* */
  6969. /* */
  6970. /* */
  6971. function resolveInject (inject, vm) {
  6972. if (inject) {
  6973. // inject is :any because flow is not smart enough to figure out cached
  6974. var result = Object.create(null);
  6975. var keys = hasSymbol
  6976. ? Reflect.ownKeys(inject)
  6977. : Object.keys(inject);
  6978. for (var i = 0; i < keys.length; i++) {
  6979. var key = keys[i];
  6980. // #6574 in case the inject object is observed...
  6981. if (key === '__ob__') { continue }
  6982. var provideKey = inject[key].from;
  6983. var source = vm;
  6984. while (source) {
  6985. if (source._provided && hasOwn(source._provided, provideKey)) {
  6986. result[key] = source._provided[provideKey];
  6987. break
  6988. }
  6989. source = source.$parent;
  6990. }
  6991. if (!source) {
  6992. if ('default' in inject[key]) {
  6993. var provideDefault = inject[key].default;
  6994. result[key] = typeof provideDefault === 'function'
  6995. ? provideDefault.call(vm)
  6996. : provideDefault;
  6997. } else {
  6998. warn(("Injection \"" + key + "\" not found"), vm);
  6999. }
  7000. }
  7001. }
  7002. return result
  7003. }
  7004. }
  7005. /* */
  7006. function resolveConstructorOptions (Ctor) {
  7007. var options = Ctor.options;
  7008. if (Ctor.super) {
  7009. var superOptions = resolveConstructorOptions(Ctor.super);
  7010. var cachedSuperOptions = Ctor.superOptions;
  7011. if (superOptions !== cachedSuperOptions) {
  7012. // super option changed,
  7013. // need to resolve new options.
  7014. Ctor.superOptions = superOptions;
  7015. // check if there are any late-modified/attached options (#4976)
  7016. var modifiedOptions = resolveModifiedOptions(Ctor);
  7017. // update base extend options
  7018. if (modifiedOptions) {
  7019. extend(Ctor.extendOptions, modifiedOptions);
  7020. }
  7021. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  7022. if (options.name) {
  7023. options.components[options.name] = Ctor;
  7024. }
  7025. }
  7026. }
  7027. return options
  7028. }
  7029. function resolveModifiedOptions (Ctor) {
  7030. var modified;
  7031. var latest = Ctor.options;
  7032. var sealed = Ctor.sealedOptions;
  7033. for (var key in latest) {
  7034. if (latest[key] !== sealed[key]) {
  7035. if (!modified) { modified = {}; }
  7036. modified[key] = latest[key];
  7037. }
  7038. }
  7039. return modified
  7040. }
  7041. /* */
  7042. function FunctionalRenderContext (
  7043. data,
  7044. props,
  7045. children,
  7046. parent,
  7047. Ctor
  7048. ) {
  7049. var this$1 = this;
  7050. var options = Ctor.options;
  7051. // ensure the createElement function in functional components
  7052. // gets a unique context - this is necessary for correct named slot check
  7053. var contextVm;
  7054. if (hasOwn(parent, '_uid')) {
  7055. contextVm = Object.create(parent);
  7056. // $flow-disable-line
  7057. contextVm._original = parent;
  7058. } else {
  7059. // the context vm passed in is a functional context as well.
  7060. // in this case we want to make sure we are able to get a hold to the
  7061. // real context instance.
  7062. contextVm = parent;
  7063. // $flow-disable-line
  7064. parent = parent._original;
  7065. }
  7066. var isCompiled = isTrue(options._compiled);
  7067. var needNormalization = !isCompiled;
  7068. this.data = data;
  7069. this.props = props;
  7070. this.children = children;
  7071. this.parent = parent;
  7072. this.listeners = data.on || emptyObject;
  7073. this.injections = resolveInject(options.inject, parent);
  7074. this.slots = function () {
  7075. if (!this$1.$slots) {
  7076. normalizeScopedSlots(
  7077. data.scopedSlots,
  7078. this$1.$slots = resolveSlots(children, parent)
  7079. );
  7080. }
  7081. return this$1.$slots
  7082. };
  7083. Object.defineProperty(this, 'scopedSlots', ({
  7084. enumerable: true,
  7085. get: function get () {
  7086. return normalizeScopedSlots(data.scopedSlots, this.slots())
  7087. }
  7088. }));
  7089. // support for compiled functional template
  7090. if (isCompiled) {
  7091. // exposing $options for renderStatic()
  7092. this.$options = options;
  7093. // pre-resolve slots for renderSlot()
  7094. this.$slots = this.slots();
  7095. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  7096. }
  7097. if (options._scopeId) {
  7098. this._c = function (a, b, c, d) {
  7099. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  7100. if (vnode && !Array.isArray(vnode)) {
  7101. vnode.fnScopeId = options._scopeId;
  7102. vnode.fnContext = parent;
  7103. }
  7104. return vnode
  7105. };
  7106. } else {
  7107. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  7108. }
  7109. }
  7110. installRenderHelpers(FunctionalRenderContext.prototype);
  7111. function createFunctionalComponent (
  7112. Ctor,
  7113. propsData,
  7114. data,
  7115. contextVm,
  7116. children
  7117. ) {
  7118. var options = Ctor.options;
  7119. var props = {};
  7120. var propOptions = options.props;
  7121. if (isDef(propOptions)) {
  7122. for (var key in propOptions) {
  7123. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  7124. }
  7125. } else {
  7126. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  7127. if (isDef(data.props)) { mergeProps(props, data.props); }
  7128. }
  7129. var renderContext = new FunctionalRenderContext(
  7130. data,
  7131. props,
  7132. children,
  7133. contextVm,
  7134. Ctor
  7135. );
  7136. var vnode = options.render.call(null, renderContext._c, renderContext);
  7137. if (vnode instanceof VNode) {
  7138. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  7139. } else if (Array.isArray(vnode)) {
  7140. var vnodes = normalizeChildren(vnode) || [];
  7141. var res = new Array(vnodes.length);
  7142. for (var i = 0; i < vnodes.length; i++) {
  7143. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  7144. }
  7145. return res
  7146. }
  7147. }
  7148. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  7149. // #7817 clone node before setting fnContext, otherwise if the node is reused
  7150. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  7151. // that should not be matched to match.
  7152. var clone = cloneVNode(vnode);
  7153. clone.fnContext = contextVm;
  7154. clone.fnOptions = options;
  7155. {
  7156. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  7157. }
  7158. if (data.slot) {
  7159. (clone.data || (clone.data = {})).slot = data.slot;
  7160. }
  7161. return clone
  7162. }
  7163. function mergeProps (to, from) {
  7164. for (var key in from) {
  7165. to[camelize(key)] = from[key];
  7166. }
  7167. }
  7168. /* */
  7169. /* */
  7170. /* */
  7171. /* */
  7172. // inline hooks to be invoked on component VNodes during patch
  7173. var componentVNodeHooks = {
  7174. init: function init (vnode, hydrating) {
  7175. if (
  7176. vnode.componentInstance &&
  7177. !vnode.componentInstance._isDestroyed &&
  7178. vnode.data.keepAlive
  7179. ) {
  7180. // kept-alive components, treat as a patch
  7181. var mountedNode = vnode; // work around flow
  7182. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  7183. } else {
  7184. var child = vnode.componentInstance = createComponentInstanceForVnode(
  7185. vnode,
  7186. activeInstance
  7187. );
  7188. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  7189. }
  7190. },
  7191. prepatch: function prepatch (oldVnode, vnode) {
  7192. var options = vnode.componentOptions;
  7193. var child = vnode.componentInstance = oldVnode.componentInstance;
  7194. updateChildComponent(
  7195. child,
  7196. options.propsData, // updated props
  7197. options.listeners, // updated listeners
  7198. vnode, // new parent vnode
  7199. options.children // new children
  7200. );
  7201. },
  7202. insert: function insert (vnode) {
  7203. var context = vnode.context;
  7204. var componentInstance = vnode.componentInstance;
  7205. if (!componentInstance._isMounted) {
  7206. componentInstance._isMounted = true;
  7207. callHook(componentInstance, 'mounted');
  7208. }
  7209. if (vnode.data.keepAlive) {
  7210. if (context._isMounted) {
  7211. // vue-router#1212
  7212. // During updates, a kept-alive component's child components may
  7213. // change, so directly walking the tree here may call activated hooks
  7214. // on incorrect children. Instead we push them into a queue which will
  7215. // be processed after the whole patch process ended.
  7216. queueActivatedComponent(componentInstance);
  7217. } else {
  7218. activateChildComponent(componentInstance, true /* direct */);
  7219. }
  7220. }
  7221. },
  7222. destroy: function destroy (vnode) {
  7223. var componentInstance = vnode.componentInstance;
  7224. if (!componentInstance._isDestroyed) {
  7225. if (!vnode.data.keepAlive) {
  7226. componentInstance.$destroy();
  7227. } else {
  7228. deactivateChildComponent(componentInstance, true /* direct */);
  7229. }
  7230. }
  7231. }
  7232. };
  7233. var hooksToMerge = Object.keys(componentVNodeHooks);
  7234. function createComponent (
  7235. Ctor,
  7236. data,
  7237. context,
  7238. children,
  7239. tag
  7240. ) {
  7241. if (isUndef(Ctor)) {
  7242. return
  7243. }
  7244. var baseCtor = context.$options._base;
  7245. // plain options object: turn it into a constructor
  7246. if (isObject(Ctor)) {
  7247. Ctor = baseCtor.extend(Ctor);
  7248. }
  7249. // if at this stage it's not a constructor or an async component factory,
  7250. // reject.
  7251. if (typeof Ctor !== 'function') {
  7252. {
  7253. warn(("Invalid Component definition: " + (String(Ctor))), context);
  7254. }
  7255. return
  7256. }
  7257. // async component
  7258. var asyncFactory;
  7259. if (isUndef(Ctor.cid)) {
  7260. asyncFactory = Ctor;
  7261. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  7262. if (Ctor === undefined) {
  7263. // return a placeholder node for async component, which is rendered
  7264. // as a comment node but preserves all the raw information for the node.
  7265. // the information will be used for async server-rendering and hydration.
  7266. return createAsyncPlaceholder(
  7267. asyncFactory,
  7268. data,
  7269. context,
  7270. children,
  7271. tag
  7272. )
  7273. }
  7274. }
  7275. data = data || {};
  7276. // resolve constructor options in case global mixins are applied after
  7277. // component constructor creation
  7278. resolveConstructorOptions(Ctor);
  7279. // transform component v-model data into props & events
  7280. if (isDef(data.model)) {
  7281. transformModel(Ctor.options, data);
  7282. }
  7283. // extract props
  7284. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  7285. // functional component
  7286. if (isTrue(Ctor.options.functional)) {
  7287. return createFunctionalComponent(Ctor, propsData, data, context, children)
  7288. }
  7289. // extract listeners, since these needs to be treated as
  7290. // child component listeners instead of DOM listeners
  7291. var listeners = data.on;
  7292. // replace with listeners with .native modifier
  7293. // so it gets processed during parent component patch.
  7294. data.on = data.nativeOn;
  7295. if (isTrue(Ctor.options.abstract)) {
  7296. // abstract components do not keep anything
  7297. // other than props & listeners & slot
  7298. // work around flow
  7299. var slot = data.slot;
  7300. data = {};
  7301. if (slot) {
  7302. data.slot = slot;
  7303. }
  7304. }
  7305. // install component management hooks onto the placeholder node
  7306. installComponentHooks(data);
  7307. // return a placeholder vnode
  7308. var name = Ctor.options.name || tag;
  7309. var vnode = new VNode(
  7310. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  7311. data, undefined, undefined, undefined, context,
  7312. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  7313. asyncFactory
  7314. );
  7315. return vnode
  7316. }
  7317. function createComponentInstanceForVnode (
  7318. vnode, // we know it's MountedComponentVNode but flow doesn't
  7319. parent // activeInstance in lifecycle state
  7320. ) {
  7321. var options = {
  7322. _isComponent: true,
  7323. _parentVnode: vnode,
  7324. parent: parent
  7325. };
  7326. // check inline-template render functions
  7327. var inlineTemplate = vnode.data.inlineTemplate;
  7328. if (isDef(inlineTemplate)) {
  7329. options.render = inlineTemplate.render;
  7330. options.staticRenderFns = inlineTemplate.staticRenderFns;
  7331. }
  7332. return new vnode.componentOptions.Ctor(options)
  7333. }
  7334. function installComponentHooks (data) {
  7335. var hooks = data.hook || (data.hook = {});
  7336. for (var i = 0; i < hooksToMerge.length; i++) {
  7337. var key = hooksToMerge[i];
  7338. var existing = hooks[key];
  7339. var toMerge = componentVNodeHooks[key];
  7340. if (existing !== toMerge && !(existing && existing._merged)) {
  7341. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  7342. }
  7343. }
  7344. }
  7345. function mergeHook$1 (f1, f2) {
  7346. var merged = function (a, b) {
  7347. // flow complains about extra args which is why we use any
  7348. f1(a, b);
  7349. f2(a, b);
  7350. };
  7351. merged._merged = true;
  7352. return merged
  7353. }
  7354. // transform component v-model info (value and callback) into
  7355. // prop and event handler respectively.
  7356. function transformModel (options, data) {
  7357. var prop = (options.model && options.model.prop) || 'value';
  7358. var event = (options.model && options.model.event) || 'input'
  7359. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  7360. var on = data.on || (data.on = {});
  7361. var existing = on[event];
  7362. var callback = data.model.callback;
  7363. if (isDef(existing)) {
  7364. if (
  7365. Array.isArray(existing)
  7366. ? existing.indexOf(callback) === -1
  7367. : existing !== callback
  7368. ) {
  7369. on[event] = [callback].concat(existing);
  7370. }
  7371. } else {
  7372. on[event] = callback;
  7373. }
  7374. }
  7375. /* */
  7376. var warned = Object.create(null);
  7377. var warnOnce = function (msg) {
  7378. if (!warned[msg]) {
  7379. warned[msg] = true;
  7380. // eslint-disable-next-line no-console
  7381. console.warn(("\n\u001b[31m" + msg + "\u001b[39m\n"));
  7382. }
  7383. };
  7384. var onCompilationError = function (err, vm) {
  7385. var trace = vm ? generateComponentTrace(vm) : '';
  7386. throw new Error(("\n\u001b[31m" + err + trace + "\u001b[39m\n"))
  7387. };
  7388. var normalizeRender = function (vm) {
  7389. var ref = vm.$options;
  7390. var render = ref.render;
  7391. var template = ref.template;
  7392. var _scopeId = ref._scopeId;
  7393. if (isUndef(render)) {
  7394. if (template) {
  7395. var compiled = compileToFunctions(template, {
  7396. scopeId: _scopeId,
  7397. warn: onCompilationError
  7398. }, vm);
  7399. vm.$options.render = compiled.render;
  7400. vm.$options.staticRenderFns = compiled.staticRenderFns;
  7401. } else {
  7402. throw new Error(
  7403. ("render function or template not defined in component: " + (vm.$options.name || vm.$options._componentTag || 'anonymous'))
  7404. )
  7405. }
  7406. }
  7407. };
  7408. function waitForServerPrefetch (vm, resolve, reject) {
  7409. var handlers = vm.$options.serverPrefetch;
  7410. if (isDef(handlers)) {
  7411. if (!Array.isArray(handlers)) { handlers = [handlers]; }
  7412. try {
  7413. var promises = [];
  7414. for (var i = 0, j = handlers.length; i < j; i++) {
  7415. var result = handlers[i].call(vm, vm);
  7416. if (result && typeof result.then === 'function') {
  7417. promises.push(result);
  7418. }
  7419. }
  7420. Promise.all(promises).then(resolve).catch(reject);
  7421. return
  7422. } catch (e) {
  7423. reject(e);
  7424. }
  7425. }
  7426. resolve();
  7427. }
  7428. function renderNode (node, isRoot, context) {
  7429. if (node.isString) {
  7430. renderStringNode$1(node, context);
  7431. } else if (isDef(node.componentOptions)) {
  7432. renderComponent(node, isRoot, context);
  7433. } else if (isDef(node.tag)) {
  7434. renderElement(node, isRoot, context);
  7435. } else if (isTrue(node.isComment)) {
  7436. if (isDef(node.asyncFactory)) {
  7437. // async component
  7438. renderAsyncComponent(node, isRoot, context);
  7439. } else {
  7440. context.write(("<!--" + (node.text) + "-->"), context.next);
  7441. }
  7442. } else {
  7443. context.write(
  7444. node.raw ? node.text : escape(String(node.text)),
  7445. context.next
  7446. );
  7447. }
  7448. }
  7449. function registerComponentForCache (options, write) {
  7450. // exposed by vue-loader, need to call this if cache hit because
  7451. // component lifecycle hooks will not be called.
  7452. var register = options._ssrRegister;
  7453. if (write.caching && isDef(register)) {
  7454. write.componentBuffer[write.componentBuffer.length - 1].add(register);
  7455. }
  7456. return register
  7457. }
  7458. function renderComponent (node, isRoot, context) {
  7459. var write = context.write;
  7460. var next = context.next;
  7461. var userContext = context.userContext;
  7462. // check cache hit
  7463. var Ctor = node.componentOptions.Ctor;
  7464. var getKey = Ctor.options.serverCacheKey;
  7465. var name = Ctor.options.name;
  7466. var cache = context.cache;
  7467. var registerComponent = registerComponentForCache(Ctor.options, write);
  7468. if (isDef(getKey) && isDef(cache) && isDef(name)) {
  7469. var rawKey = getKey(node.componentOptions.propsData);
  7470. if (rawKey === false) {
  7471. renderComponentInner(node, isRoot, context);
  7472. return
  7473. }
  7474. var key = name + '::' + rawKey;
  7475. var has = context.has;
  7476. var get = context.get;
  7477. if (isDef(has)) {
  7478. has(key, function (hit) {
  7479. if (hit === true && isDef(get)) {
  7480. get(key, function (res) {
  7481. if (isDef(registerComponent)) {
  7482. registerComponent(userContext);
  7483. }
  7484. res.components.forEach(function (register) { return register(userContext); });
  7485. write(res.html, next);
  7486. });
  7487. } else {
  7488. renderComponentWithCache(node, isRoot, key, context);
  7489. }
  7490. });
  7491. } else if (isDef(get)) {
  7492. get(key, function (res) {
  7493. if (isDef(res)) {
  7494. if (isDef(registerComponent)) {
  7495. registerComponent(userContext);
  7496. }
  7497. res.components.forEach(function (register) { return register(userContext); });
  7498. write(res.html, next);
  7499. } else {
  7500. renderComponentWithCache(node, isRoot, key, context);
  7501. }
  7502. });
  7503. }
  7504. } else {
  7505. if (isDef(getKey) && isUndef(cache)) {
  7506. warnOnce(
  7507. "[vue-server-renderer] Component " + (Ctor.options.name || '(anonymous)') + " implemented serverCacheKey, " +
  7508. 'but no cache was provided to the renderer.'
  7509. );
  7510. }
  7511. if (isDef(getKey) && isUndef(name)) {
  7512. warnOnce(
  7513. "[vue-server-renderer] Components that implement \"serverCacheKey\" " +
  7514. "must also define a unique \"name\" option."
  7515. );
  7516. }
  7517. renderComponentInner(node, isRoot, context);
  7518. }
  7519. }
  7520. function renderComponentWithCache (node, isRoot, key, context) {
  7521. var write = context.write;
  7522. write.caching = true;
  7523. var buffer = write.cacheBuffer;
  7524. var bufferIndex = buffer.push('') - 1;
  7525. var componentBuffer = write.componentBuffer;
  7526. componentBuffer.push(new Set());
  7527. context.renderStates.push({
  7528. type: 'ComponentWithCache',
  7529. key: key,
  7530. buffer: buffer,
  7531. bufferIndex: bufferIndex,
  7532. componentBuffer: componentBuffer
  7533. });
  7534. renderComponentInner(node, isRoot, context);
  7535. }
  7536. function renderComponentInner (node, isRoot, context) {
  7537. var prevActive = context.activeInstance;
  7538. // expose userContext on vnode
  7539. node.ssrContext = context.userContext;
  7540. var child = context.activeInstance = createComponentInstanceForVnode(
  7541. node,
  7542. context.activeInstance
  7543. );
  7544. normalizeRender(child);
  7545. var resolve = function () {
  7546. var childNode = child._render();
  7547. childNode.parent = node;
  7548. context.renderStates.push({
  7549. type: 'Component',
  7550. prevActive: prevActive
  7551. });
  7552. renderNode(childNode, isRoot, context);
  7553. };
  7554. var reject = context.done;
  7555. waitForServerPrefetch(child, resolve, reject);
  7556. }
  7557. function renderAsyncComponent (node, isRoot, context) {
  7558. var factory = node.asyncFactory;
  7559. var resolve = function (comp) {
  7560. if (comp.__esModule && comp.default) {
  7561. comp = comp.default;
  7562. }
  7563. var ref = node.asyncMeta;
  7564. var data = ref.data;
  7565. var children = ref.children;
  7566. var tag = ref.tag;
  7567. var nodeContext = node.asyncMeta.context;
  7568. var resolvedNode = createComponent(
  7569. comp,
  7570. data,
  7571. nodeContext,
  7572. children,
  7573. tag
  7574. );
  7575. if (resolvedNode) {
  7576. if (resolvedNode.componentOptions) {
  7577. // normal component
  7578. renderComponent(resolvedNode, isRoot, context);
  7579. } else if (!Array.isArray(resolvedNode)) {
  7580. // single return node from functional component
  7581. renderNode(resolvedNode, isRoot, context);
  7582. } else {
  7583. // multiple return nodes from functional component
  7584. context.renderStates.push({
  7585. type: 'Fragment',
  7586. children: resolvedNode,
  7587. rendered: 0,
  7588. total: resolvedNode.length
  7589. });
  7590. context.next();
  7591. }
  7592. } else {
  7593. // invalid component, but this does not throw on the client
  7594. // so render empty comment node
  7595. context.write("<!---->", context.next);
  7596. }
  7597. };
  7598. if (factory.resolved) {
  7599. resolve(factory.resolved);
  7600. return
  7601. }
  7602. var reject = context.done;
  7603. var res;
  7604. try {
  7605. res = factory(resolve, reject);
  7606. } catch (e) {
  7607. reject(e);
  7608. }
  7609. if (res) {
  7610. if (typeof res.then === 'function') {
  7611. res.then(resolve, reject).catch(reject);
  7612. } else {
  7613. // new syntax in 2.3
  7614. var comp = res.component;
  7615. if (comp && typeof comp.then === 'function') {
  7616. comp.then(resolve, reject).catch(reject);
  7617. }
  7618. }
  7619. }
  7620. }
  7621. function renderStringNode$1 (el, context) {
  7622. var write = context.write;
  7623. var next = context.next;
  7624. if (isUndef(el.children) || el.children.length === 0) {
  7625. write(el.open + (el.close || ''), next);
  7626. } else {
  7627. var children = el.children;
  7628. context.renderStates.push({
  7629. type: 'Element',
  7630. children: children,
  7631. rendered: 0,
  7632. total: children.length,
  7633. endTag: el.close
  7634. });
  7635. write(el.open, next);
  7636. }
  7637. }
  7638. function renderElement (el, isRoot, context) {
  7639. var write = context.write;
  7640. var next = context.next;
  7641. if (isTrue(isRoot)) {
  7642. if (!el.data) { el.data = {}; }
  7643. if (!el.data.attrs) { el.data.attrs = {}; }
  7644. el.data.attrs[SSR_ATTR] = 'true';
  7645. }
  7646. if (el.fnOptions) {
  7647. registerComponentForCache(el.fnOptions, write);
  7648. }
  7649. var startTag = renderStartingTag(el, context);
  7650. var endTag = "</" + (el.tag) + ">";
  7651. if (context.isUnaryTag(el.tag)) {
  7652. write(startTag, next);
  7653. } else if (isUndef(el.children) || el.children.length === 0) {
  7654. write(startTag + endTag, next);
  7655. } else {
  7656. var children = el.children;
  7657. context.renderStates.push({
  7658. type: 'Element',
  7659. children: children,
  7660. rendered: 0,
  7661. total: children.length,
  7662. endTag: endTag
  7663. });
  7664. write(startTag, next);
  7665. }
  7666. }
  7667. function hasAncestorData (node) {
  7668. var parentNode = node.parent;
  7669. return isDef(parentNode) && (isDef(parentNode.data) || hasAncestorData(parentNode))
  7670. }
  7671. function getVShowDirectiveInfo (node) {
  7672. var dir;
  7673. var tmp;
  7674. while (isDef(node)) {
  7675. if (node.data && node.data.directives) {
  7676. tmp = node.data.directives.find(function (dir) { return dir.name === 'show'; });
  7677. if (tmp) {
  7678. dir = tmp;
  7679. }
  7680. }
  7681. node = node.parent;
  7682. }
  7683. return dir
  7684. }
  7685. function renderStartingTag (node, context) {
  7686. var markup = "<" + (node.tag);
  7687. var directives = context.directives;
  7688. var modules = context.modules;
  7689. // construct synthetic data for module processing
  7690. // because modules like style also produce code by parent VNode data
  7691. if (isUndef(node.data) && hasAncestorData(node)) {
  7692. node.data = {};
  7693. }
  7694. if (isDef(node.data)) {
  7695. // check directives
  7696. var dirs = node.data.directives;
  7697. if (dirs) {
  7698. for (var i = 0; i < dirs.length; i++) {
  7699. var name = dirs[i].name;
  7700. if (name !== 'show') {
  7701. var dirRenderer = resolveAsset(context, 'directives', name);
  7702. if (dirRenderer) {
  7703. // directives mutate the node's data
  7704. // which then gets rendered by modules
  7705. dirRenderer(node, dirs[i]);
  7706. }
  7707. }
  7708. }
  7709. }
  7710. // v-show directive needs to be merged from parent to child
  7711. var vshowDirectiveInfo = getVShowDirectiveInfo(node);
  7712. if (vshowDirectiveInfo) {
  7713. directives.show(node, vshowDirectiveInfo);
  7714. }
  7715. // apply other modules
  7716. for (var i$1 = 0; i$1 < modules.length; i$1++) {
  7717. var res = modules[i$1](node);
  7718. if (res) {
  7719. markup += res;
  7720. }
  7721. }
  7722. }
  7723. // attach scoped CSS ID
  7724. var scopeId;
  7725. var activeInstance = context.activeInstance;
  7726. if (isDef(activeInstance) &&
  7727. activeInstance !== node.context &&
  7728. isDef(scopeId = activeInstance.$options._scopeId)
  7729. ) {
  7730. markup += " " + ((scopeId));
  7731. }
  7732. if (isDef(node.fnScopeId)) {
  7733. markup += " " + (node.fnScopeId);
  7734. } else {
  7735. while (isDef(node)) {
  7736. if (isDef(scopeId = node.context.$options._scopeId)) {
  7737. markup += " " + scopeId;
  7738. }
  7739. node = node.parent;
  7740. }
  7741. }
  7742. return markup + '>'
  7743. }
  7744. function createRenderFunction (
  7745. modules,
  7746. directives,
  7747. isUnaryTag,
  7748. cache
  7749. ) {
  7750. return function render (
  7751. component,
  7752. write,
  7753. userContext,
  7754. done
  7755. ) {
  7756. warned = Object.create(null);
  7757. var context = new RenderContext({
  7758. activeInstance: component,
  7759. userContext: userContext,
  7760. write: write, done: done, renderNode: renderNode,
  7761. isUnaryTag: isUnaryTag, modules: modules, directives: directives,
  7762. cache: cache
  7763. });
  7764. installSSRHelpers(component);
  7765. normalizeRender(component);
  7766. var resolve = function () {
  7767. renderNode(component._render(), true, context);
  7768. };
  7769. waitForServerPrefetch(component, resolve, done);
  7770. }
  7771. }
  7772. /* */
  7773. var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
  7774. var isCSS = function (file) { return /\.css(\?[^.]+)?$/.test(file); };
  7775. function createPromiseCallback () {
  7776. var resolve, reject;
  7777. var promise = new Promise(function (_resolve, _reject) {
  7778. resolve = _resolve;
  7779. reject = _reject;
  7780. });
  7781. var cb = function (err, res) {
  7782. if (err) { return reject(err) }
  7783. resolve(res || '');
  7784. };
  7785. return { promise: promise, cb: cb }
  7786. }
  7787. /* */
  7788. var Transform = require('stream').Transform;
  7789. var TemplateStream = /*@__PURE__*/(function (Transform) {
  7790. function TemplateStream (
  7791. renderer,
  7792. template,
  7793. context
  7794. ) {
  7795. Transform.call(this);
  7796. this.started = false;
  7797. this.renderer = renderer;
  7798. this.template = template;
  7799. this.context = context || {};
  7800. this.inject = renderer.inject;
  7801. }
  7802. if ( Transform ) TemplateStream.__proto__ = Transform;
  7803. TemplateStream.prototype = Object.create( Transform && Transform.prototype );
  7804. TemplateStream.prototype.constructor = TemplateStream;
  7805. TemplateStream.prototype._transform = function _transform (data, encoding, done) {
  7806. if (!this.started) {
  7807. this.emit('beforeStart');
  7808. this.start();
  7809. }
  7810. this.push(data);
  7811. done();
  7812. };
  7813. TemplateStream.prototype.start = function start () {
  7814. this.started = true;
  7815. this.push(this.template.head(this.context));
  7816. if (this.inject) {
  7817. // inline server-rendered head meta information
  7818. if (this.context.head) {
  7819. this.push(this.context.head);
  7820. }
  7821. // inline preload/prefetch directives for initial/async chunks
  7822. var links = this.renderer.renderResourceHints(this.context);
  7823. if (links) {
  7824. this.push(links);
  7825. }
  7826. // CSS files and inline server-rendered CSS collected by vue-style-loader
  7827. var styles = this.renderer.renderStyles(this.context);
  7828. if (styles) {
  7829. this.push(styles);
  7830. }
  7831. }
  7832. this.push(this.template.neck(this.context));
  7833. };
  7834. TemplateStream.prototype._flush = function _flush (done) {
  7835. this.emit('beforeEnd');
  7836. if (this.inject) {
  7837. // inline initial store state
  7838. var state = this.renderer.renderState(this.context);
  7839. if (state) {
  7840. this.push(state);
  7841. }
  7842. // embed scripts needed
  7843. var scripts = this.renderer.renderScripts(this.context);
  7844. if (scripts) {
  7845. this.push(scripts);
  7846. }
  7847. }
  7848. this.push(this.template.tail(this.context));
  7849. done();
  7850. };
  7851. return TemplateStream;
  7852. }(Transform));
  7853. /* */
  7854. var compile$1 = require('lodash.template');
  7855. var compileOptions = {
  7856. escape: /{{([^{][\s\S]+?[^}])}}/g,
  7857. interpolate: /{{{([\s\S]+?)}}}/g
  7858. };
  7859. function parseTemplate (
  7860. template,
  7861. contentPlaceholder
  7862. ) {
  7863. if ( contentPlaceholder === void 0 ) contentPlaceholder = '<!--vue-ssr-outlet-->';
  7864. if (typeof template === 'object') {
  7865. return template
  7866. }
  7867. var i = template.indexOf('</head>');
  7868. var j = template.indexOf(contentPlaceholder);
  7869. if (j < 0) {
  7870. throw new Error("Content placeholder not found in template.")
  7871. }
  7872. if (i < 0) {
  7873. i = template.indexOf('<body>');
  7874. if (i < 0) {
  7875. i = j;
  7876. }
  7877. }
  7878. return {
  7879. head: compile$1(template.slice(0, i), compileOptions),
  7880. neck: compile$1(template.slice(i, j), compileOptions),
  7881. tail: compile$1(template.slice(j + contentPlaceholder.length), compileOptions)
  7882. }
  7883. }
  7884. /* */
  7885. /**
  7886. * Creates a mapper that maps components used during a server-side render
  7887. * to async chunk files in the client-side build, so that we can inline them
  7888. * directly in the rendered HTML to avoid waterfall requests.
  7889. */
  7890. function createMapper (
  7891. clientManifest
  7892. ) {
  7893. var map = createMap(clientManifest);
  7894. // map server-side moduleIds to client-side files
  7895. return function mapper (moduleIds) {
  7896. var res = new Set();
  7897. for (var i = 0; i < moduleIds.length; i++) {
  7898. var mapped = map.get(moduleIds[i]);
  7899. if (mapped) {
  7900. for (var j = 0; j < mapped.length; j++) {
  7901. res.add(mapped[j]);
  7902. }
  7903. }
  7904. }
  7905. return Array.from(res)
  7906. }
  7907. }
  7908. function createMap (clientManifest) {
  7909. var map = new Map();
  7910. Object.keys(clientManifest.modules).forEach(function (id) {
  7911. map.set(id, mapIdToFile(id, clientManifest));
  7912. });
  7913. return map
  7914. }
  7915. function mapIdToFile (id, clientManifest) {
  7916. var files = [];
  7917. var fileIndices = clientManifest.modules[id];
  7918. if (fileIndices) {
  7919. fileIndices.forEach(function (index) {
  7920. var file = clientManifest.all[index];
  7921. // only include async files or non-js assets
  7922. if (clientManifest.async.indexOf(file) > -1 || !(/\.js($|\?)/.test(file))) {
  7923. files.push(file);
  7924. }
  7925. });
  7926. }
  7927. return files
  7928. }
  7929. /* */
  7930. var path = require('path');
  7931. var serialize = require('serialize-javascript');
  7932. var TemplateRenderer = function TemplateRenderer (options) {
  7933. this.options = options;
  7934. this.inject = options.inject !== false;
  7935. // if no template option is provided, the renderer is created
  7936. // as a utility object for rendering assets like preload links and scripts.
  7937. var template = options.template;
  7938. this.parsedTemplate = template
  7939. ? typeof template === 'string'
  7940. ? parseTemplate(template)
  7941. : template
  7942. : null;
  7943. // function used to serialize initial state JSON
  7944. this.serialize = options.serializer || (function (state) {
  7945. return serialize(state, { isJSON: true })
  7946. });
  7947. // extra functionality with client manifest
  7948. if (options.clientManifest) {
  7949. var clientManifest = this.clientManifest = options.clientManifest;
  7950. // ensure publicPath ends with /
  7951. this.publicPath = clientManifest.publicPath === ''
  7952. ? ''
  7953. : clientManifest.publicPath.replace(/([^\/])$/, '$1/');
  7954. // preload/prefetch directives
  7955. this.preloadFiles = (clientManifest.initial || []).map(normalizeFile);
  7956. this.prefetchFiles = (clientManifest.async || []).map(normalizeFile);
  7957. // initial async chunk mapping
  7958. this.mapFiles = createMapper(clientManifest);
  7959. }
  7960. };
  7961. TemplateRenderer.prototype.bindRenderFns = function bindRenderFns (context) {
  7962. var renderer = this
  7963. ;['ResourceHints', 'State', 'Scripts', 'Styles'].forEach(function (type) {
  7964. context[("render" + type)] = renderer[("render" + type)].bind(renderer, context);
  7965. });
  7966. // also expose getPreloadFiles, useful for HTTP/2 push
  7967. context.getPreloadFiles = renderer.getPreloadFiles.bind(renderer, context);
  7968. };
  7969. // render synchronously given rendered app content and render context
  7970. TemplateRenderer.prototype.render = function render (content, context) {
  7971. var template = this.parsedTemplate;
  7972. if (!template) {
  7973. throw new Error('render cannot be called without a template.')
  7974. }
  7975. context = context || {};
  7976. if (typeof template === 'function') {
  7977. return template(content, context)
  7978. }
  7979. if (this.inject) {
  7980. return (
  7981. template.head(context) +
  7982. (context.head || '') +
  7983. this.renderResourceHints(context) +
  7984. this.renderStyles(context) +
  7985. template.neck(context) +
  7986. content +
  7987. this.renderState(context) +
  7988. this.renderScripts(context) +
  7989. template.tail(context)
  7990. )
  7991. } else {
  7992. return (
  7993. template.head(context) +
  7994. template.neck(context) +
  7995. content +
  7996. template.tail(context)
  7997. )
  7998. }
  7999. };
  8000. TemplateRenderer.prototype.renderStyles = function renderStyles (context) {
  8001. var this$1 = this;
  8002. var initial = this.preloadFiles || [];
  8003. var async = this.getUsedAsyncFiles(context) || [];
  8004. var cssFiles = initial.concat(async).filter(function (ref) {
  8005. var file = ref.file;
  8006. return isCSS(file);
  8007. });
  8008. return (
  8009. // render links for css files
  8010. (cssFiles.length
  8011. ? cssFiles.map(function (ref) {
  8012. var file = ref.file;
  8013. return ("<link rel=\"stylesheet\" href=\"" + (this$1.publicPath) + file + "\">");
  8014. }).join('')
  8015. : '') +
  8016. // context.styles is a getter exposed by vue-style-loader which contains
  8017. // the inline component styles collected during SSR
  8018. (context.styles || '')
  8019. )
  8020. };
  8021. TemplateRenderer.prototype.renderResourceHints = function renderResourceHints (context) {
  8022. return this.renderPreloadLinks(context) + this.renderPrefetchLinks(context)
  8023. };
  8024. TemplateRenderer.prototype.getPreloadFiles = function getPreloadFiles (context) {
  8025. var usedAsyncFiles = this.getUsedAsyncFiles(context);
  8026. if (this.preloadFiles || usedAsyncFiles) {
  8027. return (this.preloadFiles || []).concat(usedAsyncFiles || [])
  8028. } else {
  8029. return []
  8030. }
  8031. };
  8032. TemplateRenderer.prototype.renderPreloadLinks = function renderPreloadLinks (context) {
  8033. var this$1 = this;
  8034. var files = this.getPreloadFiles(context);
  8035. var shouldPreload = this.options.shouldPreload;
  8036. if (files.length) {
  8037. return files.map(function (ref) {
  8038. var file = ref.file;
  8039. var extension = ref.extension;
  8040. var fileWithoutQuery = ref.fileWithoutQuery;
  8041. var asType = ref.asType;
  8042. var extra = '';
  8043. // by default, we only preload scripts or css
  8044. if (!shouldPreload && asType !== 'script' && asType !== 'style') {
  8045. return ''
  8046. }
  8047. // user wants to explicitly control what to preload
  8048. if (shouldPreload && !shouldPreload(fileWithoutQuery, asType)) {
  8049. return ''
  8050. }
  8051. if (asType === 'font') {
  8052. extra = " type=\"font/" + extension + "\" crossorigin";
  8053. }
  8054. return ("<link rel=\"preload\" href=\"" + (this$1.publicPath) + file + "\"" + (asType !== '' ? (" as=\"" + asType + "\"") : '') + extra + ">")
  8055. }).join('')
  8056. } else {
  8057. return ''
  8058. }
  8059. };
  8060. TemplateRenderer.prototype.renderPrefetchLinks = function renderPrefetchLinks (context) {
  8061. var this$1 = this;
  8062. var shouldPrefetch = this.options.shouldPrefetch;
  8063. if (this.prefetchFiles) {
  8064. var usedAsyncFiles = this.getUsedAsyncFiles(context);
  8065. var alreadyRendered = function (file) {
  8066. return usedAsyncFiles && usedAsyncFiles.some(function (f) { return f.file === file; })
  8067. };
  8068. return this.prefetchFiles.map(function (ref) {
  8069. var file = ref.file;
  8070. var fileWithoutQuery = ref.fileWithoutQuery;
  8071. var asType = ref.asType;
  8072. if (shouldPrefetch && !shouldPrefetch(fileWithoutQuery, asType)) {
  8073. return ''
  8074. }
  8075. if (alreadyRendered(file)) {
  8076. return ''
  8077. }
  8078. return ("<link rel=\"prefetch\" href=\"" + (this$1.publicPath) + file + "\">")
  8079. }).join('')
  8080. } else {
  8081. return ''
  8082. }
  8083. };
  8084. TemplateRenderer.prototype.renderState = function renderState (context, options) {
  8085. var ref = options || {};
  8086. var contextKey = ref.contextKey; if ( contextKey === void 0 ) contextKey = 'state';
  8087. var windowKey = ref.windowKey; if ( windowKey === void 0 ) windowKey = '__INITIAL_STATE__';
  8088. var state = this.serialize(context[contextKey]);
  8089. var autoRemove = '';
  8090. var nonceAttr = context.nonce ? (" nonce=\"" + (context.nonce) + "\"") : '';
  8091. return context[contextKey]
  8092. ? ("<script" + nonceAttr + ">window." + windowKey + "=" + state + autoRemove + "</script>")
  8093. : ''
  8094. };
  8095. TemplateRenderer.prototype.renderScripts = function renderScripts (context) {
  8096. var this$1 = this;
  8097. if (this.clientManifest) {
  8098. var initial = this.preloadFiles.filter(function (ref) {
  8099. var file = ref.file;
  8100. return isJS(file);
  8101. });
  8102. var async = (this.getUsedAsyncFiles(context) || []).filter(function (ref) {
  8103. var file = ref.file;
  8104. return isJS(file);
  8105. });
  8106. var needed = [initial[0]].concat(async, initial.slice(1));
  8107. return needed.map(function (ref) {
  8108. var file = ref.file;
  8109. return ("<script src=\"" + (this$1.publicPath) + file + "\" defer></script>")
  8110. }).join('')
  8111. } else {
  8112. return ''
  8113. }
  8114. };
  8115. TemplateRenderer.prototype.getUsedAsyncFiles = function getUsedAsyncFiles (context) {
  8116. if (!context._mappedFiles && context._registeredComponents && this.mapFiles) {
  8117. var registered = Array.from(context._registeredComponents);
  8118. context._mappedFiles = this.mapFiles(registered).map(normalizeFile);
  8119. }
  8120. return context._mappedFiles
  8121. };
  8122. // create a transform stream
  8123. TemplateRenderer.prototype.createStream = function createStream (context) {
  8124. if (!this.parsedTemplate) {
  8125. throw new Error('createStream cannot be called without a template.')
  8126. }
  8127. return new TemplateStream(this, this.parsedTemplate, context || {})
  8128. };
  8129. function normalizeFile (file) {
  8130. var withoutQuery = file.replace(/\?.*/, '');
  8131. var extension = path.extname(withoutQuery).slice(1);
  8132. return {
  8133. file: file,
  8134. extension: extension,
  8135. fileWithoutQuery: withoutQuery,
  8136. asType: getPreloadType(extension)
  8137. }
  8138. }
  8139. function getPreloadType (ext) {
  8140. if (ext === 'js') {
  8141. return 'script'
  8142. } else if (ext === 'css') {
  8143. return 'style'
  8144. } else if (/jpe?g|png|svg|gif|webp|ico/.test(ext)) {
  8145. return 'image'
  8146. } else if (/woff2?|ttf|otf|eot/.test(ext)) {
  8147. return 'font'
  8148. } else {
  8149. // not exhausting all possibilities here, but above covers common cases
  8150. return ''
  8151. }
  8152. }
  8153. /* */
  8154. function createRenderer (ref) {
  8155. if ( ref === void 0 ) ref = {};
  8156. var modules = ref.modules; if ( modules === void 0 ) modules = [];
  8157. var directives = ref.directives; if ( directives === void 0 ) directives = {};
  8158. var isUnaryTag = ref.isUnaryTag; if ( isUnaryTag === void 0 ) isUnaryTag = (function () { return false; });
  8159. var template = ref.template;
  8160. var inject = ref.inject;
  8161. var cache = ref.cache;
  8162. var shouldPreload = ref.shouldPreload;
  8163. var shouldPrefetch = ref.shouldPrefetch;
  8164. var clientManifest = ref.clientManifest;
  8165. var serializer = ref.serializer;
  8166. var render = createRenderFunction(modules, directives, isUnaryTag, cache);
  8167. var templateRenderer = new TemplateRenderer({
  8168. template: template,
  8169. inject: inject,
  8170. shouldPreload: shouldPreload,
  8171. shouldPrefetch: shouldPrefetch,
  8172. clientManifest: clientManifest,
  8173. serializer: serializer
  8174. });
  8175. return {
  8176. renderToString: function renderToString (
  8177. component,
  8178. context,
  8179. cb
  8180. ) {
  8181. var assign;
  8182. if (typeof context === 'function') {
  8183. cb = context;
  8184. context = {};
  8185. }
  8186. if (context) {
  8187. templateRenderer.bindRenderFns(context);
  8188. }
  8189. // no callback, return Promise
  8190. var promise;
  8191. if (!cb) {
  8192. ((assign = createPromiseCallback(), promise = assign.promise, cb = assign.cb));
  8193. }
  8194. var result = '';
  8195. var write = createWriteFunction(function (text) {
  8196. result += text;
  8197. return false
  8198. }, cb);
  8199. try {
  8200. render(component, write, context, function (err) {
  8201. if (err) {
  8202. return cb(err)
  8203. }
  8204. if (context && context.rendered) {
  8205. context.rendered(context);
  8206. }
  8207. if (template) {
  8208. try {
  8209. var res = templateRenderer.render(result, context);
  8210. if (typeof res !== 'string') {
  8211. // function template returning promise
  8212. res
  8213. .then(function (html) { return cb(null, html); })
  8214. .catch(cb);
  8215. } else {
  8216. cb(null, res);
  8217. }
  8218. } catch (e) {
  8219. cb(e);
  8220. }
  8221. } else {
  8222. cb(null, result);
  8223. }
  8224. });
  8225. } catch (e) {
  8226. cb(e);
  8227. }
  8228. return promise
  8229. },
  8230. renderToStream: function renderToStream (
  8231. component,
  8232. context
  8233. ) {
  8234. if (context) {
  8235. templateRenderer.bindRenderFns(context);
  8236. }
  8237. var renderStream = new RenderStream(function (write, done) {
  8238. render(component, write, context, done);
  8239. });
  8240. if (!template) {
  8241. if (context && context.rendered) {
  8242. var rendered = context.rendered;
  8243. renderStream.once('beforeEnd', function () {
  8244. rendered(context);
  8245. });
  8246. }
  8247. return renderStream
  8248. } else if (typeof template === 'function') {
  8249. throw new Error("function template is only supported in renderToString.")
  8250. } else {
  8251. var templateStream = templateRenderer.createStream(context);
  8252. renderStream.on('error', function (err) {
  8253. templateStream.emit('error', err);
  8254. });
  8255. renderStream.pipe(templateStream);
  8256. if (context && context.rendered) {
  8257. var rendered$1 = context.rendered;
  8258. renderStream.once('beforeEnd', function () {
  8259. rendered$1(context);
  8260. });
  8261. }
  8262. return templateStream
  8263. }
  8264. }
  8265. }
  8266. }
  8267. var vm = require('vm');
  8268. var path$1 = require('path');
  8269. var resolve = require('resolve');
  8270. var NativeModule = require('module');
  8271. function createSandbox (context) {
  8272. var sandbox = {
  8273. Buffer: Buffer,
  8274. console: console,
  8275. process: process,
  8276. setTimeout: setTimeout,
  8277. setInterval: setInterval,
  8278. setImmediate: setImmediate,
  8279. clearTimeout: clearTimeout,
  8280. clearInterval: clearInterval,
  8281. clearImmediate: clearImmediate,
  8282. __VUE_SSR_CONTEXT__: context
  8283. };
  8284. sandbox.global = sandbox;
  8285. return sandbox
  8286. }
  8287. function compileModule (files, basedir, runInNewContext) {
  8288. var compiledScripts = {};
  8289. var resolvedModules = {};
  8290. function getCompiledScript (filename) {
  8291. if (compiledScripts[filename]) {
  8292. return compiledScripts[filename]
  8293. }
  8294. var code = files[filename];
  8295. var wrapper = NativeModule.wrap(code);
  8296. var script = new vm.Script(wrapper, {
  8297. filename: filename,
  8298. displayErrors: true
  8299. });
  8300. compiledScripts[filename] = script;
  8301. return script
  8302. }
  8303. function evaluateModule (filename, sandbox, evaluatedFiles) {
  8304. if ( evaluatedFiles === void 0 ) evaluatedFiles = {};
  8305. if (evaluatedFiles[filename]) {
  8306. return evaluatedFiles[filename]
  8307. }
  8308. var script = getCompiledScript(filename);
  8309. var compiledWrapper = runInNewContext === false
  8310. ? script.runInThisContext()
  8311. : script.runInNewContext(sandbox);
  8312. var m = { exports: {}};
  8313. var r = function (file) {
  8314. file = path$1.posix.join('.', file);
  8315. if (files[file]) {
  8316. return evaluateModule(file, sandbox, evaluatedFiles)
  8317. } else if (basedir) {
  8318. return require(
  8319. resolvedModules[file] ||
  8320. (resolvedModules[file] = resolve.sync(file, { basedir: basedir }))
  8321. )
  8322. } else {
  8323. return require(file)
  8324. }
  8325. };
  8326. compiledWrapper.call(m.exports, m.exports, r, m);
  8327. var res = Object.prototype.hasOwnProperty.call(m.exports, 'default')
  8328. ? m.exports.default
  8329. : m.exports;
  8330. evaluatedFiles[filename] = res;
  8331. return res
  8332. }
  8333. return evaluateModule
  8334. }
  8335. function deepClone (val) {
  8336. if (isPlainObject(val)) {
  8337. var res = {};
  8338. for (var key in val) {
  8339. res[key] = deepClone(val[key]);
  8340. }
  8341. return res
  8342. } else if (Array.isArray(val)) {
  8343. return val.slice()
  8344. } else {
  8345. return val
  8346. }
  8347. }
  8348. function createBundleRunner (entry, files, basedir, runInNewContext) {
  8349. var evaluate = compileModule(files, basedir, runInNewContext);
  8350. if (runInNewContext !== false && runInNewContext !== 'once') {
  8351. // new context mode: creates a fresh context and re-evaluate the bundle
  8352. // on each render. Ensures entire application state is fresh for each
  8353. // render, but incurs extra evaluation cost.
  8354. return function (userContext) {
  8355. if ( userContext === void 0 ) userContext = {};
  8356. return new Promise(function (resolve) {
  8357. userContext._registeredComponents = new Set();
  8358. var res = evaluate(entry, createSandbox(userContext));
  8359. resolve(typeof res === 'function' ? res(userContext) : res);
  8360. });
  8361. }
  8362. } else {
  8363. // direct mode: instead of re-evaluating the whole bundle on
  8364. // each render, it simply calls the exported function. This avoids the
  8365. // module evaluation costs but requires the source code to be structured
  8366. // slightly differently.
  8367. var runner; // lazy creation so that errors can be caught by user
  8368. var initialContext;
  8369. return function (userContext) {
  8370. if ( userContext === void 0 ) userContext = {};
  8371. return new Promise(function (resolve) {
  8372. if (!runner) {
  8373. var sandbox = runInNewContext === 'once'
  8374. ? createSandbox()
  8375. : global;
  8376. // the initial context is only used for collecting possible non-component
  8377. // styles injected by vue-style-loader.
  8378. initialContext = sandbox.__VUE_SSR_CONTEXT__ = {};
  8379. runner = evaluate(entry, sandbox);
  8380. // On subsequent renders, __VUE_SSR_CONTEXT__ will not be available
  8381. // to prevent cross-request pollution.
  8382. delete sandbox.__VUE_SSR_CONTEXT__;
  8383. if (typeof runner !== 'function') {
  8384. throw new Error(
  8385. 'bundle export should be a function when using ' +
  8386. '{ runInNewContext: false }.'
  8387. )
  8388. }
  8389. }
  8390. userContext._registeredComponents = new Set();
  8391. // vue-style-loader styles imported outside of component lifecycle hooks
  8392. if (initialContext._styles) {
  8393. userContext._styles = deepClone(initialContext._styles);
  8394. // #6353 ensure "styles" is exposed even if no styles are injected
  8395. // in component lifecycles.
  8396. // the renderStyles fn is exposed by vue-style-loader >= 3.0.3
  8397. var renderStyles = initialContext._renderStyles;
  8398. if (renderStyles) {
  8399. Object.defineProperty(userContext, 'styles', {
  8400. enumerable: true,
  8401. get: function get () {
  8402. return renderStyles(userContext._styles)
  8403. }
  8404. });
  8405. }
  8406. }
  8407. resolve(runner(userContext));
  8408. });
  8409. }
  8410. }
  8411. }
  8412. /* */
  8413. var SourceMapConsumer = require('source-map').SourceMapConsumer;
  8414. var filenameRE = /\(([^)]+\.js):(\d+):(\d+)\)$/;
  8415. function createSourceMapConsumers (rawMaps) {
  8416. var maps = {};
  8417. Object.keys(rawMaps).forEach(function (file) {
  8418. maps[file] = new SourceMapConsumer(rawMaps[file]);
  8419. });
  8420. return maps
  8421. }
  8422. function rewriteErrorTrace (e, mapConsumers) {
  8423. if (e && typeof e.stack === 'string') {
  8424. e.stack = e.stack.split('\n').map(function (line) {
  8425. return rewriteTraceLine(line, mapConsumers)
  8426. }).join('\n');
  8427. }
  8428. }
  8429. function rewriteTraceLine (trace, mapConsumers) {
  8430. var m = trace.match(filenameRE);
  8431. var map = m && mapConsumers[m[1]];
  8432. if (m != null && map) {
  8433. var originalPosition = map.originalPositionFor({
  8434. line: Number(m[2]),
  8435. column: Number(m[3])
  8436. });
  8437. if (originalPosition.source != null) {
  8438. var source = originalPosition.source;
  8439. var line = originalPosition.line;
  8440. var column = originalPosition.column;
  8441. var mappedPosition = "(" + (source.replace(/^webpack:\/\/\//, '')) + ":" + (String(line)) + ":" + (String(column)) + ")";
  8442. return trace.replace(filenameRE, mappedPosition)
  8443. } else {
  8444. return trace
  8445. }
  8446. } else {
  8447. return trace
  8448. }
  8449. }
  8450. /* */
  8451. var fs = require('fs');
  8452. var path$2 = require('path');
  8453. var PassThrough = require('stream').PassThrough;
  8454. var INVALID_MSG =
  8455. 'Invalid server-rendering bundle format. Should be a string ' +
  8456. 'or a bundle Object of type:\n\n' +
  8457. "{\n entry: string;\n files: { [filename: string]: string; };\n maps: { [filename: string]: string; };\n}\n";
  8458. // The render bundle can either be a string (single bundled file)
  8459. // or a bundle manifest object generated by vue-ssr-webpack-plugin.
  8460. function createBundleRendererCreator (
  8461. createRenderer
  8462. ) {
  8463. return function createBundleRenderer (
  8464. bundle,
  8465. rendererOptions
  8466. ) {
  8467. if ( rendererOptions === void 0 ) rendererOptions = {};
  8468. var files, entry, maps;
  8469. var basedir = rendererOptions.basedir;
  8470. // load bundle if given filepath
  8471. if (
  8472. typeof bundle === 'string' &&
  8473. /\.js(on)?$/.test(bundle) &&
  8474. path$2.isAbsolute(bundle)
  8475. ) {
  8476. if (fs.existsSync(bundle)) {
  8477. var isJSON = /\.json$/.test(bundle);
  8478. basedir = basedir || path$2.dirname(bundle);
  8479. bundle = fs.readFileSync(bundle, 'utf-8');
  8480. if (isJSON) {
  8481. try {
  8482. bundle = JSON.parse(bundle);
  8483. } catch (e) {
  8484. throw new Error(("Invalid JSON bundle file: " + bundle))
  8485. }
  8486. }
  8487. } else {
  8488. throw new Error(("Cannot locate bundle file: " + bundle))
  8489. }
  8490. }
  8491. if (typeof bundle === 'object') {
  8492. entry = bundle.entry;
  8493. files = bundle.files;
  8494. basedir = basedir || bundle.basedir;
  8495. maps = createSourceMapConsumers(bundle.maps);
  8496. if (typeof entry !== 'string' || typeof files !== 'object') {
  8497. throw new Error(INVALID_MSG)
  8498. }
  8499. } else if (typeof bundle === 'string') {
  8500. entry = '__vue_ssr_bundle__';
  8501. files = { '__vue_ssr_bundle__': bundle };
  8502. maps = {};
  8503. } else {
  8504. throw new Error(INVALID_MSG)
  8505. }
  8506. var renderer = createRenderer(rendererOptions);
  8507. var run = createBundleRunner(
  8508. entry,
  8509. files,
  8510. basedir,
  8511. rendererOptions.runInNewContext
  8512. );
  8513. return {
  8514. renderToString: function (context, cb) {
  8515. var assign;
  8516. if (typeof context === 'function') {
  8517. cb = context;
  8518. context = {};
  8519. }
  8520. var promise;
  8521. if (!cb) {
  8522. ((assign = createPromiseCallback(), promise = assign.promise, cb = assign.cb));
  8523. }
  8524. run(context).catch(function (err) {
  8525. rewriteErrorTrace(err, maps);
  8526. cb(err);
  8527. }).then(function (app) {
  8528. if (app) {
  8529. renderer.renderToString(app, context, function (err, res) {
  8530. rewriteErrorTrace(err, maps);
  8531. cb(err, res);
  8532. });
  8533. }
  8534. });
  8535. return promise
  8536. },
  8537. renderToStream: function (context) {
  8538. var res = new PassThrough();
  8539. run(context).catch(function (err) {
  8540. rewriteErrorTrace(err, maps);
  8541. // avoid emitting synchronously before user can
  8542. // attach error listener
  8543. process.nextTick(function () {
  8544. res.emit('error', err);
  8545. });
  8546. }).then(function (app) {
  8547. if (app) {
  8548. var renderStream = renderer.renderToStream(app, context);
  8549. renderStream.on('error', function (err) {
  8550. rewriteErrorTrace(err, maps);
  8551. res.emit('error', err);
  8552. });
  8553. // relay HTMLStream special events
  8554. if (rendererOptions && rendererOptions.template) {
  8555. renderStream.on('beforeStart', function () {
  8556. res.emit('beforeStart');
  8557. });
  8558. renderStream.on('beforeEnd', function () {
  8559. res.emit('beforeEnd');
  8560. });
  8561. }
  8562. renderStream.pipe(res);
  8563. }
  8564. });
  8565. return res
  8566. }
  8567. }
  8568. }
  8569. }
  8570. /* */
  8571. process.env.VUE_ENV = 'server';
  8572. function createRenderer$1 (options) {
  8573. if ( options === void 0 ) options = {};
  8574. return createRenderer(extend(extend({}, options), {
  8575. isUnaryTag: isUnaryTag,
  8576. canBeLeftOpenTag: canBeLeftOpenTag,
  8577. modules: modules,
  8578. // user can provide server-side implementations for custom directives
  8579. // when creating the renderer.
  8580. directives: extend(baseDirectives, options.directives)
  8581. }))
  8582. }
  8583. var createBundleRenderer = createBundleRendererCreator(createRenderer$1);
  8584. exports.createRenderer = createRenderer$1;
  8585. exports.createBundleRenderer = createBundleRenderer;