vue.js 182 KB

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