vue.js 265 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029
  1. /*!
  2. * Vue.js v1.0.24
  3. * (c) 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. function set(obj, key, val) {
  12. if (hasOwn(obj, key)) {
  13. obj[key] = val;
  14. return;
  15. }
  16. if (obj._isVue) {
  17. set(obj._data, key, val);
  18. return;
  19. }
  20. var ob = obj.__ob__;
  21. if (!ob) {
  22. obj[key] = val;
  23. return;
  24. }
  25. ob.convert(key, val);
  26. ob.dep.notify();
  27. if (ob.vms) {
  28. var i = ob.vms.length;
  29. while (i--) {
  30. var vm = ob.vms[i];
  31. vm._proxy(key);
  32. vm._digest();
  33. }
  34. }
  35. return val;
  36. }
  37. /**
  38. * Delete a property and trigger change if necessary.
  39. *
  40. * @param {Object} obj
  41. * @param {String} key
  42. */
  43. function del(obj, key) {
  44. if (!hasOwn(obj, key)) {
  45. return;
  46. }
  47. delete obj[key];
  48. var ob = obj.__ob__;
  49. if (!ob) {
  50. if (obj._isVue) {
  51. delete obj._data[key];
  52. obj._digest();
  53. }
  54. return;
  55. }
  56. ob.dep.notify();
  57. if (ob.vms) {
  58. var i = ob.vms.length;
  59. while (i--) {
  60. var vm = ob.vms[i];
  61. vm._unproxy(key);
  62. vm._digest();
  63. }
  64. }
  65. }
  66. var hasOwnProperty = Object.prototype.hasOwnProperty;
  67. /**
  68. * Check whether the object has the property.
  69. *
  70. * @param {Object} obj
  71. * @param {String} key
  72. * @return {Boolean}
  73. */
  74. function hasOwn(obj, key) {
  75. return hasOwnProperty.call(obj, key);
  76. }
  77. /**
  78. * Check if an expression is a literal value.
  79. *
  80. * @param {String} exp
  81. * @return {Boolean}
  82. */
  83. var literalValueRE = /^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/;
  84. function isLiteral(exp) {
  85. return literalValueRE.test(exp);
  86. }
  87. /**
  88. * Check if a string starts with $ or _
  89. *
  90. * @param {String} str
  91. * @return {Boolean}
  92. */
  93. function isReserved(str) {
  94. var c = (str + '').charCodeAt(0);
  95. return c === 0x24 || c === 0x5F;
  96. }
  97. /**
  98. * Guard text output, make sure undefined outputs
  99. * empty string
  100. *
  101. * @param {*} value
  102. * @return {String}
  103. */
  104. function _toString(value) {
  105. return value == null ? '' : value.toString();
  106. }
  107. /**
  108. * Check and convert possible numeric strings to numbers
  109. * before setting back to data
  110. *
  111. * @param {*} value
  112. * @return {*|Number}
  113. */
  114. function toNumber(value) {
  115. if (typeof value !== 'string') {
  116. return value;
  117. } else {
  118. var parsed = Number(value);
  119. return isNaN(parsed) ? value : parsed;
  120. }
  121. }
  122. /**
  123. * Convert string boolean literals into real booleans.
  124. *
  125. * @param {*} value
  126. * @return {*|Boolean}
  127. */
  128. function toBoolean(value) {
  129. return value === 'true' ? true : value === 'false' ? false : value;
  130. }
  131. /**
  132. * Strip quotes from a string
  133. *
  134. * @param {String} str
  135. * @return {String | false}
  136. */
  137. function stripQuotes(str) {
  138. var a = str.charCodeAt(0);
  139. var b = str.charCodeAt(str.length - 1);
  140. return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str;
  141. }
  142. /**
  143. * Camelize a hyphen-delmited string.
  144. *
  145. * @param {String} str
  146. * @return {String}
  147. */
  148. var camelizeRE = /-(\w)/g;
  149. function camelize(str) {
  150. return str.replace(camelizeRE, toUpper);
  151. }
  152. function toUpper(_, c) {
  153. return c ? c.toUpperCase() : '';
  154. }
  155. /**
  156. * Hyphenate a camelCase string.
  157. *
  158. * @param {String} str
  159. * @return {String}
  160. */
  161. var hyphenateRE = /([a-z\d])([A-Z])/g;
  162. function hyphenate(str) {
  163. return str.replace(hyphenateRE, '$1-$2').toLowerCase();
  164. }
  165. /**
  166. * Converts hyphen/underscore/slash delimitered names into
  167. * camelized classNames.
  168. *
  169. * e.g. my-component => MyComponent
  170. * some_else => SomeElse
  171. * some/comp => SomeComp
  172. *
  173. * @param {String} str
  174. * @return {String}
  175. */
  176. var classifyRE = /(?:^|[-_\/])(\w)/g;
  177. function classify(str) {
  178. return str.replace(classifyRE, toUpper);
  179. }
  180. /**
  181. * Simple bind, faster than native
  182. *
  183. * @param {Function} fn
  184. * @param {Object} ctx
  185. * @return {Function}
  186. */
  187. function bind(fn, ctx) {
  188. return function (a) {
  189. var l = arguments.length;
  190. return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
  191. };
  192. }
  193. /**
  194. * Convert an Array-like object to a real Array.
  195. *
  196. * @param {Array-like} list
  197. * @param {Number} [start] - start index
  198. * @return {Array}
  199. */
  200. function toArray(list, start) {
  201. start = start || 0;
  202. var i = list.length - start;
  203. var ret = new Array(i);
  204. while (i--) {
  205. ret[i] = list[i + start];
  206. }
  207. return ret;
  208. }
  209. /**
  210. * Mix properties into target object.
  211. *
  212. * @param {Object} to
  213. * @param {Object} from
  214. */
  215. function extend(to, from) {
  216. var keys = Object.keys(from);
  217. var i = keys.length;
  218. while (i--) {
  219. to[keys[i]] = from[keys[i]];
  220. }
  221. return to;
  222. }
  223. /**
  224. * Quick object check - this is primarily used to tell
  225. * Objects from primitive values when we know the value
  226. * is a JSON-compliant type.
  227. *
  228. * @param {*} obj
  229. * @return {Boolean}
  230. */
  231. function isObject(obj) {
  232. return obj !== null && typeof obj === 'object';
  233. }
  234. /**
  235. * Strict object type check. Only returns true
  236. * for plain JavaScript objects.
  237. *
  238. * @param {*} obj
  239. * @return {Boolean}
  240. */
  241. var toString = Object.prototype.toString;
  242. var OBJECT_STRING = '[object Object]';
  243. function isPlainObject(obj) {
  244. return toString.call(obj) === OBJECT_STRING;
  245. }
  246. /**
  247. * Array type check.
  248. *
  249. * @param {*} obj
  250. * @return {Boolean}
  251. */
  252. var isArray = Array.isArray;
  253. /**
  254. * Define a property.
  255. *
  256. * @param {Object} obj
  257. * @param {String} key
  258. * @param {*} val
  259. * @param {Boolean} [enumerable]
  260. */
  261. function def(obj, key, val, enumerable) {
  262. Object.defineProperty(obj, key, {
  263. value: val,
  264. enumerable: !!enumerable,
  265. writable: true,
  266. configurable: true
  267. });
  268. }
  269. /**
  270. * Debounce a function so it only gets called after the
  271. * input stops arriving after the given wait period.
  272. *
  273. * @param {Function} func
  274. * @param {Number} wait
  275. * @return {Function} - the debounced function
  276. */
  277. function _debounce(func, wait) {
  278. var timeout, args, context, timestamp, result;
  279. var later = function later() {
  280. var last = Date.now() - timestamp;
  281. if (last < wait && last >= 0) {
  282. timeout = setTimeout(later, wait - last);
  283. } else {
  284. timeout = null;
  285. result = func.apply(context, args);
  286. if (!timeout) context = args = null;
  287. }
  288. };
  289. return function () {
  290. context = this;
  291. args = arguments;
  292. timestamp = Date.now();
  293. if (!timeout) {
  294. timeout = setTimeout(later, wait);
  295. }
  296. return result;
  297. };
  298. }
  299. /**
  300. * Manual indexOf because it's slightly faster than
  301. * native.
  302. *
  303. * @param {Array} arr
  304. * @param {*} obj
  305. */
  306. function indexOf(arr, obj) {
  307. var i = arr.length;
  308. while (i--) {
  309. if (arr[i] === obj) return i;
  310. }
  311. return -1;
  312. }
  313. /**
  314. * Make a cancellable version of an async callback.
  315. *
  316. * @param {Function} fn
  317. * @return {Function}
  318. */
  319. function cancellable(fn) {
  320. var cb = function cb() {
  321. if (!cb.cancelled) {
  322. return fn.apply(this, arguments);
  323. }
  324. };
  325. cb.cancel = function () {
  326. cb.cancelled = true;
  327. };
  328. return cb;
  329. }
  330. /**
  331. * Check if two values are loosely equal - that is,
  332. * if they are plain objects, do they have the same shape?
  333. *
  334. * @param {*} a
  335. * @param {*} b
  336. * @return {Boolean}
  337. */
  338. function looseEqual(a, b) {
  339. /* eslint-disable eqeqeq */
  340. return a == b || (isObject(a) && isObject(b) ? JSON.stringify(a) === JSON.stringify(b) : false);
  341. /* eslint-enable eqeqeq */
  342. }
  343. var hasProto = ('__proto__' in {});
  344. // Browser environment sniffing
  345. var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) !== '[object Object]';
  346. // detect devtools
  347. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  348. // UA sniffing for working around browser-specific quirks
  349. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  350. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  351. var isAndroid = UA && UA.indexOf('android') > 0;
  352. var isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA);
  353. var isWechat = UA && UA.indexOf('micromessenger') > 0;
  354. var transitionProp = undefined;
  355. var transitionEndEvent = undefined;
  356. var animationProp = undefined;
  357. var animationEndEvent = undefined;
  358. // Transition property/event sniffing
  359. if (inBrowser && !isIE9) {
  360. var isWebkitTrans = window.ontransitionend === undefined && window.onwebkittransitionend !== undefined;
  361. var isWebkitAnim = window.onanimationend === undefined && window.onwebkitanimationend !== undefined;
  362. transitionProp = isWebkitTrans ? 'WebkitTransition' : 'transition';
  363. transitionEndEvent = isWebkitTrans ? 'webkitTransitionEnd' : 'transitionend';
  364. animationProp = isWebkitAnim ? 'WebkitAnimation' : 'animation';
  365. animationEndEvent = isWebkitAnim ? 'webkitAnimationEnd' : 'animationend';
  366. }
  367. /**
  368. * Defer a task to execute it asynchronously. Ideally this
  369. * should be executed as a microtask, so we leverage
  370. * MutationObserver if it's available, and fallback to
  371. * setTimeout(0).
  372. *
  373. * @param {Function} cb
  374. * @param {Object} ctx
  375. */
  376. var nextTick = (function () {
  377. var callbacks = [];
  378. var pending = false;
  379. var timerFunc;
  380. function nextTickHandler() {
  381. pending = false;
  382. var copies = callbacks.slice(0);
  383. callbacks = [];
  384. for (var i = 0; i < copies.length; i++) {
  385. copies[i]();
  386. }
  387. }
  388. /* istanbul ignore if */
  389. if (typeof MutationObserver !== 'undefined' && !(isWechat && isIos)) {
  390. var counter = 1;
  391. var observer = new MutationObserver(nextTickHandler);
  392. var textNode = document.createTextNode(counter);
  393. observer.observe(textNode, {
  394. characterData: true
  395. });
  396. timerFunc = function () {
  397. counter = (counter + 1) % 2;
  398. textNode.data = counter;
  399. };
  400. } else {
  401. // webpack attempts to inject a shim for setImmediate
  402. // if it is used as a global, so we have to work around that to
  403. // avoid bundling unnecessary code.
  404. var context = inBrowser ? window : typeof global !== 'undefined' ? global : {};
  405. timerFunc = context.setImmediate || setTimeout;
  406. }
  407. return function (cb, ctx) {
  408. var func = ctx ? function () {
  409. cb.call(ctx);
  410. } : cb;
  411. callbacks.push(func);
  412. if (pending) return;
  413. pending = true;
  414. timerFunc(nextTickHandler, 0);
  415. };
  416. })();
  417. var _Set = undefined;
  418. /* istanbul ignore if */
  419. if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) {
  420. // use native Set when available.
  421. _Set = Set;
  422. } else {
  423. // a non-standard Set polyfill that only works with primitive keys.
  424. _Set = function () {
  425. this.set = Object.create(null);
  426. };
  427. _Set.prototype.has = function (key) {
  428. return this.set[key] !== undefined;
  429. };
  430. _Set.prototype.add = function (key) {
  431. this.set[key] = 1;
  432. };
  433. _Set.prototype.clear = function () {
  434. this.set = Object.create(null);
  435. };
  436. }
  437. function Cache(limit) {
  438. this.size = 0;
  439. this.limit = limit;
  440. this.head = this.tail = undefined;
  441. this._keymap = Object.create(null);
  442. }
  443. var p = Cache.prototype;
  444. /**
  445. * Put <value> into the cache associated with <key>.
  446. * Returns the entry which was removed to make room for
  447. * the new entry. Otherwise undefined is returned.
  448. * (i.e. if there was enough room already).
  449. *
  450. * @param {String} key
  451. * @param {*} value
  452. * @return {Entry|undefined}
  453. */
  454. p.put = function (key, value) {
  455. var removed;
  456. if (this.size === this.limit) {
  457. removed = this.shift();
  458. }
  459. var entry = this.get(key, true);
  460. if (!entry) {
  461. entry = {
  462. key: key
  463. };
  464. this._keymap[key] = entry;
  465. if (this.tail) {
  466. this.tail.newer = entry;
  467. entry.older = this.tail;
  468. } else {
  469. this.head = entry;
  470. }
  471. this.tail = entry;
  472. this.size++;
  473. }
  474. entry.value = value;
  475. return removed;
  476. };
  477. /**
  478. * Purge the least recently used (oldest) entry from the
  479. * cache. Returns the removed entry or undefined if the
  480. * cache was empty.
  481. */
  482. p.shift = function () {
  483. var entry = this.head;
  484. if (entry) {
  485. this.head = this.head.newer;
  486. this.head.older = undefined;
  487. entry.newer = entry.older = undefined;
  488. this._keymap[entry.key] = undefined;
  489. this.size--;
  490. }
  491. return entry;
  492. };
  493. /**
  494. * Get and register recent use of <key>. Returns the value
  495. * associated with <key> or undefined if not in cache.
  496. *
  497. * @param {String} key
  498. * @param {Boolean} returnEntry
  499. * @return {Entry|*}
  500. */
  501. p.get = function (key, returnEntry) {
  502. var entry = this._keymap[key];
  503. if (entry === undefined) return;
  504. if (entry === this.tail) {
  505. return returnEntry ? entry : entry.value;
  506. }
  507. // HEAD--------------TAIL
  508. // <.older .newer>
  509. // <--- add direction --
  510. // A B C <D> E
  511. if (entry.newer) {
  512. if (entry === this.head) {
  513. this.head = entry.newer;
  514. }
  515. entry.newer.older = entry.older; // C <-- E.
  516. }
  517. if (entry.older) {
  518. entry.older.newer = entry.newer; // C. --> E
  519. }
  520. entry.newer = undefined; // D --x
  521. entry.older = this.tail; // D. --> E
  522. if (this.tail) {
  523. this.tail.newer = entry; // E. <-- D
  524. }
  525. this.tail = entry;
  526. return returnEntry ? entry : entry.value;
  527. };
  528. var cache$1 = new Cache(1000);
  529. var filterTokenRE = /[^\s'"]+|'[^']*'|"[^"]*"/g;
  530. var reservedArgRE = /^in$|^-?\d+/;
  531. /**
  532. * Parser state
  533. */
  534. var str;
  535. var dir;
  536. var c;
  537. var prev;
  538. var i;
  539. var l;
  540. var lastFilterIndex;
  541. var inSingle;
  542. var inDouble;
  543. var curly;
  544. var square;
  545. var paren;
  546. /**
  547. * Push a filter to the current directive object
  548. */
  549. function pushFilter() {
  550. var exp = str.slice(lastFilterIndex, i).trim();
  551. var filter;
  552. if (exp) {
  553. filter = {};
  554. var tokens = exp.match(filterTokenRE);
  555. filter.name = tokens[0];
  556. if (tokens.length > 1) {
  557. filter.args = tokens.slice(1).map(processFilterArg);
  558. }
  559. }
  560. if (filter) {
  561. (dir.filters = dir.filters || []).push(filter);
  562. }
  563. lastFilterIndex = i + 1;
  564. }
  565. /**
  566. * Check if an argument is dynamic and strip quotes.
  567. *
  568. * @param {String} arg
  569. * @return {Object}
  570. */
  571. function processFilterArg(arg) {
  572. if (reservedArgRE.test(arg)) {
  573. return {
  574. value: toNumber(arg),
  575. dynamic: false
  576. };
  577. } else {
  578. var stripped = stripQuotes(arg);
  579. var dynamic = stripped === arg;
  580. return {
  581. value: dynamic ? arg : stripped,
  582. dynamic: dynamic
  583. };
  584. }
  585. }
  586. /**
  587. * Parse a directive value and extract the expression
  588. * and its filters into a descriptor.
  589. *
  590. * Example:
  591. *
  592. * "a + 1 | uppercase" will yield:
  593. * {
  594. * expression: 'a + 1',
  595. * filters: [
  596. * { name: 'uppercase', args: null }
  597. * ]
  598. * }
  599. *
  600. * @param {String} s
  601. * @return {Object}
  602. */
  603. function parseDirective(s) {
  604. var hit = cache$1.get(s);
  605. if (hit) {
  606. return hit;
  607. }
  608. // reset parser state
  609. str = s;
  610. inSingle = inDouble = false;
  611. curly = square = paren = 0;
  612. lastFilterIndex = 0;
  613. dir = {};
  614. for (i = 0, l = str.length; i < l; i++) {
  615. prev = c;
  616. c = str.charCodeAt(i);
  617. if (inSingle) {
  618. // check single quote
  619. if (c === 0x27 && prev !== 0x5C) inSingle = !inSingle;
  620. } else if (inDouble) {
  621. // check double quote
  622. if (c === 0x22 && prev !== 0x5C) inDouble = !inDouble;
  623. } else if (c === 0x7C && // pipe
  624. str.charCodeAt(i + 1) !== 0x7C && str.charCodeAt(i - 1) !== 0x7C) {
  625. if (dir.expression == null) {
  626. // first filter, end of expression
  627. lastFilterIndex = i + 1;
  628. dir.expression = str.slice(0, i).trim();
  629. } else {
  630. // already has filter
  631. pushFilter();
  632. }
  633. } else {
  634. switch (c) {
  635. case 0x22:
  636. inDouble = true;break; // "
  637. case 0x27:
  638. inSingle = true;break; // '
  639. case 0x28:
  640. paren++;break; // (
  641. case 0x29:
  642. paren--;break; // )
  643. case 0x5B:
  644. square++;break; // [
  645. case 0x5D:
  646. square--;break; // ]
  647. case 0x7B:
  648. curly++;break; // {
  649. case 0x7D:
  650. curly--;break; // }
  651. }
  652. }
  653. }
  654. if (dir.expression == null) {
  655. dir.expression = str.slice(0, i).trim();
  656. } else if (lastFilterIndex !== 0) {
  657. pushFilter();
  658. }
  659. cache$1.put(s, dir);
  660. return dir;
  661. }
  662. var directive = Object.freeze({
  663. parseDirective: parseDirective
  664. });
  665. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  666. var cache = undefined;
  667. var tagRE = undefined;
  668. var htmlRE = undefined;
  669. /**
  670. * Escape a string so it can be used in a RegExp
  671. * constructor.
  672. *
  673. * @param {String} str
  674. */
  675. function escapeRegex(str) {
  676. return str.replace(regexEscapeRE, '\\$&');
  677. }
  678. function compileRegex() {
  679. var open = escapeRegex(config.delimiters[0]);
  680. var close = escapeRegex(config.delimiters[1]);
  681. var unsafeOpen = escapeRegex(config.unsafeDelimiters[0]);
  682. var unsafeClose = escapeRegex(config.unsafeDelimiters[1]);
  683. tagRE = new RegExp(unsafeOpen + '((?:.|\\n)+?)' + unsafeClose + '|' + open + '((?:.|\\n)+?)' + close, 'g');
  684. htmlRE = new RegExp('^' + unsafeOpen + '.*' + unsafeClose + '$');
  685. // reset cache
  686. cache = new Cache(1000);
  687. }
  688. /**
  689. * Parse a template text string into an array of tokens.
  690. *
  691. * @param {String} text
  692. * @return {Array<Object> | null}
  693. * - {String} type
  694. * - {String} value
  695. * - {Boolean} [html]
  696. * - {Boolean} [oneTime]
  697. */
  698. function parseText(text) {
  699. if (!cache) {
  700. compileRegex();
  701. }
  702. var hit = cache.get(text);
  703. if (hit) {
  704. return hit;
  705. }
  706. if (!tagRE.test(text)) {
  707. return null;
  708. }
  709. var tokens = [];
  710. var lastIndex = tagRE.lastIndex = 0;
  711. var match, index, html, value, first, oneTime;
  712. /* eslint-disable no-cond-assign */
  713. while (match = tagRE.exec(text)) {
  714. /* eslint-enable no-cond-assign */
  715. index = match.index;
  716. // push text token
  717. if (index > lastIndex) {
  718. tokens.push({
  719. value: text.slice(lastIndex, index)
  720. });
  721. }
  722. // tag token
  723. html = htmlRE.test(match[0]);
  724. value = html ? match[1] : match[2];
  725. first = value.charCodeAt(0);
  726. oneTime = first === 42; // *
  727. value = oneTime ? value.slice(1) : value;
  728. tokens.push({
  729. tag: true,
  730. value: value.trim(),
  731. html: html,
  732. oneTime: oneTime
  733. });
  734. lastIndex = index + match[0].length;
  735. }
  736. if (lastIndex < text.length) {
  737. tokens.push({
  738. value: text.slice(lastIndex)
  739. });
  740. }
  741. cache.put(text, tokens);
  742. return tokens;
  743. }
  744. /**
  745. * Format a list of tokens into an expression.
  746. * e.g. tokens parsed from 'a {{b}} c' can be serialized
  747. * into one single expression as '"a " + b + " c"'.
  748. *
  749. * @param {Array} tokens
  750. * @param {Vue} [vm]
  751. * @return {String}
  752. */
  753. function tokensToExp(tokens, vm) {
  754. if (tokens.length > 1) {
  755. return tokens.map(function (token) {
  756. return formatToken(token, vm);
  757. }).join('+');
  758. } else {
  759. return formatToken(tokens[0], vm, true);
  760. }
  761. }
  762. /**
  763. * Format a single token.
  764. *
  765. * @param {Object} token
  766. * @param {Vue} [vm]
  767. * @param {Boolean} [single]
  768. * @return {String}
  769. */
  770. function formatToken(token, vm, single) {
  771. return token.tag ? token.oneTime && vm ? '"' + vm.$eval(token.value) + '"' : inlineFilters(token.value, single) : '"' + token.value + '"';
  772. }
  773. /**
  774. * For an attribute with multiple interpolation tags,
  775. * e.g. attr="some-{{thing | filter}}", in order to combine
  776. * the whole thing into a single watchable expression, we
  777. * have to inline those filters. This function does exactly
  778. * that. This is a bit hacky but it avoids heavy changes
  779. * to directive parser and watcher mechanism.
  780. *
  781. * @param {String} exp
  782. * @param {Boolean} single
  783. * @return {String}
  784. */
  785. var filterRE = /[^|]\|[^|]/;
  786. function inlineFilters(exp, single) {
  787. if (!filterRE.test(exp)) {
  788. return single ? exp : '(' + exp + ')';
  789. } else {
  790. var dir = parseDirective(exp);
  791. if (!dir.filters) {
  792. return '(' + exp + ')';
  793. } else {
  794. return 'this._applyFilters(' + dir.expression + // value
  795. ',null,' + // oldValue (null for read)
  796. JSON.stringify(dir.filters) + // filter descriptors
  797. ',false)'; // write?
  798. }
  799. }
  800. }
  801. var text = Object.freeze({
  802. compileRegex: compileRegex,
  803. parseText: parseText,
  804. tokensToExp: tokensToExp
  805. });
  806. var delimiters = ['{{', '}}'];
  807. var unsafeDelimiters = ['{{{', '}}}'];
  808. var config = Object.defineProperties({
  809. /**
  810. * Whether to print debug messages.
  811. * Also enables stack trace for warnings.
  812. *
  813. * @type {Boolean}
  814. */
  815. debug: false,
  816. /**
  817. * Whether to suppress warnings.
  818. *
  819. * @type {Boolean}
  820. */
  821. silent: false,
  822. /**
  823. * Whether to use async rendering.
  824. */
  825. async: true,
  826. /**
  827. * Whether to warn against errors caught when evaluating
  828. * expressions.
  829. */
  830. warnExpressionErrors: true,
  831. /**
  832. * Whether to allow devtools inspection.
  833. * Disabled by default in production builds.
  834. */
  835. devtools: 'development' !== 'production',
  836. /**
  837. * Internal flag to indicate the delimiters have been
  838. * changed.
  839. *
  840. * @type {Boolean}
  841. */
  842. _delimitersChanged: true,
  843. /**
  844. * List of asset types that a component can own.
  845. *
  846. * @type {Array}
  847. */
  848. _assetTypes: ['component', 'directive', 'elementDirective', 'filter', 'transition', 'partial'],
  849. /**
  850. * prop binding modes
  851. */
  852. _propBindingModes: {
  853. ONE_WAY: 0,
  854. TWO_WAY: 1,
  855. ONE_TIME: 2
  856. },
  857. /**
  858. * Max circular updates allowed in a batcher flush cycle.
  859. */
  860. _maxUpdateCount: 100
  861. }, {
  862. delimiters: { /**
  863. * Interpolation delimiters. Changing these would trigger
  864. * the text parser to re-compile the regular expressions.
  865. *
  866. * @type {Array<String>}
  867. */
  868. get: function get() {
  869. return delimiters;
  870. },
  871. set: function set(val) {
  872. delimiters = val;
  873. compileRegex();
  874. },
  875. configurable: true,
  876. enumerable: true
  877. },
  878. unsafeDelimiters: {
  879. get: function get() {
  880. return unsafeDelimiters;
  881. },
  882. set: function set(val) {
  883. unsafeDelimiters = val;
  884. compileRegex();
  885. },
  886. configurable: true,
  887. enumerable: true
  888. }
  889. });
  890. var warn = undefined;
  891. var formatComponentName = undefined;
  892. if ('development' !== 'production') {
  893. (function () {
  894. var hasConsole = typeof console !== 'undefined';
  895. warn = function (msg, vm) {
  896. if (hasConsole && !config.silent) {
  897. console.error('[Vue warn]: ' + msg + (vm ? formatComponentName(vm) : ''));
  898. }
  899. };
  900. formatComponentName = function (vm) {
  901. var name = vm._isVue ? vm.$options.name : vm.name;
  902. return name ? ' (found in component: <' + hyphenate(name) + '>)' : '';
  903. };
  904. })();
  905. }
  906. /**
  907. * Append with transition.
  908. *
  909. * @param {Element} el
  910. * @param {Element} target
  911. * @param {Vue} vm
  912. * @param {Function} [cb]
  913. */
  914. function appendWithTransition(el, target, vm, cb) {
  915. applyTransition(el, 1, function () {
  916. target.appendChild(el);
  917. }, vm, cb);
  918. }
  919. /**
  920. * InsertBefore with transition.
  921. *
  922. * @param {Element} el
  923. * @param {Element} target
  924. * @param {Vue} vm
  925. * @param {Function} [cb]
  926. */
  927. function beforeWithTransition(el, target, vm, cb) {
  928. applyTransition(el, 1, function () {
  929. before(el, target);
  930. }, vm, cb);
  931. }
  932. /**
  933. * Remove with transition.
  934. *
  935. * @param {Element} el
  936. * @param {Vue} vm
  937. * @param {Function} [cb]
  938. */
  939. function removeWithTransition(el, vm, cb) {
  940. applyTransition(el, -1, function () {
  941. remove(el);
  942. }, vm, cb);
  943. }
  944. /**
  945. * Apply transitions with an operation callback.
  946. *
  947. * @param {Element} el
  948. * @param {Number} direction
  949. * 1: enter
  950. * -1: leave
  951. * @param {Function} op - the actual DOM operation
  952. * @param {Vue} vm
  953. * @param {Function} [cb]
  954. */
  955. function applyTransition(el, direction, op, vm, cb) {
  956. var transition = el.__v_trans;
  957. if (!transition ||
  958. // skip if there are no js hooks and CSS transition is
  959. // not supported
  960. !transition.hooks && !transitionEndEvent ||
  961. // skip transitions for initial compile
  962. !vm._isCompiled ||
  963. // if the vm is being manipulated by a parent directive
  964. // during the parent's compilation phase, skip the
  965. // animation.
  966. vm.$parent && !vm.$parent._isCompiled) {
  967. op();
  968. if (cb) cb();
  969. return;
  970. }
  971. var action = direction > 0 ? 'enter' : 'leave';
  972. transition[action](op, cb);
  973. }
  974. var transition = Object.freeze({
  975. appendWithTransition: appendWithTransition,
  976. beforeWithTransition: beforeWithTransition,
  977. removeWithTransition: removeWithTransition,
  978. applyTransition: applyTransition
  979. });
  980. /**
  981. * Query an element selector if it's not an element already.
  982. *
  983. * @param {String|Element} el
  984. * @return {Element}
  985. */
  986. function query(el) {
  987. if (typeof el === 'string') {
  988. var selector = el;
  989. el = document.querySelector(el);
  990. if (!el) {
  991. 'development' !== 'production' && warn('Cannot find element: ' + selector);
  992. }
  993. }
  994. return el;
  995. }
  996. /**
  997. * Check if a node is in the document.
  998. * Note: document.documentElement.contains should work here
  999. * but always returns false for comment nodes in phantomjs,
  1000. * making unit tests difficult. This is fixed by doing the
  1001. * contains() check on the node's parentNode instead of
  1002. * the node itself.
  1003. *
  1004. * @param {Node} node
  1005. * @return {Boolean}
  1006. */
  1007. function inDoc(node) {
  1008. if (!node) return false;
  1009. var doc = node.ownerDocument.documentElement;
  1010. var parent = node.parentNode;
  1011. return doc === node || doc === parent || !!(parent && parent.nodeType === 1 && doc.contains(parent));
  1012. }
  1013. /**
  1014. * Get and remove an attribute from a node.
  1015. *
  1016. * @param {Node} node
  1017. * @param {String} _attr
  1018. */
  1019. function getAttr(node, _attr) {
  1020. var val = node.getAttribute(_attr);
  1021. if (val !== null) {
  1022. node.removeAttribute(_attr);
  1023. }
  1024. return val;
  1025. }
  1026. /**
  1027. * Get an attribute with colon or v-bind: prefix.
  1028. *
  1029. * @param {Node} node
  1030. * @param {String} name
  1031. * @return {String|null}
  1032. */
  1033. function getBindAttr(node, name) {
  1034. var val = getAttr(node, ':' + name);
  1035. if (val === null) {
  1036. val = getAttr(node, 'v-bind:' + name);
  1037. }
  1038. return val;
  1039. }
  1040. /**
  1041. * Check the presence of a bind attribute.
  1042. *
  1043. * @param {Node} node
  1044. * @param {String} name
  1045. * @return {Boolean}
  1046. */
  1047. function hasBindAttr(node, name) {
  1048. return node.hasAttribute(name) || node.hasAttribute(':' + name) || node.hasAttribute('v-bind:' + name);
  1049. }
  1050. /**
  1051. * Insert el before target
  1052. *
  1053. * @param {Element} el
  1054. * @param {Element} target
  1055. */
  1056. function before(el, target) {
  1057. target.parentNode.insertBefore(el, target);
  1058. }
  1059. /**
  1060. * Insert el after target
  1061. *
  1062. * @param {Element} el
  1063. * @param {Element} target
  1064. */
  1065. function after(el, target) {
  1066. if (target.nextSibling) {
  1067. before(el, target.nextSibling);
  1068. } else {
  1069. target.parentNode.appendChild(el);
  1070. }
  1071. }
  1072. /**
  1073. * Remove el from DOM
  1074. *
  1075. * @param {Element} el
  1076. */
  1077. function remove(el) {
  1078. el.parentNode.removeChild(el);
  1079. }
  1080. /**
  1081. * Prepend el to target
  1082. *
  1083. * @param {Element} el
  1084. * @param {Element} target
  1085. */
  1086. function prepend(el, target) {
  1087. if (target.firstChild) {
  1088. before(el, target.firstChild);
  1089. } else {
  1090. target.appendChild(el);
  1091. }
  1092. }
  1093. /**
  1094. * Replace target with el
  1095. *
  1096. * @param {Element} target
  1097. * @param {Element} el
  1098. */
  1099. function replace(target, el) {
  1100. var parent = target.parentNode;
  1101. if (parent) {
  1102. parent.replaceChild(el, target);
  1103. }
  1104. }
  1105. /**
  1106. * Add event listener shorthand.
  1107. *
  1108. * @param {Element} el
  1109. * @param {String} event
  1110. * @param {Function} cb
  1111. * @param {Boolean} [useCapture]
  1112. */
  1113. function on(el, event, cb, useCapture) {
  1114. el.addEventListener(event, cb, useCapture);
  1115. }
  1116. /**
  1117. * Remove event listener shorthand.
  1118. *
  1119. * @param {Element} el
  1120. * @param {String} event
  1121. * @param {Function} cb
  1122. */
  1123. function off(el, event, cb) {
  1124. el.removeEventListener(event, cb);
  1125. }
  1126. /**
  1127. * For IE9 compat: when both class and :class are present
  1128. * getAttribute('class') returns wrong value...
  1129. *
  1130. * @param {Element} el
  1131. * @return {String}
  1132. */
  1133. function getClass(el) {
  1134. var classname = el.className;
  1135. if (typeof classname === 'object') {
  1136. classname = classname.baseVal || '';
  1137. }
  1138. return classname;
  1139. }
  1140. /**
  1141. * In IE9, setAttribute('class') will result in empty class
  1142. * if the element also has the :class attribute; However in
  1143. * PhantomJS, setting `className` does not work on SVG elements...
  1144. * So we have to do a conditional check here.
  1145. *
  1146. * @param {Element} el
  1147. * @param {String} cls
  1148. */
  1149. function setClass(el, cls) {
  1150. /* istanbul ignore if */
  1151. if (isIE9 && !/svg$/.test(el.namespaceURI)) {
  1152. el.className = cls;
  1153. } else {
  1154. el.setAttribute('class', cls);
  1155. }
  1156. }
  1157. /**
  1158. * Add class with compatibility for IE & SVG
  1159. *
  1160. * @param {Element} el
  1161. * @param {String} cls
  1162. */
  1163. function addClass(el, cls) {
  1164. if (el.classList) {
  1165. el.classList.add(cls);
  1166. } else {
  1167. var cur = ' ' + getClass(el) + ' ';
  1168. if (cur.indexOf(' ' + cls + ' ') < 0) {
  1169. setClass(el, (cur + cls).trim());
  1170. }
  1171. }
  1172. }
  1173. /**
  1174. * Remove class with compatibility for IE & SVG
  1175. *
  1176. * @param {Element} el
  1177. * @param {String} cls
  1178. */
  1179. function removeClass(el, cls) {
  1180. if (el.classList) {
  1181. el.classList.remove(cls);
  1182. } else {
  1183. var cur = ' ' + getClass(el) + ' ';
  1184. var tar = ' ' + cls + ' ';
  1185. while (cur.indexOf(tar) >= 0) {
  1186. cur = cur.replace(tar, ' ');
  1187. }
  1188. setClass(el, cur.trim());
  1189. }
  1190. if (!el.className) {
  1191. el.removeAttribute('class');
  1192. }
  1193. }
  1194. /**
  1195. * Extract raw content inside an element into a temporary
  1196. * container div
  1197. *
  1198. * @param {Element} el
  1199. * @param {Boolean} asFragment
  1200. * @return {Element|DocumentFragment}
  1201. */
  1202. function extractContent(el, asFragment) {
  1203. var child;
  1204. var rawContent;
  1205. /* istanbul ignore if */
  1206. if (isTemplate(el) && isFragment(el.content)) {
  1207. el = el.content;
  1208. }
  1209. if (el.hasChildNodes()) {
  1210. trimNode(el);
  1211. rawContent = asFragment ? document.createDocumentFragment() : document.createElement('div');
  1212. /* eslint-disable no-cond-assign */
  1213. while (child = el.firstChild) {
  1214. /* eslint-enable no-cond-assign */
  1215. rawContent.appendChild(child);
  1216. }
  1217. }
  1218. return rawContent;
  1219. }
  1220. /**
  1221. * Trim possible empty head/tail text and comment
  1222. * nodes inside a parent.
  1223. *
  1224. * @param {Node} node
  1225. */
  1226. function trimNode(node) {
  1227. var child;
  1228. /* eslint-disable no-sequences */
  1229. while ((child = node.firstChild, isTrimmable(child))) {
  1230. node.removeChild(child);
  1231. }
  1232. while ((child = node.lastChild, isTrimmable(child))) {
  1233. node.removeChild(child);
  1234. }
  1235. /* eslint-enable no-sequences */
  1236. }
  1237. function isTrimmable(node) {
  1238. return node && (node.nodeType === 3 && !node.data.trim() || node.nodeType === 8);
  1239. }
  1240. /**
  1241. * Check if an element is a template tag.
  1242. * Note if the template appears inside an SVG its tagName
  1243. * will be in lowercase.
  1244. *
  1245. * @param {Element} el
  1246. */
  1247. function isTemplate(el) {
  1248. return el.tagName && el.tagName.toLowerCase() === 'template';
  1249. }
  1250. /**
  1251. * Create an "anchor" for performing dom insertion/removals.
  1252. * This is used in a number of scenarios:
  1253. * - fragment instance
  1254. * - v-html
  1255. * - v-if
  1256. * - v-for
  1257. * - component
  1258. *
  1259. * @param {String} content
  1260. * @param {Boolean} persist - IE trashes empty textNodes on
  1261. * cloneNode(true), so in certain
  1262. * cases the anchor needs to be
  1263. * non-empty to be persisted in
  1264. * templates.
  1265. * @return {Comment|Text}
  1266. */
  1267. function createAnchor(content, persist) {
  1268. var anchor = config.debug ? document.createComment(content) : document.createTextNode(persist ? ' ' : '');
  1269. anchor.__v_anchor = true;
  1270. return anchor;
  1271. }
  1272. /**
  1273. * Find a component ref attribute that starts with $.
  1274. *
  1275. * @param {Element} node
  1276. * @return {String|undefined}
  1277. */
  1278. var refRE = /^v-ref:/;
  1279. function findRef(node) {
  1280. if (node.hasAttributes()) {
  1281. var attrs = node.attributes;
  1282. for (var i = 0, l = attrs.length; i < l; i++) {
  1283. var name = attrs[i].name;
  1284. if (refRE.test(name)) {
  1285. return camelize(name.replace(refRE, ''));
  1286. }
  1287. }
  1288. }
  1289. }
  1290. /**
  1291. * Map a function to a range of nodes .
  1292. *
  1293. * @param {Node} node
  1294. * @param {Node} end
  1295. * @param {Function} op
  1296. */
  1297. function mapNodeRange(node, end, op) {
  1298. var next;
  1299. while (node !== end) {
  1300. next = node.nextSibling;
  1301. op(node);
  1302. node = next;
  1303. }
  1304. op(end);
  1305. }
  1306. /**
  1307. * Remove a range of nodes with transition, store
  1308. * the nodes in a fragment with correct ordering,
  1309. * and call callback when done.
  1310. *
  1311. * @param {Node} start
  1312. * @param {Node} end
  1313. * @param {Vue} vm
  1314. * @param {DocumentFragment} frag
  1315. * @param {Function} cb
  1316. */
  1317. function removeNodeRange(start, end, vm, frag, cb) {
  1318. var done = false;
  1319. var removed = 0;
  1320. var nodes = [];
  1321. mapNodeRange(start, end, function (node) {
  1322. if (node === end) done = true;
  1323. nodes.push(node);
  1324. removeWithTransition(node, vm, onRemoved);
  1325. });
  1326. function onRemoved() {
  1327. removed++;
  1328. if (done && removed >= nodes.length) {
  1329. for (var i = 0; i < nodes.length; i++) {
  1330. frag.appendChild(nodes[i]);
  1331. }
  1332. cb && cb();
  1333. }
  1334. }
  1335. }
  1336. /**
  1337. * Check if a node is a DocumentFragment.
  1338. *
  1339. * @param {Node} node
  1340. * @return {Boolean}
  1341. */
  1342. function isFragment(node) {
  1343. return node && node.nodeType === 11;
  1344. }
  1345. /**
  1346. * Get outerHTML of elements, taking care
  1347. * of SVG elements in IE as well.
  1348. *
  1349. * @param {Element} el
  1350. * @return {String}
  1351. */
  1352. function getOuterHTML(el) {
  1353. if (el.outerHTML) {
  1354. return el.outerHTML;
  1355. } else {
  1356. var container = document.createElement('div');
  1357. container.appendChild(el.cloneNode(true));
  1358. return container.innerHTML;
  1359. }
  1360. }
  1361. var commonTagRE = /^(div|p|span|img|a|b|i|br|ul|ol|li|h1|h2|h3|h4|h5|h6|code|pre|table|th|td|tr|form|label|input|select|option|nav|article|section|header|footer)$/i;
  1362. var reservedTagRE = /^(slot|partial|component)$/i;
  1363. var isUnknownElement = undefined;
  1364. if ('development' !== 'production') {
  1365. isUnknownElement = function (el, tag) {
  1366. if (tag.indexOf('-') > -1) {
  1367. // http://stackoverflow.com/a/28210364/1070244
  1368. return el.constructor === window.HTMLUnknownElement || el.constructor === window.HTMLElement;
  1369. } else {
  1370. return (/HTMLUnknownElement/.test(el.toString()) &&
  1371. // Chrome returns unknown for several HTML5 elements.
  1372. // https://code.google.com/p/chromium/issues/detail?id=540526
  1373. !/^(data|time|rtc|rb)$/.test(tag)
  1374. );
  1375. }
  1376. };
  1377. }
  1378. /**
  1379. * Check if an element is a component, if yes return its
  1380. * component id.
  1381. *
  1382. * @param {Element} el
  1383. * @param {Object} options
  1384. * @return {Object|undefined}
  1385. */
  1386. function checkComponentAttr(el, options) {
  1387. var tag = el.tagName.toLowerCase();
  1388. var hasAttrs = el.hasAttributes();
  1389. if (!commonTagRE.test(tag) && !reservedTagRE.test(tag)) {
  1390. if (resolveAsset(options, 'components', tag)) {
  1391. return { id: tag };
  1392. } else {
  1393. var is = hasAttrs && getIsBinding(el, options);
  1394. if (is) {
  1395. return is;
  1396. } else if ('development' !== 'production') {
  1397. var expectedTag = options._componentNameMap && options._componentNameMap[tag];
  1398. if (expectedTag) {
  1399. warn('Unknown custom element: <' + tag + '> - ' + 'did you mean <' + expectedTag + '>? ' + 'HTML is case-insensitive, remember to use kebab-case in templates.');
  1400. } else if (isUnknownElement(el, tag)) {
  1401. warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
  1402. }
  1403. }
  1404. }
  1405. } else if (hasAttrs) {
  1406. return getIsBinding(el, options);
  1407. }
  1408. }
  1409. /**
  1410. * Get "is" binding from an element.
  1411. *
  1412. * @param {Element} el
  1413. * @param {Object} options
  1414. * @return {Object|undefined}
  1415. */
  1416. function getIsBinding(el, options) {
  1417. // dynamic syntax
  1418. var exp = el.getAttribute('is');
  1419. if (exp != null) {
  1420. if (resolveAsset(options, 'components', exp)) {
  1421. el.removeAttribute('is');
  1422. return { id: exp };
  1423. }
  1424. } else {
  1425. exp = getBindAttr(el, 'is');
  1426. if (exp != null) {
  1427. return { id: exp, dynamic: true };
  1428. }
  1429. }
  1430. }
  1431. /**
  1432. * Option overwriting strategies are functions that handle
  1433. * how to merge a parent option value and a child option
  1434. * value into the final value.
  1435. *
  1436. * All strategy functions follow the same signature:
  1437. *
  1438. * @param {*} parentVal
  1439. * @param {*} childVal
  1440. * @param {Vue} [vm]
  1441. */
  1442. var strats = config.optionMergeStrategies = Object.create(null);
  1443. /**
  1444. * Helper that recursively merges two data objects together.
  1445. */
  1446. function mergeData(to, from) {
  1447. var key, toVal, fromVal;
  1448. for (key in from) {
  1449. toVal = to[key];
  1450. fromVal = from[key];
  1451. if (!hasOwn(to, key)) {
  1452. set(to, key, fromVal);
  1453. } else if (isObject(toVal) && isObject(fromVal)) {
  1454. mergeData(toVal, fromVal);
  1455. }
  1456. }
  1457. return to;
  1458. }
  1459. /**
  1460. * Data
  1461. */
  1462. strats.data = function (parentVal, childVal, vm) {
  1463. if (!vm) {
  1464. // in a Vue.extend merge, both should be functions
  1465. if (!childVal) {
  1466. return parentVal;
  1467. }
  1468. if (typeof childVal !== 'function') {
  1469. 'development' !== 'production' && warn('The "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.', vm);
  1470. return parentVal;
  1471. }
  1472. if (!parentVal) {
  1473. return childVal;
  1474. }
  1475. // when parentVal & childVal are both present,
  1476. // we need to return a function that returns the
  1477. // merged result of both functions... no need to
  1478. // check if parentVal is a function here because
  1479. // it has to be a function to pass previous merges.
  1480. return function mergedDataFn() {
  1481. return mergeData(childVal.call(this), parentVal.call(this));
  1482. };
  1483. } else if (parentVal || childVal) {
  1484. return function mergedInstanceDataFn() {
  1485. // instance merge
  1486. var instanceData = typeof childVal === 'function' ? childVal.call(vm) : childVal;
  1487. var defaultData = typeof parentVal === 'function' ? parentVal.call(vm) : undefined;
  1488. if (instanceData) {
  1489. return mergeData(instanceData, defaultData);
  1490. } else {
  1491. return defaultData;
  1492. }
  1493. };
  1494. }
  1495. };
  1496. /**
  1497. * El
  1498. */
  1499. strats.el = function (parentVal, childVal, vm) {
  1500. if (!vm && childVal && typeof childVal !== 'function') {
  1501. 'development' !== 'production' && warn('The "el" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.', vm);
  1502. return;
  1503. }
  1504. var ret = childVal || parentVal;
  1505. // invoke the element factory if this is instance merge
  1506. return vm && typeof ret === 'function' ? ret.call(vm) : ret;
  1507. };
  1508. /**
  1509. * Hooks and param attributes are merged as arrays.
  1510. */
  1511. strats.init = strats.created = strats.ready = strats.attached = strats.detached = strats.beforeCompile = strats.compiled = strats.beforeDestroy = strats.destroyed = strats.activate = function (parentVal, childVal) {
  1512. return childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal;
  1513. };
  1514. /**
  1515. * Assets
  1516. *
  1517. * When a vm is present (instance creation), we need to do
  1518. * a three-way merge between constructor options, instance
  1519. * options and parent options.
  1520. */
  1521. function mergeAssets(parentVal, childVal) {
  1522. var res = Object.create(parentVal || null);
  1523. return childVal ? extend(res, guardArrayAssets(childVal)) : res;
  1524. }
  1525. config._assetTypes.forEach(function (type) {
  1526. strats[type + 's'] = mergeAssets;
  1527. });
  1528. /**
  1529. * Events & Watchers.
  1530. *
  1531. * Events & watchers hashes should not overwrite one
  1532. * another, so we merge them as arrays.
  1533. */
  1534. strats.watch = strats.events = function (parentVal, childVal) {
  1535. if (!childVal) return parentVal;
  1536. if (!parentVal) return childVal;
  1537. var ret = {};
  1538. extend(ret, parentVal);
  1539. for (var key in childVal) {
  1540. var parent = ret[key];
  1541. var child = childVal[key];
  1542. if (parent && !isArray(parent)) {
  1543. parent = [parent];
  1544. }
  1545. ret[key] = parent ? parent.concat(child) : [child];
  1546. }
  1547. return ret;
  1548. };
  1549. /**
  1550. * Other object hashes.
  1551. */
  1552. strats.props = strats.methods = strats.computed = function (parentVal, childVal) {
  1553. if (!childVal) return parentVal;
  1554. if (!parentVal) return childVal;
  1555. var ret = Object.create(null);
  1556. extend(ret, parentVal);
  1557. extend(ret, childVal);
  1558. return ret;
  1559. };
  1560. /**
  1561. * Default strategy.
  1562. */
  1563. var defaultStrat = function defaultStrat(parentVal, childVal) {
  1564. return childVal === undefined ? parentVal : childVal;
  1565. };
  1566. /**
  1567. * Make sure component options get converted to actual
  1568. * constructors.
  1569. *
  1570. * @param {Object} options
  1571. */
  1572. function guardComponents(options) {
  1573. if (options.components) {
  1574. var components = options.components = guardArrayAssets(options.components);
  1575. var ids = Object.keys(components);
  1576. var def;
  1577. if ('development' !== 'production') {
  1578. var map = options._componentNameMap = {};
  1579. }
  1580. for (var i = 0, l = ids.length; i < l; i++) {
  1581. var key = ids[i];
  1582. if (commonTagRE.test(key) || reservedTagRE.test(key)) {
  1583. 'development' !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key);
  1584. continue;
  1585. }
  1586. // record a all lowercase <-> kebab-case mapping for
  1587. // possible custom element case error warning
  1588. if ('development' !== 'production') {
  1589. map[key.replace(/-/g, '').toLowerCase()] = hyphenate(key);
  1590. }
  1591. def = components[key];
  1592. if (isPlainObject(def)) {
  1593. components[key] = Vue.extend(def);
  1594. }
  1595. }
  1596. }
  1597. }
  1598. /**
  1599. * Ensure all props option syntax are normalized into the
  1600. * Object-based format.
  1601. *
  1602. * @param {Object} options
  1603. */
  1604. function guardProps(options) {
  1605. var props = options.props;
  1606. var i, val;
  1607. if (isArray(props)) {
  1608. options.props = {};
  1609. i = props.length;
  1610. while (i--) {
  1611. val = props[i];
  1612. if (typeof val === 'string') {
  1613. options.props[val] = null;
  1614. } else if (val.name) {
  1615. options.props[val.name] = val;
  1616. }
  1617. }
  1618. } else if (isPlainObject(props)) {
  1619. var keys = Object.keys(props);
  1620. i = keys.length;
  1621. while (i--) {
  1622. val = props[keys[i]];
  1623. if (typeof val === 'function') {
  1624. props[keys[i]] = { type: val };
  1625. }
  1626. }
  1627. }
  1628. }
  1629. /**
  1630. * Guard an Array-format assets option and converted it
  1631. * into the key-value Object format.
  1632. *
  1633. * @param {Object|Array} assets
  1634. * @return {Object}
  1635. */
  1636. function guardArrayAssets(assets) {
  1637. if (isArray(assets)) {
  1638. var res = {};
  1639. var i = assets.length;
  1640. var asset;
  1641. while (i--) {
  1642. asset = assets[i];
  1643. var id = typeof asset === 'function' ? asset.options && asset.options.name || asset.id : asset.name || asset.id;
  1644. if (!id) {
  1645. 'development' !== 'production' && warn('Array-syntax assets must provide a "name" or "id" field.');
  1646. } else {
  1647. res[id] = asset;
  1648. }
  1649. }
  1650. return res;
  1651. }
  1652. return assets;
  1653. }
  1654. /**
  1655. * Merge two option objects into a new one.
  1656. * Core utility used in both instantiation and inheritance.
  1657. *
  1658. * @param {Object} parent
  1659. * @param {Object} child
  1660. * @param {Vue} [vm] - if vm is present, indicates this is
  1661. * an instantiation merge.
  1662. */
  1663. function mergeOptions(parent, child, vm) {
  1664. guardComponents(child);
  1665. guardProps(child);
  1666. if ('development' !== 'production') {
  1667. if (child.propsData && !vm) {
  1668. warn('propsData can only be used as an instantiation option.');
  1669. }
  1670. }
  1671. var options = {};
  1672. var key;
  1673. if (child['extends']) {
  1674. parent = typeof child['extends'] === 'function' ? mergeOptions(parent, child['extends'].options, vm) : mergeOptions(parent, child['extends'], vm);
  1675. }
  1676. if (child.mixins) {
  1677. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1678. parent = mergeOptions(parent, child.mixins[i], vm);
  1679. }
  1680. }
  1681. for (key in parent) {
  1682. mergeField(key);
  1683. }
  1684. for (key in child) {
  1685. if (!hasOwn(parent, key)) {
  1686. mergeField(key);
  1687. }
  1688. }
  1689. function mergeField(key) {
  1690. var strat = strats[key] || defaultStrat;
  1691. options[key] = strat(parent[key], child[key], vm, key);
  1692. }
  1693. return options;
  1694. }
  1695. /**
  1696. * Resolve an asset.
  1697. * This function is used because child instances need access
  1698. * to assets defined in its ancestor chain.
  1699. *
  1700. * @param {Object} options
  1701. * @param {String} type
  1702. * @param {String} id
  1703. * @param {Boolean} warnMissing
  1704. * @return {Object|Function}
  1705. */
  1706. function resolveAsset(options, type, id, warnMissing) {
  1707. /* istanbul ignore if */
  1708. if (typeof id !== 'string') {
  1709. return;
  1710. }
  1711. var assets = options[type];
  1712. var camelizedId;
  1713. var res = assets[id] ||
  1714. // camelCase ID
  1715. assets[camelizedId = camelize(id)] ||
  1716. // Pascal Case ID
  1717. assets[camelizedId.charAt(0).toUpperCase() + camelizedId.slice(1)];
  1718. if ('development' !== 'production' && warnMissing && !res) {
  1719. warn('Failed to resolve ' + type.slice(0, -1) + ': ' + id, options);
  1720. }
  1721. return res;
  1722. }
  1723. var uid$1 = 0;
  1724. /**
  1725. * A dep is an observable that can have multiple
  1726. * directives subscribing to it.
  1727. *
  1728. * @constructor
  1729. */
  1730. function Dep() {
  1731. this.id = uid$1++;
  1732. this.subs = [];
  1733. }
  1734. // the current target watcher being evaluated.
  1735. // this is globally unique because there could be only one
  1736. // watcher being evaluated at any time.
  1737. Dep.target = null;
  1738. /**
  1739. * Add a directive subscriber.
  1740. *
  1741. * @param {Directive} sub
  1742. */
  1743. Dep.prototype.addSub = function (sub) {
  1744. this.subs.push(sub);
  1745. };
  1746. /**
  1747. * Remove a directive subscriber.
  1748. *
  1749. * @param {Directive} sub
  1750. */
  1751. Dep.prototype.removeSub = function (sub) {
  1752. this.subs.$remove(sub);
  1753. };
  1754. /**
  1755. * Add self as a dependency to the target watcher.
  1756. */
  1757. Dep.prototype.depend = function () {
  1758. Dep.target.addDep(this);
  1759. };
  1760. /**
  1761. * Notify all subscribers of a new value.
  1762. */
  1763. Dep.prototype.notify = function () {
  1764. // stablize the subscriber list first
  1765. var subs = toArray(this.subs);
  1766. for (var i = 0, l = subs.length; i < l; i++) {
  1767. subs[i].update();
  1768. }
  1769. };
  1770. var arrayProto = Array.prototype;
  1771. var arrayMethods = Object.create(arrayProto)
  1772. /**
  1773. * Intercept mutating methods and emit events
  1774. */
  1775. ;['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'].forEach(function (method) {
  1776. // cache original method
  1777. var original = arrayProto[method];
  1778. def(arrayMethods, method, function mutator() {
  1779. // avoid leaking arguments:
  1780. // http://jsperf.com/closure-with-arguments
  1781. var i = arguments.length;
  1782. var args = new Array(i);
  1783. while (i--) {
  1784. args[i] = arguments[i];
  1785. }
  1786. var result = original.apply(this, args);
  1787. var ob = this.__ob__;
  1788. var inserted;
  1789. switch (method) {
  1790. case 'push':
  1791. inserted = args;
  1792. break;
  1793. case 'unshift':
  1794. inserted = args;
  1795. break;
  1796. case 'splice':
  1797. inserted = args.slice(2);
  1798. break;
  1799. }
  1800. if (inserted) ob.observeArray(inserted);
  1801. // notify change
  1802. ob.dep.notify();
  1803. return result;
  1804. });
  1805. });
  1806. /**
  1807. * Swap the element at the given index with a new value
  1808. * and emits corresponding event.
  1809. *
  1810. * @param {Number} index
  1811. * @param {*} val
  1812. * @return {*} - replaced element
  1813. */
  1814. def(arrayProto, '$set', function $set(index, val) {
  1815. if (index >= this.length) {
  1816. this.length = Number(index) + 1;
  1817. }
  1818. return this.splice(index, 1, val)[0];
  1819. });
  1820. /**
  1821. * Convenience method to remove the element at given index or target element reference.
  1822. *
  1823. * @param {*} item
  1824. */
  1825. def(arrayProto, '$remove', function $remove(item) {
  1826. /* istanbul ignore if */
  1827. if (!this.length) return;
  1828. var index = indexOf(this, item);
  1829. if (index > -1) {
  1830. return this.splice(index, 1);
  1831. }
  1832. });
  1833. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  1834. /**
  1835. * By default, when a reactive property is set, the new value is
  1836. * also converted to become reactive. However in certain cases, e.g.
  1837. * v-for scope alias and props, we don't want to force conversion
  1838. * because the value may be a nested value under a frozen data structure.
  1839. *
  1840. * So whenever we want to set a reactive property without forcing
  1841. * conversion on the new value, we wrap that call inside this function.
  1842. */
  1843. var shouldConvert = true;
  1844. function withoutConversion(fn) {
  1845. shouldConvert = false;
  1846. fn();
  1847. shouldConvert = true;
  1848. }
  1849. /**
  1850. * Observer class that are attached to each observed
  1851. * object. Once attached, the observer converts target
  1852. * object's property keys into getter/setters that
  1853. * collect dependencies and dispatches updates.
  1854. *
  1855. * @param {Array|Object} value
  1856. * @constructor
  1857. */
  1858. function Observer(value) {
  1859. this.value = value;
  1860. this.dep = new Dep();
  1861. def(value, '__ob__', this);
  1862. if (isArray(value)) {
  1863. var augment = hasProto ? protoAugment : copyAugment;
  1864. augment(value, arrayMethods, arrayKeys);
  1865. this.observeArray(value);
  1866. } else {
  1867. this.walk(value);
  1868. }
  1869. }
  1870. // Instance methods
  1871. /**
  1872. * Walk through each property and convert them into
  1873. * getter/setters. This method should only be called when
  1874. * value type is Object.
  1875. *
  1876. * @param {Object} obj
  1877. */
  1878. Observer.prototype.walk = function (obj) {
  1879. var keys = Object.keys(obj);
  1880. for (var i = 0, l = keys.length; i < l; i++) {
  1881. this.convert(keys[i], obj[keys[i]]);
  1882. }
  1883. };
  1884. /**
  1885. * Observe a list of Array items.
  1886. *
  1887. * @param {Array} items
  1888. */
  1889. Observer.prototype.observeArray = function (items) {
  1890. for (var i = 0, l = items.length; i < l; i++) {
  1891. observe(items[i]);
  1892. }
  1893. };
  1894. /**
  1895. * Convert a property into getter/setter so we can emit
  1896. * the events when the property is accessed/changed.
  1897. *
  1898. * @param {String} key
  1899. * @param {*} val
  1900. */
  1901. Observer.prototype.convert = function (key, val) {
  1902. defineReactive(this.value, key, val);
  1903. };
  1904. /**
  1905. * Add an owner vm, so that when $set/$delete mutations
  1906. * happen we can notify owner vms to proxy the keys and
  1907. * digest the watchers. This is only called when the object
  1908. * is observed as an instance's root $data.
  1909. *
  1910. * @param {Vue} vm
  1911. */
  1912. Observer.prototype.addVm = function (vm) {
  1913. (this.vms || (this.vms = [])).push(vm);
  1914. };
  1915. /**
  1916. * Remove an owner vm. This is called when the object is
  1917. * swapped out as an instance's $data object.
  1918. *
  1919. * @param {Vue} vm
  1920. */
  1921. Observer.prototype.removeVm = function (vm) {
  1922. this.vms.$remove(vm);
  1923. };
  1924. // helpers
  1925. /**
  1926. * Augment an target Object or Array by intercepting
  1927. * the prototype chain using __proto__
  1928. *
  1929. * @param {Object|Array} target
  1930. * @param {Object} src
  1931. */
  1932. function protoAugment(target, src) {
  1933. /* eslint-disable no-proto */
  1934. target.__proto__ = src;
  1935. /* eslint-enable no-proto */
  1936. }
  1937. /**
  1938. * Augment an target Object or Array by defining
  1939. * hidden properties.
  1940. *
  1941. * @param {Object|Array} target
  1942. * @param {Object} proto
  1943. */
  1944. function copyAugment(target, src, keys) {
  1945. for (var i = 0, l = keys.length; i < l; i++) {
  1946. var key = keys[i];
  1947. def(target, key, src[key]);
  1948. }
  1949. }
  1950. /**
  1951. * Attempt to create an observer instance for a value,
  1952. * returns the new observer if successfully observed,
  1953. * or the existing observer if the value already has one.
  1954. *
  1955. * @param {*} value
  1956. * @param {Vue} [vm]
  1957. * @return {Observer|undefined}
  1958. * @static
  1959. */
  1960. function observe(value, vm) {
  1961. if (!value || typeof value !== 'object') {
  1962. return;
  1963. }
  1964. var ob;
  1965. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  1966. ob = value.__ob__;
  1967. } else if (shouldConvert && (isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
  1968. ob = new Observer(value);
  1969. }
  1970. if (ob && vm) {
  1971. ob.addVm(vm);
  1972. }
  1973. return ob;
  1974. }
  1975. /**
  1976. * Define a reactive property on an Object.
  1977. *
  1978. * @param {Object} obj
  1979. * @param {String} key
  1980. * @param {*} val
  1981. */
  1982. function defineReactive(obj, key, val) {
  1983. var dep = new Dep();
  1984. var property = Object.getOwnPropertyDescriptor(obj, key);
  1985. if (property && property.configurable === false) {
  1986. return;
  1987. }
  1988. // cater for pre-defined getter/setters
  1989. var getter = property && property.get;
  1990. var setter = property && property.set;
  1991. var childOb = observe(val);
  1992. Object.defineProperty(obj, key, {
  1993. enumerable: true,
  1994. configurable: true,
  1995. get: function reactiveGetter() {
  1996. var value = getter ? getter.call(obj) : val;
  1997. if (Dep.target) {
  1998. dep.depend();
  1999. if (childOb) {
  2000. childOb.dep.depend();
  2001. }
  2002. if (isArray(value)) {
  2003. for (var e, i = 0, l = value.length; i < l; i++) {
  2004. e = value[i];
  2005. e && e.__ob__ && e.__ob__.dep.depend();
  2006. }
  2007. }
  2008. }
  2009. return value;
  2010. },
  2011. set: function reactiveSetter(newVal) {
  2012. var value = getter ? getter.call(obj) : val;
  2013. if (newVal === value) {
  2014. return;
  2015. }
  2016. if (setter) {
  2017. setter.call(obj, newVal);
  2018. } else {
  2019. val = newVal;
  2020. }
  2021. childOb = observe(newVal);
  2022. dep.notify();
  2023. }
  2024. });
  2025. }
  2026. var util = Object.freeze({
  2027. defineReactive: defineReactive,
  2028. set: set,
  2029. del: del,
  2030. hasOwn: hasOwn,
  2031. isLiteral: isLiteral,
  2032. isReserved: isReserved,
  2033. _toString: _toString,
  2034. toNumber: toNumber,
  2035. toBoolean: toBoolean,
  2036. stripQuotes: stripQuotes,
  2037. camelize: camelize,
  2038. hyphenate: hyphenate,
  2039. classify: classify,
  2040. bind: bind,
  2041. toArray: toArray,
  2042. extend: extend,
  2043. isObject: isObject,
  2044. isPlainObject: isPlainObject,
  2045. def: def,
  2046. debounce: _debounce,
  2047. indexOf: indexOf,
  2048. cancellable: cancellable,
  2049. looseEqual: looseEqual,
  2050. isArray: isArray,
  2051. hasProto: hasProto,
  2052. inBrowser: inBrowser,
  2053. devtools: devtools,
  2054. isIE9: isIE9,
  2055. isAndroid: isAndroid,
  2056. isIos: isIos,
  2057. isWechat: isWechat,
  2058. get transitionProp () { return transitionProp; },
  2059. get transitionEndEvent () { return transitionEndEvent; },
  2060. get animationProp () { return animationProp; },
  2061. get animationEndEvent () { return animationEndEvent; },
  2062. nextTick: nextTick,
  2063. get _Set () { return _Set; },
  2064. query: query,
  2065. inDoc: inDoc,
  2066. getAttr: getAttr,
  2067. getBindAttr: getBindAttr,
  2068. hasBindAttr: hasBindAttr,
  2069. before: before,
  2070. after: after,
  2071. remove: remove,
  2072. prepend: prepend,
  2073. replace: replace,
  2074. on: on,
  2075. off: off,
  2076. setClass: setClass,
  2077. addClass: addClass,
  2078. removeClass: removeClass,
  2079. extractContent: extractContent,
  2080. trimNode: trimNode,
  2081. isTemplate: isTemplate,
  2082. createAnchor: createAnchor,
  2083. findRef: findRef,
  2084. mapNodeRange: mapNodeRange,
  2085. removeNodeRange: removeNodeRange,
  2086. isFragment: isFragment,
  2087. getOuterHTML: getOuterHTML,
  2088. mergeOptions: mergeOptions,
  2089. resolveAsset: resolveAsset,
  2090. checkComponentAttr: checkComponentAttr,
  2091. commonTagRE: commonTagRE,
  2092. reservedTagRE: reservedTagRE,
  2093. get warn () { return warn; }
  2094. });
  2095. var uid = 0;
  2096. function initMixin (Vue) {
  2097. /**
  2098. * The main init sequence. This is called for every
  2099. * instance, including ones that are created from extended
  2100. * constructors.
  2101. *
  2102. * @param {Object} options - this options object should be
  2103. * the result of merging class
  2104. * options and the options passed
  2105. * in to the constructor.
  2106. */
  2107. Vue.prototype._init = function (options) {
  2108. options = options || {};
  2109. this.$el = null;
  2110. this.$parent = options.parent;
  2111. this.$root = this.$parent ? this.$parent.$root : this;
  2112. this.$children = [];
  2113. this.$refs = {}; // child vm references
  2114. this.$els = {}; // element references
  2115. this._watchers = []; // all watchers as an array
  2116. this._directives = []; // all directives
  2117. // a uid
  2118. this._uid = uid++;
  2119. // a flag to avoid this being observed
  2120. this._isVue = true;
  2121. // events bookkeeping
  2122. this._events = {}; // registered callbacks
  2123. this._eventsCount = {}; // for $broadcast optimization
  2124. // fragment instance properties
  2125. this._isFragment = false;
  2126. this._fragment = // @type {DocumentFragment}
  2127. this._fragmentStart = // @type {Text|Comment}
  2128. this._fragmentEnd = null; // @type {Text|Comment}
  2129. // lifecycle state
  2130. this._isCompiled = this._isDestroyed = this._isReady = this._isAttached = this._isBeingDestroyed = this._vForRemoving = false;
  2131. this._unlinkFn = null;
  2132. // context:
  2133. // if this is a transcluded component, context
  2134. // will be the common parent vm of this instance
  2135. // and its host.
  2136. this._context = options._context || this.$parent;
  2137. // scope:
  2138. // if this is inside an inline v-for, the scope
  2139. // will be the intermediate scope created for this
  2140. // repeat fragment. this is used for linking props
  2141. // and container directives.
  2142. this._scope = options._scope;
  2143. // fragment:
  2144. // if this instance is compiled inside a Fragment, it
  2145. // needs to reigster itself as a child of that fragment
  2146. // for attach/detach to work properly.
  2147. this._frag = options._frag;
  2148. if (this._frag) {
  2149. this._frag.children.push(this);
  2150. }
  2151. // push self into parent / transclusion host
  2152. if (this.$parent) {
  2153. this.$parent.$children.push(this);
  2154. }
  2155. // merge options.
  2156. options = this.$options = mergeOptions(this.constructor.options, options, this);
  2157. // set ref
  2158. this._updateRef();
  2159. // initialize data as empty object.
  2160. // it will be filled up in _initData().
  2161. this._data = {};
  2162. // call init hook
  2163. this._callHook('init');
  2164. // initialize data observation and scope inheritance.
  2165. this._initState();
  2166. // setup event system and option events.
  2167. this._initEvents();
  2168. // call created hook
  2169. this._callHook('created');
  2170. // if `el` option is passed, start compilation.
  2171. if (options.el) {
  2172. this.$mount(options.el);
  2173. }
  2174. };
  2175. }
  2176. var pathCache = new Cache(1000);
  2177. // actions
  2178. var APPEND = 0;
  2179. var PUSH = 1;
  2180. var INC_SUB_PATH_DEPTH = 2;
  2181. var PUSH_SUB_PATH = 3;
  2182. // states
  2183. var BEFORE_PATH = 0;
  2184. var IN_PATH = 1;
  2185. var BEFORE_IDENT = 2;
  2186. var IN_IDENT = 3;
  2187. var IN_SUB_PATH = 4;
  2188. var IN_SINGLE_QUOTE = 5;
  2189. var IN_DOUBLE_QUOTE = 6;
  2190. var AFTER_PATH = 7;
  2191. var ERROR = 8;
  2192. var pathStateMachine = [];
  2193. pathStateMachine[BEFORE_PATH] = {
  2194. 'ws': [BEFORE_PATH],
  2195. 'ident': [IN_IDENT, APPEND],
  2196. '[': [IN_SUB_PATH],
  2197. 'eof': [AFTER_PATH]
  2198. };
  2199. pathStateMachine[IN_PATH] = {
  2200. 'ws': [IN_PATH],
  2201. '.': [BEFORE_IDENT],
  2202. '[': [IN_SUB_PATH],
  2203. 'eof': [AFTER_PATH]
  2204. };
  2205. pathStateMachine[BEFORE_IDENT] = {
  2206. 'ws': [BEFORE_IDENT],
  2207. 'ident': [IN_IDENT, APPEND]
  2208. };
  2209. pathStateMachine[IN_IDENT] = {
  2210. 'ident': [IN_IDENT, APPEND],
  2211. '0': [IN_IDENT, APPEND],
  2212. 'number': [IN_IDENT, APPEND],
  2213. 'ws': [IN_PATH, PUSH],
  2214. '.': [BEFORE_IDENT, PUSH],
  2215. '[': [IN_SUB_PATH, PUSH],
  2216. 'eof': [AFTER_PATH, PUSH]
  2217. };
  2218. pathStateMachine[IN_SUB_PATH] = {
  2219. "'": [IN_SINGLE_QUOTE, APPEND],
  2220. '"': [IN_DOUBLE_QUOTE, APPEND],
  2221. '[': [IN_SUB_PATH, INC_SUB_PATH_DEPTH],
  2222. ']': [IN_PATH, PUSH_SUB_PATH],
  2223. 'eof': ERROR,
  2224. 'else': [IN_SUB_PATH, APPEND]
  2225. };
  2226. pathStateMachine[IN_SINGLE_QUOTE] = {
  2227. "'": [IN_SUB_PATH, APPEND],
  2228. 'eof': ERROR,
  2229. 'else': [IN_SINGLE_QUOTE, APPEND]
  2230. };
  2231. pathStateMachine[IN_DOUBLE_QUOTE] = {
  2232. '"': [IN_SUB_PATH, APPEND],
  2233. 'eof': ERROR,
  2234. 'else': [IN_DOUBLE_QUOTE, APPEND]
  2235. };
  2236. /**
  2237. * Determine the type of a character in a keypath.
  2238. *
  2239. * @param {Char} ch
  2240. * @return {String} type
  2241. */
  2242. function getPathCharType(ch) {
  2243. if (ch === undefined) {
  2244. return 'eof';
  2245. }
  2246. var code = ch.charCodeAt(0);
  2247. switch (code) {
  2248. case 0x5B: // [
  2249. case 0x5D: // ]
  2250. case 0x2E: // .
  2251. case 0x22: // "
  2252. case 0x27: // '
  2253. case 0x30:
  2254. // 0
  2255. return ch;
  2256. case 0x5F: // _
  2257. case 0x24:
  2258. // $
  2259. return 'ident';
  2260. case 0x20: // Space
  2261. case 0x09: // Tab
  2262. case 0x0A: // Newline
  2263. case 0x0D: // Return
  2264. case 0xA0: // No-break space
  2265. case 0xFEFF: // Byte Order Mark
  2266. case 0x2028: // Line Separator
  2267. case 0x2029:
  2268. // Paragraph Separator
  2269. return 'ws';
  2270. }
  2271. // a-z, A-Z
  2272. if (code >= 0x61 && code <= 0x7A || code >= 0x41 && code <= 0x5A) {
  2273. return 'ident';
  2274. }
  2275. // 1-9
  2276. if (code >= 0x31 && code <= 0x39) {
  2277. return 'number';
  2278. }
  2279. return 'else';
  2280. }
  2281. /**
  2282. * Format a subPath, return its plain form if it is
  2283. * a literal string or number. Otherwise prepend the
  2284. * dynamic indicator (*).
  2285. *
  2286. * @param {String} path
  2287. * @return {String}
  2288. */
  2289. function formatSubPath(path) {
  2290. var trimmed = path.trim();
  2291. // invalid leading 0
  2292. if (path.charAt(0) === '0' && isNaN(path)) {
  2293. return false;
  2294. }
  2295. return isLiteral(trimmed) ? stripQuotes(trimmed) : '*' + trimmed;
  2296. }
  2297. /**
  2298. * Parse a string path into an array of segments
  2299. *
  2300. * @param {String} path
  2301. * @return {Array|undefined}
  2302. */
  2303. function parse(path) {
  2304. var keys = [];
  2305. var index = -1;
  2306. var mode = BEFORE_PATH;
  2307. var subPathDepth = 0;
  2308. var c, newChar, key, type, transition, action, typeMap;
  2309. var actions = [];
  2310. actions[PUSH] = function () {
  2311. if (key !== undefined) {
  2312. keys.push(key);
  2313. key = undefined;
  2314. }
  2315. };
  2316. actions[APPEND] = function () {
  2317. if (key === undefined) {
  2318. key = newChar;
  2319. } else {
  2320. key += newChar;
  2321. }
  2322. };
  2323. actions[INC_SUB_PATH_DEPTH] = function () {
  2324. actions[APPEND]();
  2325. subPathDepth++;
  2326. };
  2327. actions[PUSH_SUB_PATH] = function () {
  2328. if (subPathDepth > 0) {
  2329. subPathDepth--;
  2330. mode = IN_SUB_PATH;
  2331. actions[APPEND]();
  2332. } else {
  2333. subPathDepth = 0;
  2334. key = formatSubPath(key);
  2335. if (key === false) {
  2336. return false;
  2337. } else {
  2338. actions[PUSH]();
  2339. }
  2340. }
  2341. };
  2342. function maybeUnescapeQuote() {
  2343. var nextChar = path[index + 1];
  2344. if (mode === IN_SINGLE_QUOTE && nextChar === "'" || mode === IN_DOUBLE_QUOTE && nextChar === '"') {
  2345. index++;
  2346. newChar = '\\' + nextChar;
  2347. actions[APPEND]();
  2348. return true;
  2349. }
  2350. }
  2351. while (mode != null) {
  2352. index++;
  2353. c = path[index];
  2354. if (c === '\\' && maybeUnescapeQuote()) {
  2355. continue;
  2356. }
  2357. type = getPathCharType(c);
  2358. typeMap = pathStateMachine[mode];
  2359. transition = typeMap[type] || typeMap['else'] || ERROR;
  2360. if (transition === ERROR) {
  2361. return; // parse error
  2362. }
  2363. mode = transition[0];
  2364. action = actions[transition[1]];
  2365. if (action) {
  2366. newChar = transition[2];
  2367. newChar = newChar === undefined ? c : newChar;
  2368. if (action() === false) {
  2369. return;
  2370. }
  2371. }
  2372. if (mode === AFTER_PATH) {
  2373. keys.raw = path;
  2374. return keys;
  2375. }
  2376. }
  2377. }
  2378. /**
  2379. * External parse that check for a cache hit first
  2380. *
  2381. * @param {String} path
  2382. * @return {Array|undefined}
  2383. */
  2384. function parsePath(path) {
  2385. var hit = pathCache.get(path);
  2386. if (!hit) {
  2387. hit = parse(path);
  2388. if (hit) {
  2389. pathCache.put(path, hit);
  2390. }
  2391. }
  2392. return hit;
  2393. }
  2394. /**
  2395. * Get from an object from a path string
  2396. *
  2397. * @param {Object} obj
  2398. * @param {String} path
  2399. */
  2400. function getPath(obj, path) {
  2401. return parseExpression(path).get(obj);
  2402. }
  2403. /**
  2404. * Warn against setting non-existent root path on a vm.
  2405. */
  2406. var warnNonExistent;
  2407. if ('development' !== 'production') {
  2408. warnNonExistent = function (path, vm) {
  2409. warn('You are setting a non-existent path "' + path.raw + '" ' + 'on a vm instance. Consider pre-initializing the property ' + 'with the "data" option for more reliable reactivity ' + 'and better performance.', vm);
  2410. };
  2411. }
  2412. /**
  2413. * Set on an object from a path
  2414. *
  2415. * @param {Object} obj
  2416. * @param {String | Array} path
  2417. * @param {*} val
  2418. */
  2419. function setPath(obj, path, val) {
  2420. var original = obj;
  2421. if (typeof path === 'string') {
  2422. path = parse(path);
  2423. }
  2424. if (!path || !isObject(obj)) {
  2425. return false;
  2426. }
  2427. var last, key;
  2428. for (var i = 0, l = path.length; i < l; i++) {
  2429. last = obj;
  2430. key = path[i];
  2431. if (key.charAt(0) === '*') {
  2432. key = parseExpression(key.slice(1)).get.call(original, original);
  2433. }
  2434. if (i < l - 1) {
  2435. obj = obj[key];
  2436. if (!isObject(obj)) {
  2437. obj = {};
  2438. if ('development' !== 'production' && last._isVue) {
  2439. warnNonExistent(path, last);
  2440. }
  2441. set(last, key, obj);
  2442. }
  2443. } else {
  2444. if (isArray(obj)) {
  2445. obj.$set(key, val);
  2446. } else if (key in obj) {
  2447. obj[key] = val;
  2448. } else {
  2449. if ('development' !== 'production' && obj._isVue) {
  2450. warnNonExistent(path, obj);
  2451. }
  2452. set(obj, key, val);
  2453. }
  2454. }
  2455. }
  2456. return true;
  2457. }
  2458. var path = Object.freeze({
  2459. parsePath: parsePath,
  2460. getPath: getPath,
  2461. setPath: setPath
  2462. });
  2463. var expressionCache = new Cache(1000);
  2464. var allowedKeywords = 'Math,Date,this,true,false,null,undefined,Infinity,NaN,' + 'isNaN,isFinite,decodeURI,decodeURIComponent,encodeURI,' + 'encodeURIComponent,parseInt,parseFloat';
  2465. var allowedKeywordsRE = new RegExp('^(' + allowedKeywords.replace(/,/g, '\\b|') + '\\b)');
  2466. // keywords that don't make sense inside expressions
  2467. var improperKeywords = 'break,case,class,catch,const,continue,debugger,default,' + 'delete,do,else,export,extends,finally,for,function,if,' + 'import,in,instanceof,let,return,super,switch,throw,try,' + 'var,while,with,yield,enum,await,implements,package,' + 'protected,static,interface,private,public';
  2468. var improperKeywordsRE = new RegExp('^(' + improperKeywords.replace(/,/g, '\\b|') + '\\b)');
  2469. var wsRE = /\s/g;
  2470. var newlineRE = /\n/g;
  2471. var saveRE = /[\{,]\s*[\w\$_]+\s*:|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`)|new |typeof |void /g;
  2472. var restoreRE = /"(\d+)"/g;
  2473. var pathTestRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/;
  2474. var identRE = /[^\w$\.](?:[A-Za-z_$][\w$]*)/g;
  2475. var booleanLiteralRE = /^(?:true|false)$/;
  2476. /**
  2477. * Save / Rewrite / Restore
  2478. *
  2479. * When rewriting paths found in an expression, it is
  2480. * possible for the same letter sequences to be found in
  2481. * strings and Object literal property keys. Therefore we
  2482. * remove and store these parts in a temporary array, and
  2483. * restore them after the path rewrite.
  2484. */
  2485. var saved = [];
  2486. /**
  2487. * Save replacer
  2488. *
  2489. * The save regex can match two possible cases:
  2490. * 1. An opening object literal
  2491. * 2. A string
  2492. * If matched as a plain string, we need to escape its
  2493. * newlines, since the string needs to be preserved when
  2494. * generating the function body.
  2495. *
  2496. * @param {String} str
  2497. * @param {String} isString - str if matched as a string
  2498. * @return {String} - placeholder with index
  2499. */
  2500. function save(str, isString) {
  2501. var i = saved.length;
  2502. saved[i] = isString ? str.replace(newlineRE, '\\n') : str;
  2503. return '"' + i + '"';
  2504. }
  2505. /**
  2506. * Path rewrite replacer
  2507. *
  2508. * @param {String} raw
  2509. * @return {String}
  2510. */
  2511. function rewrite(raw) {
  2512. var c = raw.charAt(0);
  2513. var path = raw.slice(1);
  2514. if (allowedKeywordsRE.test(path)) {
  2515. return raw;
  2516. } else {
  2517. path = path.indexOf('"') > -1 ? path.replace(restoreRE, restore) : path;
  2518. return c + 'scope.' + path;
  2519. }
  2520. }
  2521. /**
  2522. * Restore replacer
  2523. *
  2524. * @param {String} str
  2525. * @param {String} i - matched save index
  2526. * @return {String}
  2527. */
  2528. function restore(str, i) {
  2529. return saved[i];
  2530. }
  2531. /**
  2532. * Rewrite an expression, prefixing all path accessors with
  2533. * `scope.` and generate getter/setter functions.
  2534. *
  2535. * @param {String} exp
  2536. * @return {Function}
  2537. */
  2538. function compileGetter(exp) {
  2539. if (improperKeywordsRE.test(exp)) {
  2540. 'development' !== 'production' && warn('Avoid using reserved keywords in expression: ' + exp);
  2541. }
  2542. // reset state
  2543. saved.length = 0;
  2544. // save strings and object literal keys
  2545. var body = exp.replace(saveRE, save).replace(wsRE, '');
  2546. // rewrite all paths
  2547. // pad 1 space here becaue the regex matches 1 extra char
  2548. body = (' ' + body).replace(identRE, rewrite).replace(restoreRE, restore);
  2549. return makeGetterFn(body);
  2550. }
  2551. /**
  2552. * Build a getter function. Requires eval.
  2553. *
  2554. * We isolate the try/catch so it doesn't affect the
  2555. * optimization of the parse function when it is not called.
  2556. *
  2557. * @param {String} body
  2558. * @return {Function|undefined}
  2559. */
  2560. function makeGetterFn(body) {
  2561. try {
  2562. /* eslint-disable no-new-func */
  2563. return new Function('scope', 'return ' + body + ';');
  2564. /* eslint-enable no-new-func */
  2565. } catch (e) {
  2566. 'development' !== 'production' && warn('Invalid expression. ' + 'Generated function body: ' + body);
  2567. }
  2568. }
  2569. /**
  2570. * Compile a setter function for the expression.
  2571. *
  2572. * @param {String} exp
  2573. * @return {Function|undefined}
  2574. */
  2575. function compileSetter(exp) {
  2576. var path = parsePath(exp);
  2577. if (path) {
  2578. return function (scope, val) {
  2579. setPath(scope, path, val);
  2580. };
  2581. } else {
  2582. 'development' !== 'production' && warn('Invalid setter expression: ' + exp);
  2583. }
  2584. }
  2585. /**
  2586. * Parse an expression into re-written getter/setters.
  2587. *
  2588. * @param {String} exp
  2589. * @param {Boolean} needSet
  2590. * @return {Function}
  2591. */
  2592. function parseExpression(exp, needSet) {
  2593. exp = exp.trim();
  2594. // try cache
  2595. var hit = expressionCache.get(exp);
  2596. if (hit) {
  2597. if (needSet && !hit.set) {
  2598. hit.set = compileSetter(hit.exp);
  2599. }
  2600. return hit;
  2601. }
  2602. var res = { exp: exp };
  2603. res.get = isSimplePath(exp) && exp.indexOf('[') < 0
  2604. // optimized super simple getter
  2605. ? makeGetterFn('scope.' + exp)
  2606. // dynamic getter
  2607. : compileGetter(exp);
  2608. if (needSet) {
  2609. res.set = compileSetter(exp);
  2610. }
  2611. expressionCache.put(exp, res);
  2612. return res;
  2613. }
  2614. /**
  2615. * Check if an expression is a simple path.
  2616. *
  2617. * @param {String} exp
  2618. * @return {Boolean}
  2619. */
  2620. function isSimplePath(exp) {
  2621. return pathTestRE.test(exp) &&
  2622. // don't treat true/false as paths
  2623. !booleanLiteralRE.test(exp) &&
  2624. // Math constants e.g. Math.PI, Math.E etc.
  2625. exp.slice(0, 5) !== 'Math.';
  2626. }
  2627. var expression = Object.freeze({
  2628. parseExpression: parseExpression,
  2629. isSimplePath: isSimplePath
  2630. });
  2631. // we have two separate queues: one for directive updates
  2632. // and one for user watcher registered via $watch().
  2633. // we want to guarantee directive updates to be called
  2634. // before user watchers so that when user watchers are
  2635. // triggered, the DOM would have already been in updated
  2636. // state.
  2637. var queue = [];
  2638. var userQueue = [];
  2639. var has = {};
  2640. var circular = {};
  2641. var waiting = false;
  2642. /**
  2643. * Reset the batcher's state.
  2644. */
  2645. function resetBatcherState() {
  2646. queue.length = 0;
  2647. userQueue.length = 0;
  2648. has = {};
  2649. circular = {};
  2650. waiting = false;
  2651. }
  2652. /**
  2653. * Flush both queues and run the watchers.
  2654. */
  2655. function flushBatcherQueue() {
  2656. var _again = true;
  2657. _function: while (_again) {
  2658. _again = false;
  2659. runBatcherQueue(queue);
  2660. runBatcherQueue(userQueue);
  2661. // user watchers triggered more watchers,
  2662. // keep flushing until it depletes
  2663. if (queue.length) {
  2664. _again = true;
  2665. continue _function;
  2666. }
  2667. // dev tool hook
  2668. /* istanbul ignore if */
  2669. if (devtools && config.devtools) {
  2670. devtools.emit('flush');
  2671. }
  2672. resetBatcherState();
  2673. }
  2674. }
  2675. /**
  2676. * Run the watchers in a single queue.
  2677. *
  2678. * @param {Array} queue
  2679. */
  2680. function runBatcherQueue(queue) {
  2681. // do not cache length because more watchers might be pushed
  2682. // as we run existing watchers
  2683. for (var i = 0; i < queue.length; i++) {
  2684. var watcher = queue[i];
  2685. var id = watcher.id;
  2686. has[id] = null;
  2687. watcher.run();
  2688. // in dev build, check and stop circular updates.
  2689. if ('development' !== 'production' && has[id] != null) {
  2690. circular[id] = (circular[id] || 0) + 1;
  2691. if (circular[id] > config._maxUpdateCount) {
  2692. warn('You may have an infinite update loop for watcher ' + 'with expression "' + watcher.expression + '"', watcher.vm);
  2693. break;
  2694. }
  2695. }
  2696. }
  2697. queue.length = 0;
  2698. }
  2699. /**
  2700. * Push a watcher into the watcher queue.
  2701. * Jobs with duplicate IDs will be skipped unless it's
  2702. * pushed when the queue is being flushed.
  2703. *
  2704. * @param {Watcher} watcher
  2705. * properties:
  2706. * - {Number} id
  2707. * - {Function} run
  2708. */
  2709. function pushWatcher(watcher) {
  2710. var id = watcher.id;
  2711. if (has[id] == null) {
  2712. // push watcher into appropriate queue
  2713. var q = watcher.user ? userQueue : queue;
  2714. has[id] = q.length;
  2715. q.push(watcher);
  2716. // queue the flush
  2717. if (!waiting) {
  2718. waiting = true;
  2719. nextTick(flushBatcherQueue);
  2720. }
  2721. }
  2722. }
  2723. var uid$2 = 0;
  2724. /**
  2725. * A watcher parses an expression, collects dependencies,
  2726. * and fires callback when the expression value changes.
  2727. * This is used for both the $watch() api and directives.
  2728. *
  2729. * @param {Vue} vm
  2730. * @param {String|Function} expOrFn
  2731. * @param {Function} cb
  2732. * @param {Object} options
  2733. * - {Array} filters
  2734. * - {Boolean} twoWay
  2735. * - {Boolean} deep
  2736. * - {Boolean} user
  2737. * - {Boolean} sync
  2738. * - {Boolean} lazy
  2739. * - {Function} [preProcess]
  2740. * - {Function} [postProcess]
  2741. * @constructor
  2742. */
  2743. function Watcher(vm, expOrFn, cb, options) {
  2744. // mix in options
  2745. if (options) {
  2746. extend(this, options);
  2747. }
  2748. var isFn = typeof expOrFn === 'function';
  2749. this.vm = vm;
  2750. vm._watchers.push(this);
  2751. this.expression = expOrFn;
  2752. this.cb = cb;
  2753. this.id = ++uid$2; // uid for batching
  2754. this.active = true;
  2755. this.dirty = this.lazy; // for lazy watchers
  2756. this.deps = [];
  2757. this.newDeps = [];
  2758. this.depIds = new _Set();
  2759. this.newDepIds = new _Set();
  2760. this.prevError = null; // for async error stacks
  2761. // parse expression for getter/setter
  2762. if (isFn) {
  2763. this.getter = expOrFn;
  2764. this.setter = undefined;
  2765. } else {
  2766. var res = parseExpression(expOrFn, this.twoWay);
  2767. this.getter = res.get;
  2768. this.setter = res.set;
  2769. }
  2770. this.value = this.lazy ? undefined : this.get();
  2771. // state for avoiding false triggers for deep and Array
  2772. // watchers during vm._digest()
  2773. this.queued = this.shallow = false;
  2774. }
  2775. /**
  2776. * Evaluate the getter, and re-collect dependencies.
  2777. */
  2778. Watcher.prototype.get = function () {
  2779. this.beforeGet();
  2780. var scope = this.scope || this.vm;
  2781. var value;
  2782. try {
  2783. value = this.getter.call(scope, scope);
  2784. } catch (e) {
  2785. if ('development' !== 'production' && config.warnExpressionErrors) {
  2786. warn('Error when evaluating expression ' + '"' + this.expression + '": ' + e.toString(), this.vm);
  2787. }
  2788. }
  2789. // "touch" every property so they are all tracked as
  2790. // dependencies for deep watching
  2791. if (this.deep) {
  2792. traverse(value);
  2793. }
  2794. if (this.preProcess) {
  2795. value = this.preProcess(value);
  2796. }
  2797. if (this.filters) {
  2798. value = scope._applyFilters(value, null, this.filters, false);
  2799. }
  2800. if (this.postProcess) {
  2801. value = this.postProcess(value);
  2802. }
  2803. this.afterGet();
  2804. return value;
  2805. };
  2806. /**
  2807. * Set the corresponding value with the setter.
  2808. *
  2809. * @param {*} value
  2810. */
  2811. Watcher.prototype.set = function (value) {
  2812. var scope = this.scope || this.vm;
  2813. if (this.filters) {
  2814. value = scope._applyFilters(value, this.value, this.filters, true);
  2815. }
  2816. try {
  2817. this.setter.call(scope, scope, value);
  2818. } catch (e) {
  2819. if ('development' !== 'production' && config.warnExpressionErrors) {
  2820. warn('Error when evaluating setter ' + '"' + this.expression + '": ' + e.toString(), this.vm);
  2821. }
  2822. }
  2823. // two-way sync for v-for alias
  2824. var forContext = scope.$forContext;
  2825. if (forContext && forContext.alias === this.expression) {
  2826. if (forContext.filters) {
  2827. 'development' !== 'production' && warn('It seems you are using two-way binding on ' + 'a v-for alias (' + this.expression + '), and the ' + 'v-for has filters. This will not work properly. ' + 'Either remove the filters or use an array of ' + 'objects and bind to object properties instead.', this.vm);
  2828. return;
  2829. }
  2830. forContext._withLock(function () {
  2831. if (scope.$key) {
  2832. // original is an object
  2833. forContext.rawValue[scope.$key] = value;
  2834. } else {
  2835. forContext.rawValue.$set(scope.$index, value);
  2836. }
  2837. });
  2838. }
  2839. };
  2840. /**
  2841. * Prepare for dependency collection.
  2842. */
  2843. Watcher.prototype.beforeGet = function () {
  2844. Dep.target = this;
  2845. };
  2846. /**
  2847. * Add a dependency to this directive.
  2848. *
  2849. * @param {Dep} dep
  2850. */
  2851. Watcher.prototype.addDep = function (dep) {
  2852. var id = dep.id;
  2853. if (!this.newDepIds.has(id)) {
  2854. this.newDepIds.add(id);
  2855. this.newDeps.push(dep);
  2856. if (!this.depIds.has(id)) {
  2857. dep.addSub(this);
  2858. }
  2859. }
  2860. };
  2861. /**
  2862. * Clean up for dependency collection.
  2863. */
  2864. Watcher.prototype.afterGet = function () {
  2865. Dep.target = null;
  2866. var i = this.deps.length;
  2867. while (i--) {
  2868. var dep = this.deps[i];
  2869. if (!this.newDepIds.has(dep.id)) {
  2870. dep.removeSub(this);
  2871. }
  2872. }
  2873. var tmp = this.depIds;
  2874. this.depIds = this.newDepIds;
  2875. this.newDepIds = tmp;
  2876. this.newDepIds.clear();
  2877. tmp = this.deps;
  2878. this.deps = this.newDeps;
  2879. this.newDeps = tmp;
  2880. this.newDeps.length = 0;
  2881. };
  2882. /**
  2883. * Subscriber interface.
  2884. * Will be called when a dependency changes.
  2885. *
  2886. * @param {Boolean} shallow
  2887. */
  2888. Watcher.prototype.update = function (shallow) {
  2889. if (this.lazy) {
  2890. this.dirty = true;
  2891. } else if (this.sync || !config.async) {
  2892. this.run();
  2893. } else {
  2894. // if queued, only overwrite shallow with non-shallow,
  2895. // but not the other way around.
  2896. this.shallow = this.queued ? shallow ? this.shallow : false : !!shallow;
  2897. this.queued = true;
  2898. // record before-push error stack in debug mode
  2899. /* istanbul ignore if */
  2900. if ('development' !== 'production' && config.debug) {
  2901. this.prevError = new Error('[vue] async stack trace');
  2902. }
  2903. pushWatcher(this);
  2904. }
  2905. };
  2906. /**
  2907. * Batcher job interface.
  2908. * Will be called by the batcher.
  2909. */
  2910. Watcher.prototype.run = function () {
  2911. if (this.active) {
  2912. var value = this.get();
  2913. if (value !== this.value ||
  2914. // Deep watchers and watchers on Object/Arrays should fire even
  2915. // when the value is the same, because the value may
  2916. // have mutated; but only do so if this is a
  2917. // non-shallow update (caused by a vm digest).
  2918. (isObject(value) || this.deep) && !this.shallow) {
  2919. // set new value
  2920. var oldValue = this.value;
  2921. this.value = value;
  2922. // in debug + async mode, when a watcher callbacks
  2923. // throws, we also throw the saved before-push error
  2924. // so the full cross-tick stack trace is available.
  2925. var prevError = this.prevError;
  2926. /* istanbul ignore if */
  2927. if ('development' !== 'production' && config.debug && prevError) {
  2928. this.prevError = null;
  2929. try {
  2930. this.cb.call(this.vm, value, oldValue);
  2931. } catch (e) {
  2932. nextTick(function () {
  2933. throw prevError;
  2934. }, 0);
  2935. throw e;
  2936. }
  2937. } else {
  2938. this.cb.call(this.vm, value, oldValue);
  2939. }
  2940. }
  2941. this.queued = this.shallow = false;
  2942. }
  2943. };
  2944. /**
  2945. * Evaluate the value of the watcher.
  2946. * This only gets called for lazy watchers.
  2947. */
  2948. Watcher.prototype.evaluate = function () {
  2949. // avoid overwriting another watcher that is being
  2950. // collected.
  2951. var current = Dep.target;
  2952. this.value = this.get();
  2953. this.dirty = false;
  2954. Dep.target = current;
  2955. };
  2956. /**
  2957. * Depend on all deps collected by this watcher.
  2958. */
  2959. Watcher.prototype.depend = function () {
  2960. var i = this.deps.length;
  2961. while (i--) {
  2962. this.deps[i].depend();
  2963. }
  2964. };
  2965. /**
  2966. * Remove self from all dependencies' subcriber list.
  2967. */
  2968. Watcher.prototype.teardown = function () {
  2969. if (this.active) {
  2970. // remove self from vm's watcher list
  2971. // this is a somewhat expensive operation so we skip it
  2972. // if the vm is being destroyed or is performing a v-for
  2973. // re-render (the watcher list is then filtered by v-for).
  2974. if (!this.vm._isBeingDestroyed && !this.vm._vForRemoving) {
  2975. this.vm._watchers.$remove(this);
  2976. }
  2977. var i = this.deps.length;
  2978. while (i--) {
  2979. this.deps[i].removeSub(this);
  2980. }
  2981. this.active = false;
  2982. this.vm = this.cb = this.value = null;
  2983. }
  2984. };
  2985. /**
  2986. * Recrusively traverse an object to evoke all converted
  2987. * getters, so that every nested property inside the object
  2988. * is collected as a "deep" dependency.
  2989. *
  2990. * @param {*} val
  2991. */
  2992. var seenObjects = new _Set();
  2993. function traverse(val, seen) {
  2994. var i = undefined,
  2995. keys = undefined;
  2996. if (!seen) {
  2997. seen = seenObjects;
  2998. seen.clear();
  2999. }
  3000. var isA = isArray(val);
  3001. var isO = isObject(val);
  3002. if (isA || isO) {
  3003. if (val.__ob__) {
  3004. var depId = val.__ob__.dep.id;
  3005. if (seen.has(depId)) {
  3006. return;
  3007. } else {
  3008. seen.add(depId);
  3009. }
  3010. }
  3011. if (isA) {
  3012. i = val.length;
  3013. while (i--) traverse(val[i], seen);
  3014. } else if (isO) {
  3015. keys = Object.keys(val);
  3016. i = keys.length;
  3017. while (i--) traverse(val[keys[i]], seen);
  3018. }
  3019. }
  3020. }
  3021. var text$1 = {
  3022. bind: function bind() {
  3023. this.attr = this.el.nodeType === 3 ? 'data' : 'textContent';
  3024. },
  3025. update: function update(value) {
  3026. this.el[this.attr] = _toString(value);
  3027. }
  3028. };
  3029. var templateCache = new Cache(1000);
  3030. var idSelectorCache = new Cache(1000);
  3031. var map = {
  3032. efault: [0, '', ''],
  3033. legend: [1, '<fieldset>', '</fieldset>'],
  3034. tr: [2, '<table><tbody>', '</tbody></table>'],
  3035. col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>']
  3036. };
  3037. map.td = map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
  3038. map.option = map.optgroup = [1, '<select multiple="multiple">', '</select>'];
  3039. map.thead = map.tbody = map.colgroup = map.caption = map.tfoot = [1, '<table>', '</table>'];
  3040. map.g = map.defs = map.symbol = map.use = map.image = map.text = map.circle = map.ellipse = map.line = map.path = map.polygon = map.polyline = map.rect = [1, '<svg ' + 'xmlns="http://www.w3.org/2000/svg" ' + 'xmlns:xlink="http://www.w3.org/1999/xlink" ' + 'xmlns:ev="http://www.w3.org/2001/xml-events"' + 'version="1.1">', '</svg>'];
  3041. /**
  3042. * Check if a node is a supported template node with a
  3043. * DocumentFragment content.
  3044. *
  3045. * @param {Node} node
  3046. * @return {Boolean}
  3047. */
  3048. function isRealTemplate(node) {
  3049. return isTemplate(node) && isFragment(node.content);
  3050. }
  3051. var tagRE$1 = /<([\w:-]+)/;
  3052. var entityRE = /&#?\w+?;/;
  3053. /**
  3054. * Convert a string template to a DocumentFragment.
  3055. * Determines correct wrapping by tag types. Wrapping
  3056. * strategy found in jQuery & component/domify.
  3057. *
  3058. * @param {String} templateString
  3059. * @param {Boolean} raw
  3060. * @return {DocumentFragment}
  3061. */
  3062. function stringToFragment(templateString, raw) {
  3063. // try a cache hit first
  3064. var cacheKey = raw ? templateString : templateString.trim();
  3065. var hit = templateCache.get(cacheKey);
  3066. if (hit) {
  3067. return hit;
  3068. }
  3069. var frag = document.createDocumentFragment();
  3070. var tagMatch = templateString.match(tagRE$1);
  3071. var entityMatch = entityRE.test(templateString);
  3072. if (!tagMatch && !entityMatch) {
  3073. // text only, return a single text node.
  3074. frag.appendChild(document.createTextNode(templateString));
  3075. } else {
  3076. var tag = tagMatch && tagMatch[1];
  3077. var wrap = map[tag] || map.efault;
  3078. var depth = wrap[0];
  3079. var prefix = wrap[1];
  3080. var suffix = wrap[2];
  3081. var node = document.createElement('div');
  3082. node.innerHTML = prefix + templateString + suffix;
  3083. while (depth--) {
  3084. node = node.lastChild;
  3085. }
  3086. var child;
  3087. /* eslint-disable no-cond-assign */
  3088. while (child = node.firstChild) {
  3089. /* eslint-enable no-cond-assign */
  3090. frag.appendChild(child);
  3091. }
  3092. }
  3093. if (!raw) {
  3094. trimNode(frag);
  3095. }
  3096. templateCache.put(cacheKey, frag);
  3097. return frag;
  3098. }
  3099. /**
  3100. * Convert a template node to a DocumentFragment.
  3101. *
  3102. * @param {Node} node
  3103. * @return {DocumentFragment}
  3104. */
  3105. function nodeToFragment(node) {
  3106. // if its a template tag and the browser supports it,
  3107. // its content is already a document fragment. However, iOS Safari has
  3108. // bug when using directly cloned template content with touch
  3109. // events and can cause crashes when the nodes are removed from DOM, so we
  3110. // have to treat template elements as string templates. (#2805)
  3111. /* istanbul ignore if */
  3112. if (isRealTemplate(node)) {
  3113. return stringToFragment(node.innerHTML);
  3114. }
  3115. // script template
  3116. if (node.tagName === 'SCRIPT') {
  3117. return stringToFragment(node.textContent);
  3118. }
  3119. // normal node, clone it to avoid mutating the original
  3120. var clonedNode = cloneNode(node);
  3121. var frag = document.createDocumentFragment();
  3122. var child;
  3123. /* eslint-disable no-cond-assign */
  3124. while (child = clonedNode.firstChild) {
  3125. /* eslint-enable no-cond-assign */
  3126. frag.appendChild(child);
  3127. }
  3128. trimNode(frag);
  3129. return frag;
  3130. }
  3131. // Test for the presence of the Safari template cloning bug
  3132. // https://bugs.webkit.org/showug.cgi?id=137755
  3133. var hasBrokenTemplate = (function () {
  3134. /* istanbul ignore else */
  3135. if (inBrowser) {
  3136. var a = document.createElement('div');
  3137. a.innerHTML = '<template>1</template>';
  3138. return !a.cloneNode(true).firstChild.innerHTML;
  3139. } else {
  3140. return false;
  3141. }
  3142. })();
  3143. // Test for IE10/11 textarea placeholder clone bug
  3144. var hasTextareaCloneBug = (function () {
  3145. /* istanbul ignore else */
  3146. if (inBrowser) {
  3147. var t = document.createElement('textarea');
  3148. t.placeholder = 't';
  3149. return t.cloneNode(true).value === 't';
  3150. } else {
  3151. return false;
  3152. }
  3153. })();
  3154. /**
  3155. * 1. Deal with Safari cloning nested <template> bug by
  3156. * manually cloning all template instances.
  3157. * 2. Deal with IE10/11 textarea placeholder bug by setting
  3158. * the correct value after cloning.
  3159. *
  3160. * @param {Element|DocumentFragment} node
  3161. * @return {Element|DocumentFragment}
  3162. */
  3163. function cloneNode(node) {
  3164. /* istanbul ignore if */
  3165. if (!node.querySelectorAll) {
  3166. return node.cloneNode();
  3167. }
  3168. var res = node.cloneNode(true);
  3169. var i, original, cloned;
  3170. /* istanbul ignore if */
  3171. if (hasBrokenTemplate) {
  3172. var tempClone = res;
  3173. if (isRealTemplate(node)) {
  3174. node = node.content;
  3175. tempClone = res.content;
  3176. }
  3177. original = node.querySelectorAll('template');
  3178. if (original.length) {
  3179. cloned = tempClone.querySelectorAll('template');
  3180. i = cloned.length;
  3181. while (i--) {
  3182. cloned[i].parentNode.replaceChild(cloneNode(original[i]), cloned[i]);
  3183. }
  3184. }
  3185. }
  3186. /* istanbul ignore if */
  3187. if (hasTextareaCloneBug) {
  3188. if (node.tagName === 'TEXTAREA') {
  3189. res.value = node.value;
  3190. } else {
  3191. original = node.querySelectorAll('textarea');
  3192. if (original.length) {
  3193. cloned = res.querySelectorAll('textarea');
  3194. i = cloned.length;
  3195. while (i--) {
  3196. cloned[i].value = original[i].value;
  3197. }
  3198. }
  3199. }
  3200. }
  3201. return res;
  3202. }
  3203. /**
  3204. * Process the template option and normalizes it into a
  3205. * a DocumentFragment that can be used as a partial or a
  3206. * instance template.
  3207. *
  3208. * @param {*} template
  3209. * Possible values include:
  3210. * - DocumentFragment object
  3211. * - Node object of type Template
  3212. * - id selector: '#some-template-id'
  3213. * - template string: '<div><span>{{msg}}</span></div>'
  3214. * @param {Boolean} shouldClone
  3215. * @param {Boolean} raw
  3216. * inline HTML interpolation. Do not check for id
  3217. * selector and keep whitespace in the string.
  3218. * @return {DocumentFragment|undefined}
  3219. */
  3220. function parseTemplate(template, shouldClone, raw) {
  3221. var node, frag;
  3222. // if the template is already a document fragment,
  3223. // do nothing
  3224. if (isFragment(template)) {
  3225. trimNode(template);
  3226. return shouldClone ? cloneNode(template) : template;
  3227. }
  3228. if (typeof template === 'string') {
  3229. // id selector
  3230. if (!raw && template.charAt(0) === '#') {
  3231. // id selector can be cached too
  3232. frag = idSelectorCache.get(template);
  3233. if (!frag) {
  3234. node = document.getElementById(template.slice(1));
  3235. if (node) {
  3236. frag = nodeToFragment(node);
  3237. // save selector to cache
  3238. idSelectorCache.put(template, frag);
  3239. }
  3240. }
  3241. } else {
  3242. // normal string template
  3243. frag = stringToFragment(template, raw);
  3244. }
  3245. } else if (template.nodeType) {
  3246. // a direct node
  3247. frag = nodeToFragment(template);
  3248. }
  3249. return frag && shouldClone ? cloneNode(frag) : frag;
  3250. }
  3251. var template = Object.freeze({
  3252. cloneNode: cloneNode,
  3253. parseTemplate: parseTemplate
  3254. });
  3255. var html = {
  3256. bind: function bind() {
  3257. // a comment node means this is a binding for
  3258. // {{{ inline unescaped html }}}
  3259. if (this.el.nodeType === 8) {
  3260. // hold nodes
  3261. this.nodes = [];
  3262. // replace the placeholder with proper anchor
  3263. this.anchor = createAnchor('v-html');
  3264. replace(this.el, this.anchor);
  3265. }
  3266. },
  3267. update: function update(value) {
  3268. value = _toString(value);
  3269. if (this.nodes) {
  3270. this.swap(value);
  3271. } else {
  3272. this.el.innerHTML = value;
  3273. }
  3274. },
  3275. swap: function swap(value) {
  3276. // remove old nodes
  3277. var i = this.nodes.length;
  3278. while (i--) {
  3279. remove(this.nodes[i]);
  3280. }
  3281. // convert new value to a fragment
  3282. // do not attempt to retrieve from id selector
  3283. var frag = parseTemplate(value, true, true);
  3284. // save a reference to these nodes so we can remove later
  3285. this.nodes = toArray(frag.childNodes);
  3286. before(frag, this.anchor);
  3287. }
  3288. };
  3289. /**
  3290. * Abstraction for a partially-compiled fragment.
  3291. * Can optionally compile content with a child scope.
  3292. *
  3293. * @param {Function} linker
  3294. * @param {Vue} vm
  3295. * @param {DocumentFragment} frag
  3296. * @param {Vue} [host]
  3297. * @param {Object} [scope]
  3298. * @param {Fragment} [parentFrag]
  3299. */
  3300. function Fragment(linker, vm, frag, host, scope, parentFrag) {
  3301. this.children = [];
  3302. this.childFrags = [];
  3303. this.vm = vm;
  3304. this.scope = scope;
  3305. this.inserted = false;
  3306. this.parentFrag = parentFrag;
  3307. if (parentFrag) {
  3308. parentFrag.childFrags.push(this);
  3309. }
  3310. this.unlink = linker(vm, frag, host, scope, this);
  3311. var single = this.single = frag.childNodes.length === 1 &&
  3312. // do not go single mode if the only node is an anchor
  3313. !frag.childNodes[0].__v_anchor;
  3314. if (single) {
  3315. this.node = frag.childNodes[0];
  3316. this.before = singleBefore;
  3317. this.remove = singleRemove;
  3318. } else {
  3319. this.node = createAnchor('fragment-start');
  3320. this.end = createAnchor('fragment-end');
  3321. this.frag = frag;
  3322. prepend(this.node, frag);
  3323. frag.appendChild(this.end);
  3324. this.before = multiBefore;
  3325. this.remove = multiRemove;
  3326. }
  3327. this.node.__v_frag = this;
  3328. }
  3329. /**
  3330. * Call attach/detach for all components contained within
  3331. * this fragment. Also do so recursively for all child
  3332. * fragments.
  3333. *
  3334. * @param {Function} hook
  3335. */
  3336. Fragment.prototype.callHook = function (hook) {
  3337. var i, l;
  3338. for (i = 0, l = this.childFrags.length; i < l; i++) {
  3339. this.childFrags[i].callHook(hook);
  3340. }
  3341. for (i = 0, l = this.children.length; i < l; i++) {
  3342. hook(this.children[i]);
  3343. }
  3344. };
  3345. /**
  3346. * Insert fragment before target, single node version
  3347. *
  3348. * @param {Node} target
  3349. * @param {Boolean} withTransition
  3350. */
  3351. function singleBefore(target, withTransition) {
  3352. this.inserted = true;
  3353. var method = withTransition !== false ? beforeWithTransition : before;
  3354. method(this.node, target, this.vm);
  3355. if (inDoc(this.node)) {
  3356. this.callHook(attach);
  3357. }
  3358. }
  3359. /**
  3360. * Remove fragment, single node version
  3361. */
  3362. function singleRemove() {
  3363. this.inserted = false;
  3364. var shouldCallRemove = inDoc(this.node);
  3365. var self = this;
  3366. this.beforeRemove();
  3367. removeWithTransition(this.node, this.vm, function () {
  3368. if (shouldCallRemove) {
  3369. self.callHook(detach);
  3370. }
  3371. self.destroy();
  3372. });
  3373. }
  3374. /**
  3375. * Insert fragment before target, multi-nodes version
  3376. *
  3377. * @param {Node} target
  3378. * @param {Boolean} withTransition
  3379. */
  3380. function multiBefore(target, withTransition) {
  3381. this.inserted = true;
  3382. var vm = this.vm;
  3383. var method = withTransition !== false ? beforeWithTransition : before;
  3384. mapNodeRange(this.node, this.end, function (node) {
  3385. method(node, target, vm);
  3386. });
  3387. if (inDoc(this.node)) {
  3388. this.callHook(attach);
  3389. }
  3390. }
  3391. /**
  3392. * Remove fragment, multi-nodes version
  3393. */
  3394. function multiRemove() {
  3395. this.inserted = false;
  3396. var self = this;
  3397. var shouldCallRemove = inDoc(this.node);
  3398. this.beforeRemove();
  3399. removeNodeRange(this.node, this.end, this.vm, this.frag, function () {
  3400. if (shouldCallRemove) {
  3401. self.callHook(detach);
  3402. }
  3403. self.destroy();
  3404. });
  3405. }
  3406. /**
  3407. * Prepare the fragment for removal.
  3408. */
  3409. Fragment.prototype.beforeRemove = function () {
  3410. var i, l;
  3411. for (i = 0, l = this.childFrags.length; i < l; i++) {
  3412. // call the same method recursively on child
  3413. // fragments, depth-first
  3414. this.childFrags[i].beforeRemove(false);
  3415. }
  3416. for (i = 0, l = this.children.length; i < l; i++) {
  3417. // Call destroy for all contained instances,
  3418. // with remove:false and defer:true.
  3419. // Defer is necessary because we need to
  3420. // keep the children to call detach hooks
  3421. // on them.
  3422. this.children[i].$destroy(false, true);
  3423. }
  3424. var dirs = this.unlink.dirs;
  3425. for (i = 0, l = dirs.length; i < l; i++) {
  3426. // disable the watchers on all the directives
  3427. // so that the rendered content stays the same
  3428. // during removal.
  3429. dirs[i]._watcher && dirs[i]._watcher.teardown();
  3430. }
  3431. };
  3432. /**
  3433. * Destroy the fragment.
  3434. */
  3435. Fragment.prototype.destroy = function () {
  3436. if (this.parentFrag) {
  3437. this.parentFrag.childFrags.$remove(this);
  3438. }
  3439. this.node.__v_frag = null;
  3440. this.unlink();
  3441. };
  3442. /**
  3443. * Call attach hook for a Vue instance.
  3444. *
  3445. * @param {Vue} child
  3446. */
  3447. function attach(child) {
  3448. if (!child._isAttached && inDoc(child.$el)) {
  3449. child._callHook('attached');
  3450. }
  3451. }
  3452. /**
  3453. * Call detach hook for a Vue instance.
  3454. *
  3455. * @param {Vue} child
  3456. */
  3457. function detach(child) {
  3458. if (child._isAttached && !inDoc(child.$el)) {
  3459. child._callHook('detached');
  3460. }
  3461. }
  3462. var linkerCache = new Cache(5000);
  3463. /**
  3464. * A factory that can be used to create instances of a
  3465. * fragment. Caches the compiled linker if possible.
  3466. *
  3467. * @param {Vue} vm
  3468. * @param {Element|String} el
  3469. */
  3470. function FragmentFactory(vm, el) {
  3471. this.vm = vm;
  3472. var template;
  3473. var isString = typeof el === 'string';
  3474. if (isString || isTemplate(el) && !el.hasAttribute('v-if')) {
  3475. template = parseTemplate(el, true);
  3476. } else {
  3477. template = document.createDocumentFragment();
  3478. template.appendChild(el);
  3479. }
  3480. this.template = template;
  3481. // linker can be cached, but only for components
  3482. var linker;
  3483. var cid = vm.constructor.cid;
  3484. if (cid > 0) {
  3485. var cacheId = cid + (isString ? el : getOuterHTML(el));
  3486. linker = linkerCache.get(cacheId);
  3487. if (!linker) {
  3488. linker = compile(template, vm.$options, true);
  3489. linkerCache.put(cacheId, linker);
  3490. }
  3491. } else {
  3492. linker = compile(template, vm.$options, true);
  3493. }
  3494. this.linker = linker;
  3495. }
  3496. /**
  3497. * Create a fragment instance with given host and scope.
  3498. *
  3499. * @param {Vue} host
  3500. * @param {Object} scope
  3501. * @param {Fragment} parentFrag
  3502. */
  3503. FragmentFactory.prototype.create = function (host, scope, parentFrag) {
  3504. var frag = cloneNode(this.template);
  3505. return new Fragment(this.linker, this.vm, frag, host, scope, parentFrag);
  3506. };
  3507. var ON = 700;
  3508. var MODEL = 800;
  3509. var BIND = 850;
  3510. var TRANSITION = 1100;
  3511. var EL = 1500;
  3512. var COMPONENT = 1500;
  3513. var PARTIAL = 1750;
  3514. var IF = 2100;
  3515. var FOR = 2200;
  3516. var SLOT = 2300;
  3517. var uid$3 = 0;
  3518. var vFor = {
  3519. priority: FOR,
  3520. terminal: true,
  3521. params: ['track-by', 'stagger', 'enter-stagger', 'leave-stagger'],
  3522. bind: function bind() {
  3523. // support "item in/of items" syntax
  3524. var inMatch = this.expression.match(/(.*) (?:in|of) (.*)/);
  3525. if (inMatch) {
  3526. var itMatch = inMatch[1].match(/\((.*),(.*)\)/);
  3527. if (itMatch) {
  3528. this.iterator = itMatch[1].trim();
  3529. this.alias = itMatch[2].trim();
  3530. } else {
  3531. this.alias = inMatch[1].trim();
  3532. }
  3533. this.expression = inMatch[2];
  3534. }
  3535. if (!this.alias) {
  3536. 'development' !== 'production' && warn('Invalid v-for expression "' + this.descriptor.raw + '": ' + 'alias is required.', this.vm);
  3537. return;
  3538. }
  3539. // uid as a cache identifier
  3540. this.id = '__v-for__' + ++uid$3;
  3541. // check if this is an option list,
  3542. // so that we know if we need to update the <select>'s
  3543. // v-model when the option list has changed.
  3544. // because v-model has a lower priority than v-for,
  3545. // the v-model is not bound here yet, so we have to
  3546. // retrive it in the actual updateModel() function.
  3547. var tag = this.el.tagName;
  3548. this.isOption = (tag === 'OPTION' || tag === 'OPTGROUP') && this.el.parentNode.tagName === 'SELECT';
  3549. // setup anchor nodes
  3550. this.start = createAnchor('v-for-start');
  3551. this.end = createAnchor('v-for-end');
  3552. replace(this.el, this.end);
  3553. before(this.start, this.end);
  3554. // cache
  3555. this.cache = Object.create(null);
  3556. // fragment factory
  3557. this.factory = new FragmentFactory(this.vm, this.el);
  3558. },
  3559. update: function update(data) {
  3560. this.diff(data);
  3561. this.updateRef();
  3562. this.updateModel();
  3563. },
  3564. /**
  3565. * Diff, based on new data and old data, determine the
  3566. * minimum amount of DOM manipulations needed to make the
  3567. * DOM reflect the new data Array.
  3568. *
  3569. * The algorithm diffs the new data Array by storing a
  3570. * hidden reference to an owner vm instance on previously
  3571. * seen data. This allows us to achieve O(n) which is
  3572. * better than a levenshtein distance based algorithm,
  3573. * which is O(m * n).
  3574. *
  3575. * @param {Array} data
  3576. */
  3577. diff: function diff(data) {
  3578. // check if the Array was converted from an Object
  3579. var item = data[0];
  3580. var convertedFromObject = this.fromObject = isObject(item) && hasOwn(item, '$key') && hasOwn(item, '$value');
  3581. var trackByKey = this.params.trackBy;
  3582. var oldFrags = this.frags;
  3583. var frags = this.frags = new Array(data.length);
  3584. var alias = this.alias;
  3585. var iterator = this.iterator;
  3586. var start = this.start;
  3587. var end = this.end;
  3588. var inDocument = inDoc(start);
  3589. var init = !oldFrags;
  3590. var i, l, frag, key, value, primitive;
  3591. // First pass, go through the new Array and fill up
  3592. // the new frags array. If a piece of data has a cached
  3593. // instance for it, we reuse it. Otherwise build a new
  3594. // instance.
  3595. for (i = 0, l = data.length; i < l; i++) {
  3596. item = data[i];
  3597. key = convertedFromObject ? item.$key : null;
  3598. value = convertedFromObject ? item.$value : item;
  3599. primitive = !isObject(value);
  3600. frag = !init && this.getCachedFrag(value, i, key);
  3601. if (frag) {
  3602. // reusable fragment
  3603. frag.reused = true;
  3604. // update $index
  3605. frag.scope.$index = i;
  3606. // update $key
  3607. if (key) {
  3608. frag.scope.$key = key;
  3609. }
  3610. // update iterator
  3611. if (iterator) {
  3612. frag.scope[iterator] = key !== null ? key : i;
  3613. }
  3614. // update data for track-by, object repeat &
  3615. // primitive values.
  3616. if (trackByKey || convertedFromObject || primitive) {
  3617. withoutConversion(function () {
  3618. frag.scope[alias] = value;
  3619. });
  3620. }
  3621. } else {
  3622. // new isntance
  3623. frag = this.create(value, alias, i, key);
  3624. frag.fresh = !init;
  3625. }
  3626. frags[i] = frag;
  3627. if (init) {
  3628. frag.before(end);
  3629. }
  3630. }
  3631. // we're done for the initial render.
  3632. if (init) {
  3633. return;
  3634. }
  3635. // Second pass, go through the old fragments and
  3636. // destroy those who are not reused (and remove them
  3637. // from cache)
  3638. var removalIndex = 0;
  3639. var totalRemoved = oldFrags.length - frags.length;
  3640. // when removing a large number of fragments, watcher removal
  3641. // turns out to be a perf bottleneck, so we batch the watcher
  3642. // removals into a single filter call!
  3643. this.vm._vForRemoving = true;
  3644. for (i = 0, l = oldFrags.length; i < l; i++) {
  3645. frag = oldFrags[i];
  3646. if (!frag.reused) {
  3647. this.deleteCachedFrag(frag);
  3648. this.remove(frag, removalIndex++, totalRemoved, inDocument);
  3649. }
  3650. }
  3651. this.vm._vForRemoving = false;
  3652. if (removalIndex) {
  3653. this.vm._watchers = this.vm._watchers.filter(function (w) {
  3654. return w.active;
  3655. });
  3656. }
  3657. // Final pass, move/insert new fragments into the
  3658. // right place.
  3659. var targetPrev, prevEl, currentPrev;
  3660. var insertionIndex = 0;
  3661. for (i = 0, l = frags.length; i < l; i++) {
  3662. frag = frags[i];
  3663. // this is the frag that we should be after
  3664. targetPrev = frags[i - 1];
  3665. prevEl = targetPrev ? targetPrev.staggerCb ? targetPrev.staggerAnchor : targetPrev.end || targetPrev.node : start;
  3666. if (frag.reused && !frag.staggerCb) {
  3667. currentPrev = findPrevFrag(frag, start, this.id);
  3668. if (currentPrev !== targetPrev && (!currentPrev ||
  3669. // optimization for moving a single item.
  3670. // thanks to suggestions by @livoras in #1807
  3671. findPrevFrag(currentPrev, start, this.id) !== targetPrev)) {
  3672. this.move(frag, prevEl);
  3673. }
  3674. } else {
  3675. // new instance, or still in stagger.
  3676. // insert with updated stagger index.
  3677. this.insert(frag, insertionIndex++, prevEl, inDocument);
  3678. }
  3679. frag.reused = frag.fresh = false;
  3680. }
  3681. },
  3682. /**
  3683. * Create a new fragment instance.
  3684. *
  3685. * @param {*} value
  3686. * @param {String} alias
  3687. * @param {Number} index
  3688. * @param {String} [key]
  3689. * @return {Fragment}
  3690. */
  3691. create: function create(value, alias, index, key) {
  3692. var host = this._host;
  3693. // create iteration scope
  3694. var parentScope = this._scope || this.vm;
  3695. var scope = Object.create(parentScope);
  3696. // ref holder for the scope
  3697. scope.$refs = Object.create(parentScope.$refs);
  3698. scope.$els = Object.create(parentScope.$els);
  3699. // make sure point $parent to parent scope
  3700. scope.$parent = parentScope;
  3701. // for two-way binding on alias
  3702. scope.$forContext = this;
  3703. // define scope properties
  3704. // important: define the scope alias without forced conversion
  3705. // so that frozen data structures remain non-reactive.
  3706. withoutConversion(function () {
  3707. defineReactive(scope, alias, value);
  3708. });
  3709. defineReactive(scope, '$index', index);
  3710. if (key) {
  3711. defineReactive(scope, '$key', key);
  3712. } else if (scope.$key) {
  3713. // avoid accidental fallback
  3714. def(scope, '$key', null);
  3715. }
  3716. if (this.iterator) {
  3717. defineReactive(scope, this.iterator, key !== null ? key : index);
  3718. }
  3719. var frag = this.factory.create(host, scope, this._frag);
  3720. frag.forId = this.id;
  3721. this.cacheFrag(value, frag, index, key);
  3722. return frag;
  3723. },
  3724. /**
  3725. * Update the v-ref on owner vm.
  3726. */
  3727. updateRef: function updateRef() {
  3728. var ref = this.descriptor.ref;
  3729. if (!ref) return;
  3730. var hash = (this._scope || this.vm).$refs;
  3731. var refs;
  3732. if (!this.fromObject) {
  3733. refs = this.frags.map(findVmFromFrag);
  3734. } else {
  3735. refs = {};
  3736. this.frags.forEach(function (frag) {
  3737. refs[frag.scope.$key] = findVmFromFrag(frag);
  3738. });
  3739. }
  3740. hash[ref] = refs;
  3741. },
  3742. /**
  3743. * For option lists, update the containing v-model on
  3744. * parent <select>.
  3745. */
  3746. updateModel: function updateModel() {
  3747. if (this.isOption) {
  3748. var parent = this.start.parentNode;
  3749. var model = parent && parent.__v_model;
  3750. if (model) {
  3751. model.forceUpdate();
  3752. }
  3753. }
  3754. },
  3755. /**
  3756. * Insert a fragment. Handles staggering.
  3757. *
  3758. * @param {Fragment} frag
  3759. * @param {Number} index
  3760. * @param {Node} prevEl
  3761. * @param {Boolean} inDocument
  3762. */
  3763. insert: function insert(frag, index, prevEl, inDocument) {
  3764. if (frag.staggerCb) {
  3765. frag.staggerCb.cancel();
  3766. frag.staggerCb = null;
  3767. }
  3768. var staggerAmount = this.getStagger(frag, index, null, 'enter');
  3769. if (inDocument && staggerAmount) {
  3770. // create an anchor and insert it synchronously,
  3771. // so that we can resolve the correct order without
  3772. // worrying about some elements not inserted yet
  3773. var anchor = frag.staggerAnchor;
  3774. if (!anchor) {
  3775. anchor = frag.staggerAnchor = createAnchor('stagger-anchor');
  3776. anchor.__v_frag = frag;
  3777. }
  3778. after(anchor, prevEl);
  3779. var op = frag.staggerCb = cancellable(function () {
  3780. frag.staggerCb = null;
  3781. frag.before(anchor);
  3782. remove(anchor);
  3783. });
  3784. setTimeout(op, staggerAmount);
  3785. } else {
  3786. var target = prevEl.nextSibling;
  3787. /* istanbul ignore if */
  3788. if (!target) {
  3789. // reset end anchor position in case the position was messed up
  3790. // by an external drag-n-drop library.
  3791. after(this.end, prevEl);
  3792. target = this.end;
  3793. }
  3794. frag.before(target);
  3795. }
  3796. },
  3797. /**
  3798. * Remove a fragment. Handles staggering.
  3799. *
  3800. * @param {Fragment} frag
  3801. * @param {Number} index
  3802. * @param {Number} total
  3803. * @param {Boolean} inDocument
  3804. */
  3805. remove: function remove(frag, index, total, inDocument) {
  3806. if (frag.staggerCb) {
  3807. frag.staggerCb.cancel();
  3808. frag.staggerCb = null;
  3809. // it's not possible for the same frag to be removed
  3810. // twice, so if we have a pending stagger callback,
  3811. // it means this frag is queued for enter but removed
  3812. // before its transition started. Since it is already
  3813. // destroyed, we can just leave it in detached state.
  3814. return;
  3815. }
  3816. var staggerAmount = this.getStagger(frag, index, total, 'leave');
  3817. if (inDocument && staggerAmount) {
  3818. var op = frag.staggerCb = cancellable(function () {
  3819. frag.staggerCb = null;
  3820. frag.remove();
  3821. });
  3822. setTimeout(op, staggerAmount);
  3823. } else {
  3824. frag.remove();
  3825. }
  3826. },
  3827. /**
  3828. * Move a fragment to a new position.
  3829. * Force no transition.
  3830. *
  3831. * @param {Fragment} frag
  3832. * @param {Node} prevEl
  3833. */
  3834. move: function move(frag, prevEl) {
  3835. // fix a common issue with Sortable:
  3836. // if prevEl doesn't have nextSibling, this means it's
  3837. // been dragged after the end anchor. Just re-position
  3838. // the end anchor to the end of the container.
  3839. /* istanbul ignore if */
  3840. if (!prevEl.nextSibling) {
  3841. this.end.parentNode.appendChild(this.end);
  3842. }
  3843. frag.before(prevEl.nextSibling, false);
  3844. },
  3845. /**
  3846. * Cache a fragment using track-by or the object key.
  3847. *
  3848. * @param {*} value
  3849. * @param {Fragment} frag
  3850. * @param {Number} index
  3851. * @param {String} [key]
  3852. */
  3853. cacheFrag: function cacheFrag(value, frag, index, key) {
  3854. var trackByKey = this.params.trackBy;
  3855. var cache = this.cache;
  3856. var primitive = !isObject(value);
  3857. var id;
  3858. if (key || trackByKey || primitive) {
  3859. id = getTrackByKey(index, key, value, trackByKey);
  3860. if (!cache[id]) {
  3861. cache[id] = frag;
  3862. } else if (trackByKey !== '$index') {
  3863. 'development' !== 'production' && this.warnDuplicate(value);
  3864. }
  3865. } else {
  3866. id = this.id;
  3867. if (hasOwn(value, id)) {
  3868. if (value[id] === null) {
  3869. value[id] = frag;
  3870. } else {
  3871. 'development' !== 'production' && this.warnDuplicate(value);
  3872. }
  3873. } else if (Object.isExtensible(value)) {
  3874. def(value, id, frag);
  3875. } else if ('development' !== 'production') {
  3876. warn('Frozen v-for objects cannot be automatically tracked, make sure to ' + 'provide a track-by key.');
  3877. }
  3878. }
  3879. frag.raw = value;
  3880. },
  3881. /**
  3882. * Get a cached fragment from the value/index/key
  3883. *
  3884. * @param {*} value
  3885. * @param {Number} index
  3886. * @param {String} key
  3887. * @return {Fragment}
  3888. */
  3889. getCachedFrag: function getCachedFrag(value, index, key) {
  3890. var trackByKey = this.params.trackBy;
  3891. var primitive = !isObject(value);
  3892. var frag;
  3893. if (key || trackByKey || primitive) {
  3894. var id = getTrackByKey(index, key, value, trackByKey);
  3895. frag = this.cache[id];
  3896. } else {
  3897. frag = value[this.id];
  3898. }
  3899. if (frag && (frag.reused || frag.fresh)) {
  3900. 'development' !== 'production' && this.warnDuplicate(value);
  3901. }
  3902. return frag;
  3903. },
  3904. /**
  3905. * Delete a fragment from cache.
  3906. *
  3907. * @param {Fragment} frag
  3908. */
  3909. deleteCachedFrag: function deleteCachedFrag(frag) {
  3910. var value = frag.raw;
  3911. var trackByKey = this.params.trackBy;
  3912. var scope = frag.scope;
  3913. var index = scope.$index;
  3914. // fix #948: avoid accidentally fall through to
  3915. // a parent repeater which happens to have $key.
  3916. var key = hasOwn(scope, '$key') && scope.$key;
  3917. var primitive = !isObject(value);
  3918. if (trackByKey || key || primitive) {
  3919. var id = getTrackByKey(index, key, value, trackByKey);
  3920. this.cache[id] = null;
  3921. } else {
  3922. value[this.id] = null;
  3923. frag.raw = null;
  3924. }
  3925. },
  3926. /**
  3927. * Get the stagger amount for an insertion/removal.
  3928. *
  3929. * @param {Fragment} frag
  3930. * @param {Number} index
  3931. * @param {Number} total
  3932. * @param {String} type
  3933. */
  3934. getStagger: function getStagger(frag, index, total, type) {
  3935. type = type + 'Stagger';
  3936. var trans = frag.node.__v_trans;
  3937. var hooks = trans && trans.hooks;
  3938. var hook = hooks && (hooks[type] || hooks.stagger);
  3939. return hook ? hook.call(frag, index, total) : index * parseInt(this.params[type] || this.params.stagger, 10);
  3940. },
  3941. /**
  3942. * Pre-process the value before piping it through the
  3943. * filters. This is passed to and called by the watcher.
  3944. */
  3945. _preProcess: function _preProcess(value) {
  3946. // regardless of type, store the un-filtered raw value.
  3947. this.rawValue = value;
  3948. return value;
  3949. },
  3950. /**
  3951. * Post-process the value after it has been piped through
  3952. * the filters. This is passed to and called by the watcher.
  3953. *
  3954. * It is necessary for this to be called during the
  3955. * wathcer's dependency collection phase because we want
  3956. * the v-for to update when the source Object is mutated.
  3957. */
  3958. _postProcess: function _postProcess(value) {
  3959. if (isArray(value)) {
  3960. return value;
  3961. } else if (isPlainObject(value)) {
  3962. // convert plain object to array.
  3963. var keys = Object.keys(value);
  3964. var i = keys.length;
  3965. var res = new Array(i);
  3966. var key;
  3967. while (i--) {
  3968. key = keys[i];
  3969. res[i] = {
  3970. $key: key,
  3971. $value: value[key]
  3972. };
  3973. }
  3974. return res;
  3975. } else {
  3976. if (typeof value === 'number' && !isNaN(value)) {
  3977. value = range(value);
  3978. }
  3979. return value || [];
  3980. }
  3981. },
  3982. unbind: function unbind() {
  3983. if (this.descriptor.ref) {
  3984. (this._scope || this.vm).$refs[this.descriptor.ref] = null;
  3985. }
  3986. if (this.frags) {
  3987. var i = this.frags.length;
  3988. var frag;
  3989. while (i--) {
  3990. frag = this.frags[i];
  3991. this.deleteCachedFrag(frag);
  3992. frag.destroy();
  3993. }
  3994. }
  3995. }
  3996. };
  3997. /**
  3998. * Helper to find the previous element that is a fragment
  3999. * anchor. This is necessary because a destroyed frag's
  4000. * element could still be lingering in the DOM before its
  4001. * leaving transition finishes, but its inserted flag
  4002. * should have been set to false so we can skip them.
  4003. *
  4004. * If this is a block repeat, we want to make sure we only
  4005. * return frag that is bound to this v-for. (see #929)
  4006. *
  4007. * @param {Fragment} frag
  4008. * @param {Comment|Text} anchor
  4009. * @param {String} id
  4010. * @return {Fragment}
  4011. */
  4012. function findPrevFrag(frag, anchor, id) {
  4013. var el = frag.node.previousSibling;
  4014. /* istanbul ignore if */
  4015. if (!el) return;
  4016. frag = el.__v_frag;
  4017. while ((!frag || frag.forId !== id || !frag.inserted) && el !== anchor) {
  4018. el = el.previousSibling;
  4019. /* istanbul ignore if */
  4020. if (!el) return;
  4021. frag = el.__v_frag;
  4022. }
  4023. return frag;
  4024. }
  4025. /**
  4026. * Find a vm from a fragment.
  4027. *
  4028. * @param {Fragment} frag
  4029. * @return {Vue|undefined}
  4030. */
  4031. function findVmFromFrag(frag) {
  4032. var node = frag.node;
  4033. // handle multi-node frag
  4034. if (frag.end) {
  4035. while (!node.__vue__ && node !== frag.end && node.nextSibling) {
  4036. node = node.nextSibling;
  4037. }
  4038. }
  4039. return node.__vue__;
  4040. }
  4041. /**
  4042. * Create a range array from given number.
  4043. *
  4044. * @param {Number} n
  4045. * @return {Array}
  4046. */
  4047. function range(n) {
  4048. var i = -1;
  4049. var ret = new Array(Math.floor(n));
  4050. while (++i < n) {
  4051. ret[i] = i;
  4052. }
  4053. return ret;
  4054. }
  4055. /**
  4056. * Get the track by key for an item.
  4057. *
  4058. * @param {Number} index
  4059. * @param {String} key
  4060. * @param {*} value
  4061. * @param {String} [trackByKey]
  4062. */
  4063. function getTrackByKey(index, key, value, trackByKey) {
  4064. return trackByKey ? trackByKey === '$index' ? index : trackByKey.charAt(0).match(/\w/) ? getPath(value, trackByKey) : value[trackByKey] : key || value;
  4065. }
  4066. if ('development' !== 'production') {
  4067. vFor.warnDuplicate = function (value) {
  4068. warn('Duplicate value found in v-for="' + this.descriptor.raw + '": ' + JSON.stringify(value) + '. Use track-by="$index" if ' + 'you are expecting duplicate values.', this.vm);
  4069. };
  4070. }
  4071. var vIf = {
  4072. priority: IF,
  4073. terminal: true,
  4074. bind: function bind() {
  4075. var el = this.el;
  4076. if (!el.__vue__) {
  4077. // check else block
  4078. var next = el.nextElementSibling;
  4079. if (next && getAttr(next, 'v-else') !== null) {
  4080. remove(next);
  4081. this.elseEl = next;
  4082. }
  4083. // check main block
  4084. this.anchor = createAnchor('v-if');
  4085. replace(el, this.anchor);
  4086. } else {
  4087. 'development' !== 'production' && warn('v-if="' + this.expression + '" cannot be ' + 'used on an instance root element.', this.vm);
  4088. this.invalid = true;
  4089. }
  4090. },
  4091. update: function update(value) {
  4092. if (this.invalid) return;
  4093. if (value) {
  4094. if (!this.frag) {
  4095. this.insert();
  4096. }
  4097. } else {
  4098. this.remove();
  4099. }
  4100. },
  4101. insert: function insert() {
  4102. if (this.elseFrag) {
  4103. this.elseFrag.remove();
  4104. this.elseFrag = null;
  4105. }
  4106. // lazy init factory
  4107. if (!this.factory) {
  4108. this.factory = new FragmentFactory(this.vm, this.el);
  4109. }
  4110. this.frag = this.factory.create(this._host, this._scope, this._frag);
  4111. this.frag.before(this.anchor);
  4112. },
  4113. remove: function remove() {
  4114. if (this.frag) {
  4115. this.frag.remove();
  4116. this.frag = null;
  4117. }
  4118. if (this.elseEl && !this.elseFrag) {
  4119. if (!this.elseFactory) {
  4120. this.elseFactory = new FragmentFactory(this.elseEl._context || this.vm, this.elseEl);
  4121. }
  4122. this.elseFrag = this.elseFactory.create(this._host, this._scope, this._frag);
  4123. this.elseFrag.before(this.anchor);
  4124. }
  4125. },
  4126. unbind: function unbind() {
  4127. if (this.frag) {
  4128. this.frag.destroy();
  4129. }
  4130. if (this.elseFrag) {
  4131. this.elseFrag.destroy();
  4132. }
  4133. }
  4134. };
  4135. var show = {
  4136. bind: function bind() {
  4137. // check else block
  4138. var next = this.el.nextElementSibling;
  4139. if (next && getAttr(next, 'v-else') !== null) {
  4140. this.elseEl = next;
  4141. }
  4142. },
  4143. update: function update(value) {
  4144. this.apply(this.el, value);
  4145. if (this.elseEl) {
  4146. this.apply(this.elseEl, !value);
  4147. }
  4148. },
  4149. apply: function apply(el, value) {
  4150. if (inDoc(el)) {
  4151. applyTransition(el, value ? 1 : -1, toggle, this.vm);
  4152. } else {
  4153. toggle();
  4154. }
  4155. function toggle() {
  4156. el.style.display = value ? '' : 'none';
  4157. }
  4158. }
  4159. };
  4160. var text$2 = {
  4161. bind: function bind() {
  4162. var self = this;
  4163. var el = this.el;
  4164. var isRange = el.type === 'range';
  4165. var lazy = this.params.lazy;
  4166. var number = this.params.number;
  4167. var debounce = this.params.debounce;
  4168. // handle composition events.
  4169. // http://blog.evanyou.me/2014/01/03/composition-event/
  4170. // skip this for Android because it handles composition
  4171. // events quite differently. Android doesn't trigger
  4172. // composition events for language input methods e.g.
  4173. // Chinese, but instead triggers them for spelling
  4174. // suggestions... (see Discussion/#162)
  4175. var composing = false;
  4176. if (!isAndroid && !isRange) {
  4177. this.on('compositionstart', function () {
  4178. composing = true;
  4179. });
  4180. this.on('compositionend', function () {
  4181. composing = false;
  4182. // in IE11 the "compositionend" event fires AFTER
  4183. // the "input" event, so the input handler is blocked
  4184. // at the end... have to call it here.
  4185. //
  4186. // #1327: in lazy mode this is unecessary.
  4187. if (!lazy) {
  4188. self.listener();
  4189. }
  4190. });
  4191. }
  4192. // prevent messing with the input when user is typing,
  4193. // and force update on blur.
  4194. this.focused = false;
  4195. if (!isRange && !lazy) {
  4196. this.on('focus', function () {
  4197. self.focused = true;
  4198. });
  4199. this.on('blur', function () {
  4200. self.focused = false;
  4201. // do not sync value after fragment removal (#2017)
  4202. if (!self._frag || self._frag.inserted) {
  4203. self.rawListener();
  4204. }
  4205. });
  4206. }
  4207. // Now attach the main listener
  4208. this.listener = this.rawListener = function () {
  4209. if (composing || !self._bound) {
  4210. return;
  4211. }
  4212. var val = number || isRange ? toNumber(el.value) : el.value;
  4213. self.set(val);
  4214. // force update on next tick to avoid lock & same value
  4215. // also only update when user is not typing
  4216. nextTick(function () {
  4217. if (self._bound && !self.focused) {
  4218. self.update(self._watcher.value);
  4219. }
  4220. });
  4221. };
  4222. // apply debounce
  4223. if (debounce) {
  4224. this.listener = _debounce(this.listener, debounce);
  4225. }
  4226. // Support jQuery events, since jQuery.trigger() doesn't
  4227. // trigger native events in some cases and some plugins
  4228. // rely on $.trigger()
  4229. //
  4230. // We want to make sure if a listener is attached using
  4231. // jQuery, it is also removed with jQuery, that's why
  4232. // we do the check for each directive instance and
  4233. // store that check result on itself. This also allows
  4234. // easier test coverage control by unsetting the global
  4235. // jQuery variable in tests.
  4236. this.hasjQuery = typeof jQuery === 'function';
  4237. if (this.hasjQuery) {
  4238. var method = jQuery.fn.on ? 'on' : 'bind';
  4239. jQuery(el)[method]('change', this.rawListener);
  4240. if (!lazy) {
  4241. jQuery(el)[method]('input', this.listener);
  4242. }
  4243. } else {
  4244. this.on('change', this.rawListener);
  4245. if (!lazy) {
  4246. this.on('input', this.listener);
  4247. }
  4248. }
  4249. // IE9 doesn't fire input event on backspace/del/cut
  4250. if (!lazy && isIE9) {
  4251. this.on('cut', function () {
  4252. nextTick(self.listener);
  4253. });
  4254. this.on('keyup', function (e) {
  4255. if (e.keyCode === 46 || e.keyCode === 8) {
  4256. self.listener();
  4257. }
  4258. });
  4259. }
  4260. // set initial value if present
  4261. if (el.hasAttribute('value') || el.tagName === 'TEXTAREA' && el.value.trim()) {
  4262. this.afterBind = this.listener;
  4263. }
  4264. },
  4265. update: function update(value) {
  4266. this.el.value = _toString(value);
  4267. },
  4268. unbind: function unbind() {
  4269. var el = this.el;
  4270. if (this.hasjQuery) {
  4271. var method = jQuery.fn.off ? 'off' : 'unbind';
  4272. jQuery(el)[method]('change', this.listener);
  4273. jQuery(el)[method]('input', this.listener);
  4274. }
  4275. }
  4276. };
  4277. var radio = {
  4278. bind: function bind() {
  4279. var self = this;
  4280. var el = this.el;
  4281. this.getValue = function () {
  4282. // value overwrite via v-bind:value
  4283. if (el.hasOwnProperty('_value')) {
  4284. return el._value;
  4285. }
  4286. var val = el.value;
  4287. if (self.params.number) {
  4288. val = toNumber(val);
  4289. }
  4290. return val;
  4291. };
  4292. this.listener = function () {
  4293. self.set(self.getValue());
  4294. };
  4295. this.on('change', this.listener);
  4296. if (el.hasAttribute('checked')) {
  4297. this.afterBind = this.listener;
  4298. }
  4299. },
  4300. update: function update(value) {
  4301. this.el.checked = looseEqual(value, this.getValue());
  4302. }
  4303. };
  4304. var select = {
  4305. bind: function bind() {
  4306. var self = this;
  4307. var el = this.el;
  4308. // method to force update DOM using latest value.
  4309. this.forceUpdate = function () {
  4310. if (self._watcher) {
  4311. self.update(self._watcher.get());
  4312. }
  4313. };
  4314. // check if this is a multiple select
  4315. var multiple = this.multiple = el.hasAttribute('multiple');
  4316. // attach listener
  4317. this.listener = function () {
  4318. var value = getValue(el, multiple);
  4319. value = self.params.number ? isArray(value) ? value.map(toNumber) : toNumber(value) : value;
  4320. self.set(value);
  4321. };
  4322. this.on('change', this.listener);
  4323. // if has initial value, set afterBind
  4324. var initValue = getValue(el, multiple, true);
  4325. if (multiple && initValue.length || !multiple && initValue !== null) {
  4326. this.afterBind = this.listener;
  4327. }
  4328. // All major browsers except Firefox resets
  4329. // selectedIndex with value -1 to 0 when the element
  4330. // is appended to a new parent, therefore we have to
  4331. // force a DOM update whenever that happens...
  4332. this.vm.$on('hook:attached', this.forceUpdate);
  4333. },
  4334. update: function update(value) {
  4335. var el = this.el;
  4336. el.selectedIndex = -1;
  4337. var multi = this.multiple && isArray(value);
  4338. var options = el.options;
  4339. var i = options.length;
  4340. var op, val;
  4341. while (i--) {
  4342. op = options[i];
  4343. val = op.hasOwnProperty('_value') ? op._value : op.value;
  4344. /* eslint-disable eqeqeq */
  4345. op.selected = multi ? indexOf$1(value, val) > -1 : looseEqual(value, val);
  4346. /* eslint-enable eqeqeq */
  4347. }
  4348. },
  4349. unbind: function unbind() {
  4350. /* istanbul ignore next */
  4351. this.vm.$off('hook:attached', this.forceUpdate);
  4352. }
  4353. };
  4354. /**
  4355. * Get select value
  4356. *
  4357. * @param {SelectElement} el
  4358. * @param {Boolean} multi
  4359. * @param {Boolean} init
  4360. * @return {Array|*}
  4361. */
  4362. function getValue(el, multi, init) {
  4363. var res = multi ? [] : null;
  4364. var op, val, selected;
  4365. for (var i = 0, l = el.options.length; i < l; i++) {
  4366. op = el.options[i];
  4367. selected = init ? op.hasAttribute('selected') : op.selected;
  4368. if (selected) {
  4369. val = op.hasOwnProperty('_value') ? op._value : op.value;
  4370. if (multi) {
  4371. res.push(val);
  4372. } else {
  4373. return val;
  4374. }
  4375. }
  4376. }
  4377. return res;
  4378. }
  4379. /**
  4380. * Native Array.indexOf uses strict equal, but in this
  4381. * case we need to match string/numbers with custom equal.
  4382. *
  4383. * @param {Array} arr
  4384. * @param {*} val
  4385. */
  4386. function indexOf$1(arr, val) {
  4387. var i = arr.length;
  4388. while (i--) {
  4389. if (looseEqual(arr[i], val)) {
  4390. return i;
  4391. }
  4392. }
  4393. return -1;
  4394. }
  4395. var checkbox = {
  4396. bind: function bind() {
  4397. var self = this;
  4398. var el = this.el;
  4399. this.getValue = function () {
  4400. return el.hasOwnProperty('_value') ? el._value : self.params.number ? toNumber(el.value) : el.value;
  4401. };
  4402. function getBooleanValue() {
  4403. var val = el.checked;
  4404. if (val && el.hasOwnProperty('_trueValue')) {
  4405. return el._trueValue;
  4406. }
  4407. if (!val && el.hasOwnProperty('_falseValue')) {
  4408. return el._falseValue;
  4409. }
  4410. return val;
  4411. }
  4412. this.listener = function () {
  4413. var model = self._watcher.value;
  4414. if (isArray(model)) {
  4415. var val = self.getValue();
  4416. if (el.checked) {
  4417. if (indexOf(model, val) < 0) {
  4418. model.push(val);
  4419. }
  4420. } else {
  4421. model.$remove(val);
  4422. }
  4423. } else {
  4424. self.set(getBooleanValue());
  4425. }
  4426. };
  4427. this.on('change', this.listener);
  4428. if (el.hasAttribute('checked')) {
  4429. this.afterBind = this.listener;
  4430. }
  4431. },
  4432. update: function update(value) {
  4433. var el = this.el;
  4434. if (isArray(value)) {
  4435. el.checked = indexOf(value, this.getValue()) > -1;
  4436. } else {
  4437. if (el.hasOwnProperty('_trueValue')) {
  4438. el.checked = looseEqual(value, el._trueValue);
  4439. } else {
  4440. el.checked = !!value;
  4441. }
  4442. }
  4443. }
  4444. };
  4445. var handlers = {
  4446. text: text$2,
  4447. radio: radio,
  4448. select: select,
  4449. checkbox: checkbox
  4450. };
  4451. var model = {
  4452. priority: MODEL,
  4453. twoWay: true,
  4454. handlers: handlers,
  4455. params: ['lazy', 'number', 'debounce'],
  4456. /**
  4457. * Possible elements:
  4458. * <select>
  4459. * <textarea>
  4460. * <input type="*">
  4461. * - text
  4462. * - checkbox
  4463. * - radio
  4464. * - number
  4465. */
  4466. bind: function bind() {
  4467. // friendly warning...
  4468. this.checkFilters();
  4469. if (this.hasRead && !this.hasWrite) {
  4470. 'development' !== 'production' && warn('It seems you are using a read-only filter with ' + 'v-model="' + this.descriptor.raw + '". ' + 'You might want to use a two-way filter to ensure correct behavior.', this.vm);
  4471. }
  4472. var el = this.el;
  4473. var tag = el.tagName;
  4474. var handler;
  4475. if (tag === 'INPUT') {
  4476. handler = handlers[el.type] || handlers.text;
  4477. } else if (tag === 'SELECT') {
  4478. handler = handlers.select;
  4479. } else if (tag === 'TEXTAREA') {
  4480. handler = handlers.text;
  4481. } else {
  4482. 'development' !== 'production' && warn('v-model does not support element type: ' + tag, this.vm);
  4483. return;
  4484. }
  4485. el.__v_model = this;
  4486. handler.bind.call(this);
  4487. this.update = handler.update;
  4488. this._unbind = handler.unbind;
  4489. },
  4490. /**
  4491. * Check read/write filter stats.
  4492. */
  4493. checkFilters: function checkFilters() {
  4494. var filters = this.filters;
  4495. if (!filters) return;
  4496. var i = filters.length;
  4497. while (i--) {
  4498. var filter = resolveAsset(this.vm.$options, 'filters', filters[i].name);
  4499. if (typeof filter === 'function' || filter.read) {
  4500. this.hasRead = true;
  4501. }
  4502. if (filter.write) {
  4503. this.hasWrite = true;
  4504. }
  4505. }
  4506. },
  4507. unbind: function unbind() {
  4508. this.el.__v_model = null;
  4509. this._unbind && this._unbind();
  4510. }
  4511. };
  4512. // keyCode aliases
  4513. var keyCodes = {
  4514. esc: 27,
  4515. tab: 9,
  4516. enter: 13,
  4517. space: 32,
  4518. 'delete': [8, 46],
  4519. up: 38,
  4520. left: 37,
  4521. right: 39,
  4522. down: 40
  4523. };
  4524. function keyFilter(handler, keys) {
  4525. var codes = keys.map(function (key) {
  4526. var charCode = key.charCodeAt(0);
  4527. if (charCode > 47 && charCode < 58) {
  4528. return parseInt(key, 10);
  4529. }
  4530. if (key.length === 1) {
  4531. charCode = key.toUpperCase().charCodeAt(0);
  4532. if (charCode > 64 && charCode < 91) {
  4533. return charCode;
  4534. }
  4535. }
  4536. return keyCodes[key];
  4537. });
  4538. codes = [].concat.apply([], codes);
  4539. return function keyHandler(e) {
  4540. if (codes.indexOf(e.keyCode) > -1) {
  4541. return handler.call(this, e);
  4542. }
  4543. };
  4544. }
  4545. function stopFilter(handler) {
  4546. return function stopHandler(e) {
  4547. e.stopPropagation();
  4548. return handler.call(this, e);
  4549. };
  4550. }
  4551. function preventFilter(handler) {
  4552. return function preventHandler(e) {
  4553. e.preventDefault();
  4554. return handler.call(this, e);
  4555. };
  4556. }
  4557. function selfFilter(handler) {
  4558. return function selfHandler(e) {
  4559. if (e.target === e.currentTarget) {
  4560. return handler.call(this, e);
  4561. }
  4562. };
  4563. }
  4564. var on$1 = {
  4565. priority: ON,
  4566. acceptStatement: true,
  4567. keyCodes: keyCodes,
  4568. bind: function bind() {
  4569. // deal with iframes
  4570. if (this.el.tagName === 'IFRAME' && this.arg !== 'load') {
  4571. var self = this;
  4572. this.iframeBind = function () {
  4573. on(self.el.contentWindow, self.arg, self.handler, self.modifiers.capture);
  4574. };
  4575. this.on('load', this.iframeBind);
  4576. }
  4577. },
  4578. update: function update(handler) {
  4579. // stub a noop for v-on with no value,
  4580. // e.g. @mousedown.prevent
  4581. if (!this.descriptor.raw) {
  4582. handler = function () {};
  4583. }
  4584. if (typeof handler !== 'function') {
  4585. 'development' !== 'production' && warn('v-on:' + this.arg + '="' + this.expression + '" expects a function value, ' + 'got ' + handler, this.vm);
  4586. return;
  4587. }
  4588. // apply modifiers
  4589. if (this.modifiers.stop) {
  4590. handler = stopFilter(handler);
  4591. }
  4592. if (this.modifiers.prevent) {
  4593. handler = preventFilter(handler);
  4594. }
  4595. if (this.modifiers.self) {
  4596. handler = selfFilter(handler);
  4597. }
  4598. // key filter
  4599. var keys = Object.keys(this.modifiers).filter(function (key) {
  4600. return key !== 'stop' && key !== 'prevent' && key !== 'self' && key !== 'capture';
  4601. });
  4602. if (keys.length) {
  4603. handler = keyFilter(handler, keys);
  4604. }
  4605. this.reset();
  4606. this.handler = handler;
  4607. if (this.iframeBind) {
  4608. this.iframeBind();
  4609. } else {
  4610. on(this.el, this.arg, this.handler, this.modifiers.capture);
  4611. }
  4612. },
  4613. reset: function reset() {
  4614. var el = this.iframeBind ? this.el.contentWindow : this.el;
  4615. if (this.handler) {
  4616. off(el, this.arg, this.handler);
  4617. }
  4618. },
  4619. unbind: function unbind() {
  4620. this.reset();
  4621. }
  4622. };
  4623. var prefixes = ['-webkit-', '-moz-', '-ms-'];
  4624. var camelPrefixes = ['Webkit', 'Moz', 'ms'];
  4625. var importantRE = /!important;?$/;
  4626. var propCache = Object.create(null);
  4627. var testEl = null;
  4628. var style = {
  4629. deep: true,
  4630. update: function update(value) {
  4631. if (typeof value === 'string') {
  4632. this.el.style.cssText = value;
  4633. } else if (isArray(value)) {
  4634. this.handleObject(value.reduce(extend, {}));
  4635. } else {
  4636. this.handleObject(value || {});
  4637. }
  4638. },
  4639. handleObject: function handleObject(value) {
  4640. // cache object styles so that only changed props
  4641. // are actually updated.
  4642. var cache = this.cache || (this.cache = {});
  4643. var name, val;
  4644. for (name in cache) {
  4645. if (!(name in value)) {
  4646. this.handleSingle(name, null);
  4647. delete cache[name];
  4648. }
  4649. }
  4650. for (name in value) {
  4651. val = value[name];
  4652. if (val !== cache[name]) {
  4653. cache[name] = val;
  4654. this.handleSingle(name, val);
  4655. }
  4656. }
  4657. },
  4658. handleSingle: function handleSingle(prop, value) {
  4659. prop = normalize(prop);
  4660. if (!prop) return; // unsupported prop
  4661. // cast possible numbers/booleans into strings
  4662. if (value != null) value += '';
  4663. if (value) {
  4664. var isImportant = importantRE.test(value) ? 'important' : '';
  4665. if (isImportant) {
  4666. /* istanbul ignore if */
  4667. if ('development' !== 'production') {
  4668. warn('It\'s probably a bad idea to use !important with inline rules. ' + 'This feature will be deprecated in a future version of Vue.');
  4669. }
  4670. value = value.replace(importantRE, '').trim();
  4671. this.el.style.setProperty(prop.kebab, value, isImportant);
  4672. } else {
  4673. this.el.style[prop.camel] = value;
  4674. }
  4675. } else {
  4676. this.el.style[prop.camel] = '';
  4677. }
  4678. }
  4679. };
  4680. /**
  4681. * Normalize a CSS property name.
  4682. * - cache result
  4683. * - auto prefix
  4684. * - camelCase -> dash-case
  4685. *
  4686. * @param {String} prop
  4687. * @return {String}
  4688. */
  4689. function normalize(prop) {
  4690. if (propCache[prop]) {
  4691. return propCache[prop];
  4692. }
  4693. var res = prefix(prop);
  4694. propCache[prop] = propCache[res] = res;
  4695. return res;
  4696. }
  4697. /**
  4698. * Auto detect the appropriate prefix for a CSS property.
  4699. * https://gist.github.com/paulirish/523692
  4700. *
  4701. * @param {String} prop
  4702. * @return {String}
  4703. */
  4704. function prefix(prop) {
  4705. prop = hyphenate(prop);
  4706. var camel = camelize(prop);
  4707. var upper = camel.charAt(0).toUpperCase() + camel.slice(1);
  4708. if (!testEl) {
  4709. testEl = document.createElement('div');
  4710. }
  4711. var i = prefixes.length;
  4712. var prefixed;
  4713. if (camel !== 'filter' && camel in testEl.style) {
  4714. return {
  4715. kebab: prop,
  4716. camel: camel
  4717. };
  4718. }
  4719. while (i--) {
  4720. prefixed = camelPrefixes[i] + upper;
  4721. if (prefixed in testEl.style) {
  4722. return {
  4723. kebab: prefixes[i] + prop,
  4724. camel: prefixed
  4725. };
  4726. }
  4727. }
  4728. }
  4729. // xlink
  4730. var xlinkNS = 'http://www.w3.org/1999/xlink';
  4731. var xlinkRE = /^xlink:/;
  4732. // check for attributes that prohibit interpolations
  4733. var disallowedInterpAttrRE = /^v-|^:|^@|^(?:is|transition|transition-mode|debounce|track-by|stagger|enter-stagger|leave-stagger)$/;
  4734. // these attributes should also set their corresponding properties
  4735. // because they only affect the initial state of the element
  4736. var attrWithPropsRE = /^(?:value|checked|selected|muted)$/;
  4737. // these attributes expect enumrated values of "true" or "false"
  4738. // but are not boolean attributes
  4739. var enumeratedAttrRE = /^(?:draggable|contenteditable|spellcheck)$/;
  4740. // these attributes should set a hidden property for
  4741. // binding v-model to object values
  4742. var modelProps = {
  4743. value: '_value',
  4744. 'true-value': '_trueValue',
  4745. 'false-value': '_falseValue'
  4746. };
  4747. var bind$1 = {
  4748. priority: BIND,
  4749. bind: function bind() {
  4750. var attr = this.arg;
  4751. var tag = this.el.tagName;
  4752. // should be deep watch on object mode
  4753. if (!attr) {
  4754. this.deep = true;
  4755. }
  4756. // handle interpolation bindings
  4757. var descriptor = this.descriptor;
  4758. var tokens = descriptor.interp;
  4759. if (tokens) {
  4760. // handle interpolations with one-time tokens
  4761. if (descriptor.hasOneTime) {
  4762. this.expression = tokensToExp(tokens, this._scope || this.vm);
  4763. }
  4764. // only allow binding on native attributes
  4765. if (disallowedInterpAttrRE.test(attr) || attr === 'name' && (tag === 'PARTIAL' || tag === 'SLOT')) {
  4766. 'development' !== 'production' && warn(attr + '="' + descriptor.raw + '": ' + 'attribute interpolation is not allowed in Vue.js ' + 'directives and special attributes.', this.vm);
  4767. this.el.removeAttribute(attr);
  4768. this.invalid = true;
  4769. }
  4770. /* istanbul ignore if */
  4771. if ('development' !== 'production') {
  4772. var raw = attr + '="' + descriptor.raw + '": ';
  4773. // warn src
  4774. if (attr === 'src') {
  4775. warn(raw + 'interpolation in "src" attribute will cause ' + 'a 404 request. Use v-bind:src instead.', this.vm);
  4776. }
  4777. // warn style
  4778. if (attr === 'style') {
  4779. warn(raw + 'interpolation in "style" attribute will cause ' + 'the attribute to be discarded in Internet Explorer. ' + 'Use v-bind:style instead.', this.vm);
  4780. }
  4781. }
  4782. }
  4783. },
  4784. update: function update(value) {
  4785. if (this.invalid) {
  4786. return;
  4787. }
  4788. var attr = this.arg;
  4789. if (this.arg) {
  4790. this.handleSingle(attr, value);
  4791. } else {
  4792. this.handleObject(value || {});
  4793. }
  4794. },
  4795. // share object handler with v-bind:class
  4796. handleObject: style.handleObject,
  4797. handleSingle: function handleSingle(attr, value) {
  4798. var el = this.el;
  4799. var interp = this.descriptor.interp;
  4800. if (this.modifiers.camel) {
  4801. attr = camelize(attr);
  4802. }
  4803. if (!interp && attrWithPropsRE.test(attr) && attr in el) {
  4804. var attrValue = attr === 'value' ? value == null // IE9 will set input.value to "null" for null...
  4805. ? '' : value : value;
  4806. if (el[attr] !== attrValue) {
  4807. el[attr] = attrValue;
  4808. }
  4809. }
  4810. // set model props
  4811. var modelProp = modelProps[attr];
  4812. if (!interp && modelProp) {
  4813. el[modelProp] = value;
  4814. // update v-model if present
  4815. var model = el.__v_model;
  4816. if (model) {
  4817. model.listener();
  4818. }
  4819. }
  4820. // do not set value attribute for textarea
  4821. if (attr === 'value' && el.tagName === 'TEXTAREA') {
  4822. el.removeAttribute(attr);
  4823. return;
  4824. }
  4825. // update attribute
  4826. if (enumeratedAttrRE.test(attr)) {
  4827. el.setAttribute(attr, value ? 'true' : 'false');
  4828. } else if (value != null && value !== false) {
  4829. if (attr === 'class') {
  4830. // handle edge case #1960:
  4831. // class interpolation should not overwrite Vue transition class
  4832. if (el.__v_trans) {
  4833. value += ' ' + el.__v_trans.id + '-transition';
  4834. }
  4835. setClass(el, value);
  4836. } else if (xlinkRE.test(attr)) {
  4837. el.setAttributeNS(xlinkNS, attr, value === true ? '' : value);
  4838. } else {
  4839. el.setAttribute(attr, value === true ? '' : value);
  4840. }
  4841. } else {
  4842. el.removeAttribute(attr);
  4843. }
  4844. }
  4845. };
  4846. var el = {
  4847. priority: EL,
  4848. bind: function bind() {
  4849. /* istanbul ignore if */
  4850. if (!this.arg) {
  4851. return;
  4852. }
  4853. var id = this.id = camelize(this.arg);
  4854. var refs = (this._scope || this.vm).$els;
  4855. if (hasOwn(refs, id)) {
  4856. refs[id] = this.el;
  4857. } else {
  4858. defineReactive(refs, id, this.el);
  4859. }
  4860. },
  4861. unbind: function unbind() {
  4862. var refs = (this._scope || this.vm).$els;
  4863. if (refs[this.id] === this.el) {
  4864. refs[this.id] = null;
  4865. }
  4866. }
  4867. };
  4868. var ref = {
  4869. bind: function bind() {
  4870. 'development' !== 'production' && warn('v-ref:' + this.arg + ' must be used on a child ' + 'component. Found on <' + this.el.tagName.toLowerCase() + '>.', this.vm);
  4871. }
  4872. };
  4873. var cloak = {
  4874. bind: function bind() {
  4875. var el = this.el;
  4876. this.vm.$once('pre-hook:compiled', function () {
  4877. el.removeAttribute('v-cloak');
  4878. });
  4879. }
  4880. };
  4881. // must export plain object
  4882. var directives = {
  4883. text: text$1,
  4884. html: html,
  4885. 'for': vFor,
  4886. 'if': vIf,
  4887. show: show,
  4888. model: model,
  4889. on: on$1,
  4890. bind: bind$1,
  4891. el: el,
  4892. ref: ref,
  4893. cloak: cloak
  4894. };
  4895. var vClass = {
  4896. deep: true,
  4897. update: function update(value) {
  4898. if (!value) {
  4899. this.cleanup();
  4900. } else if (typeof value === 'string') {
  4901. this.setClass(value.trim().split(/\s+/));
  4902. } else {
  4903. this.setClass(normalize$1(value));
  4904. }
  4905. },
  4906. setClass: function setClass(value) {
  4907. this.cleanup(value);
  4908. for (var i = 0, l = value.length; i < l; i++) {
  4909. var val = value[i];
  4910. if (val) {
  4911. apply(this.el, val, addClass);
  4912. }
  4913. }
  4914. this.prevKeys = value;
  4915. },
  4916. cleanup: function cleanup(value) {
  4917. var prevKeys = this.prevKeys;
  4918. if (!prevKeys) return;
  4919. var i = prevKeys.length;
  4920. while (i--) {
  4921. var key = prevKeys[i];
  4922. if (!value || value.indexOf(key) < 0) {
  4923. apply(this.el, key, removeClass);
  4924. }
  4925. }
  4926. }
  4927. };
  4928. /**
  4929. * Normalize objects and arrays (potentially containing objects)
  4930. * into array of strings.
  4931. *
  4932. * @param {Object|Array<String|Object>} value
  4933. * @return {Array<String>}
  4934. */
  4935. function normalize$1(value) {
  4936. var res = [];
  4937. if (isArray(value)) {
  4938. for (var i = 0, l = value.length; i < l; i++) {
  4939. var _key = value[i];
  4940. if (_key) {
  4941. if (typeof _key === 'string') {
  4942. res.push(_key);
  4943. } else {
  4944. for (var k in _key) {
  4945. if (_key[k]) res.push(k);
  4946. }
  4947. }
  4948. }
  4949. }
  4950. } else if (isObject(value)) {
  4951. for (var key in value) {
  4952. if (value[key]) res.push(key);
  4953. }
  4954. }
  4955. return res;
  4956. }
  4957. /**
  4958. * Add or remove a class/classes on an element
  4959. *
  4960. * @param {Element} el
  4961. * @param {String} key The class name. This may or may not
  4962. * contain a space character, in such a
  4963. * case we'll deal with multiple class
  4964. * names at once.
  4965. * @param {Function} fn
  4966. */
  4967. function apply(el, key, fn) {
  4968. key = key.trim();
  4969. if (key.indexOf(' ') === -1) {
  4970. fn(el, key);
  4971. return;
  4972. }
  4973. // The key contains one or more space characters.
  4974. // Since a class name doesn't accept such characters, we
  4975. // treat it as multiple classes.
  4976. var keys = key.split(/\s+/);
  4977. for (var i = 0, l = keys.length; i < l; i++) {
  4978. fn(el, keys[i]);
  4979. }
  4980. }
  4981. var component = {
  4982. priority: COMPONENT,
  4983. params: ['keep-alive', 'transition-mode', 'inline-template'],
  4984. /**
  4985. * Setup. Two possible usages:
  4986. *
  4987. * - static:
  4988. * <comp> or <div v-component="comp">
  4989. *
  4990. * - dynamic:
  4991. * <component :is="view">
  4992. */
  4993. bind: function bind() {
  4994. if (!this.el.__vue__) {
  4995. // keep-alive cache
  4996. this.keepAlive = this.params.keepAlive;
  4997. if (this.keepAlive) {
  4998. this.cache = {};
  4999. }
  5000. // check inline-template
  5001. if (this.params.inlineTemplate) {
  5002. // extract inline template as a DocumentFragment
  5003. this.inlineTemplate = extractContent(this.el, true);
  5004. }
  5005. // component resolution related state
  5006. this.pendingComponentCb = this.Component = null;
  5007. // transition related state
  5008. this.pendingRemovals = 0;
  5009. this.pendingRemovalCb = null;
  5010. // create a ref anchor
  5011. this.anchor = createAnchor('v-component');
  5012. replace(this.el, this.anchor);
  5013. // remove is attribute.
  5014. // this is removed during compilation, but because compilation is
  5015. // cached, when the component is used elsewhere this attribute
  5016. // will remain at link time.
  5017. this.el.removeAttribute('is');
  5018. this.el.removeAttribute(':is');
  5019. // remove ref, same as above
  5020. if (this.descriptor.ref) {
  5021. this.el.removeAttribute('v-ref:' + hyphenate(this.descriptor.ref));
  5022. }
  5023. // if static, build right now.
  5024. if (this.literal) {
  5025. this.setComponent(this.expression);
  5026. }
  5027. } else {
  5028. 'development' !== 'production' && warn('cannot mount component "' + this.expression + '" ' + 'on already mounted element: ' + this.el);
  5029. }
  5030. },
  5031. /**
  5032. * Public update, called by the watcher in the dynamic
  5033. * literal scenario, e.g. <component :is="view">
  5034. */
  5035. update: function update(value) {
  5036. if (!this.literal) {
  5037. this.setComponent(value);
  5038. }
  5039. },
  5040. /**
  5041. * Switch dynamic components. May resolve the component
  5042. * asynchronously, and perform transition based on
  5043. * specified transition mode. Accepts a few additional
  5044. * arguments specifically for vue-router.
  5045. *
  5046. * The callback is called when the full transition is
  5047. * finished.
  5048. *
  5049. * @param {String} value
  5050. * @param {Function} [cb]
  5051. */
  5052. setComponent: function setComponent(value, cb) {
  5053. this.invalidatePending();
  5054. if (!value) {
  5055. // just remove current
  5056. this.unbuild(true);
  5057. this.remove(this.childVM, cb);
  5058. this.childVM = null;
  5059. } else {
  5060. var self = this;
  5061. this.resolveComponent(value, function () {
  5062. self.mountComponent(cb);
  5063. });
  5064. }
  5065. },
  5066. /**
  5067. * Resolve the component constructor to use when creating
  5068. * the child vm.
  5069. *
  5070. * @param {String|Function} value
  5071. * @param {Function} cb
  5072. */
  5073. resolveComponent: function resolveComponent(value, cb) {
  5074. var self = this;
  5075. this.pendingComponentCb = cancellable(function (Component) {
  5076. self.ComponentName = Component.options.name || (typeof value === 'string' ? value : null);
  5077. self.Component = Component;
  5078. cb();
  5079. });
  5080. this.vm._resolveComponent(value, this.pendingComponentCb);
  5081. },
  5082. /**
  5083. * Create a new instance using the current constructor and
  5084. * replace the existing instance. This method doesn't care
  5085. * whether the new component and the old one are actually
  5086. * the same.
  5087. *
  5088. * @param {Function} [cb]
  5089. */
  5090. mountComponent: function mountComponent(cb) {
  5091. // actual mount
  5092. this.unbuild(true);
  5093. var self = this;
  5094. var activateHooks = this.Component.options.activate;
  5095. var cached = this.getCached();
  5096. var newComponent = this.build();
  5097. if (activateHooks && !cached) {
  5098. this.waitingFor = newComponent;
  5099. callActivateHooks(activateHooks, newComponent, function () {
  5100. if (self.waitingFor !== newComponent) {
  5101. return;
  5102. }
  5103. self.waitingFor = null;
  5104. self.transition(newComponent, cb);
  5105. });
  5106. } else {
  5107. // update ref for kept-alive component
  5108. if (cached) {
  5109. newComponent._updateRef();
  5110. }
  5111. this.transition(newComponent, cb);
  5112. }
  5113. },
  5114. /**
  5115. * When the component changes or unbinds before an async
  5116. * constructor is resolved, we need to invalidate its
  5117. * pending callback.
  5118. */
  5119. invalidatePending: function invalidatePending() {
  5120. if (this.pendingComponentCb) {
  5121. this.pendingComponentCb.cancel();
  5122. this.pendingComponentCb = null;
  5123. }
  5124. },
  5125. /**
  5126. * Instantiate/insert a new child vm.
  5127. * If keep alive and has cached instance, insert that
  5128. * instance; otherwise build a new one and cache it.
  5129. *
  5130. * @param {Object} [extraOptions]
  5131. * @return {Vue} - the created instance
  5132. */
  5133. build: function build(extraOptions) {
  5134. var cached = this.getCached();
  5135. if (cached) {
  5136. return cached;
  5137. }
  5138. if (this.Component) {
  5139. // default options
  5140. var options = {
  5141. name: this.ComponentName,
  5142. el: cloneNode(this.el),
  5143. template: this.inlineTemplate,
  5144. // make sure to add the child with correct parent
  5145. // if this is a transcluded component, its parent
  5146. // should be the transclusion host.
  5147. parent: this._host || this.vm,
  5148. // if no inline-template, then the compiled
  5149. // linker can be cached for better performance.
  5150. _linkerCachable: !this.inlineTemplate,
  5151. _ref: this.descriptor.ref,
  5152. _asComponent: true,
  5153. _isRouterView: this._isRouterView,
  5154. // if this is a transcluded component, context
  5155. // will be the common parent vm of this instance
  5156. // and its host.
  5157. _context: this.vm,
  5158. // if this is inside an inline v-for, the scope
  5159. // will be the intermediate scope created for this
  5160. // repeat fragment. this is used for linking props
  5161. // and container directives.
  5162. _scope: this._scope,
  5163. // pass in the owner fragment of this component.
  5164. // this is necessary so that the fragment can keep
  5165. // track of its contained components in order to
  5166. // call attach/detach hooks for them.
  5167. _frag: this._frag
  5168. };
  5169. // extra options
  5170. // in 1.0.0 this is used by vue-router only
  5171. /* istanbul ignore if */
  5172. if (extraOptions) {
  5173. extend(options, extraOptions);
  5174. }
  5175. var child = new this.Component(options);
  5176. if (this.keepAlive) {
  5177. this.cache[this.Component.cid] = child;
  5178. }
  5179. /* istanbul ignore if */
  5180. if ('development' !== 'production' && this.el.hasAttribute('transition') && child._isFragment) {
  5181. warn('Transitions will not work on a fragment instance. ' + 'Template: ' + child.$options.template, child);
  5182. }
  5183. return child;
  5184. }
  5185. },
  5186. /**
  5187. * Try to get a cached instance of the current component.
  5188. *
  5189. * @return {Vue|undefined}
  5190. */
  5191. getCached: function getCached() {
  5192. return this.keepAlive && this.cache[this.Component.cid];
  5193. },
  5194. /**
  5195. * Teardown the current child, but defers cleanup so
  5196. * that we can separate the destroy and removal steps.
  5197. *
  5198. * @param {Boolean} defer
  5199. */
  5200. unbuild: function unbuild(defer) {
  5201. if (this.waitingFor) {
  5202. if (!this.keepAlive) {
  5203. this.waitingFor.$destroy();
  5204. }
  5205. this.waitingFor = null;
  5206. }
  5207. var child = this.childVM;
  5208. if (!child || this.keepAlive) {
  5209. if (child) {
  5210. // remove ref
  5211. child._inactive = true;
  5212. child._updateRef(true);
  5213. }
  5214. return;
  5215. }
  5216. // the sole purpose of `deferCleanup` is so that we can
  5217. // "deactivate" the vm right now and perform DOM removal
  5218. // later.
  5219. child.$destroy(false, defer);
  5220. },
  5221. /**
  5222. * Remove current destroyed child and manually do
  5223. * the cleanup after removal.
  5224. *
  5225. * @param {Function} cb
  5226. */
  5227. remove: function remove(child, cb) {
  5228. var keepAlive = this.keepAlive;
  5229. if (child) {
  5230. // we may have a component switch when a previous
  5231. // component is still being transitioned out.
  5232. // we want to trigger only one lastest insertion cb
  5233. // when the existing transition finishes. (#1119)
  5234. this.pendingRemovals++;
  5235. this.pendingRemovalCb = cb;
  5236. var self = this;
  5237. child.$remove(function () {
  5238. self.pendingRemovals--;
  5239. if (!keepAlive) child._cleanup();
  5240. if (!self.pendingRemovals && self.pendingRemovalCb) {
  5241. self.pendingRemovalCb();
  5242. self.pendingRemovalCb = null;
  5243. }
  5244. });
  5245. } else if (cb) {
  5246. cb();
  5247. }
  5248. },
  5249. /**
  5250. * Actually swap the components, depending on the
  5251. * transition mode. Defaults to simultaneous.
  5252. *
  5253. * @param {Vue} target
  5254. * @param {Function} [cb]
  5255. */
  5256. transition: function transition(target, cb) {
  5257. var self = this;
  5258. var current = this.childVM;
  5259. // for devtool inspection
  5260. if (current) current._inactive = true;
  5261. target._inactive = false;
  5262. this.childVM = target;
  5263. switch (self.params.transitionMode) {
  5264. case 'in-out':
  5265. target.$before(self.anchor, function () {
  5266. self.remove(current, cb);
  5267. });
  5268. break;
  5269. case 'out-in':
  5270. self.remove(current, function () {
  5271. target.$before(self.anchor, cb);
  5272. });
  5273. break;
  5274. default:
  5275. self.remove(current);
  5276. target.$before(self.anchor, cb);
  5277. }
  5278. },
  5279. /**
  5280. * Unbind.
  5281. */
  5282. unbind: function unbind() {
  5283. this.invalidatePending();
  5284. // Do not defer cleanup when unbinding
  5285. this.unbuild();
  5286. // destroy all keep-alive cached instances
  5287. if (this.cache) {
  5288. for (var key in this.cache) {
  5289. this.cache[key].$destroy();
  5290. }
  5291. this.cache = null;
  5292. }
  5293. }
  5294. };
  5295. /**
  5296. * Call activate hooks in order (asynchronous)
  5297. *
  5298. * @param {Array} hooks
  5299. * @param {Vue} vm
  5300. * @param {Function} cb
  5301. */
  5302. function callActivateHooks(hooks, vm, cb) {
  5303. var total = hooks.length;
  5304. var called = 0;
  5305. hooks[0].call(vm, next);
  5306. function next() {
  5307. if (++called >= total) {
  5308. cb();
  5309. } else {
  5310. hooks[called].call(vm, next);
  5311. }
  5312. }
  5313. }
  5314. var propBindingModes = config._propBindingModes;
  5315. var empty = {};
  5316. // regexes
  5317. var identRE$1 = /^[$_a-zA-Z]+[\w$]*$/;
  5318. var settablePathRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\[[^\[\]]+\])*$/;
  5319. /**
  5320. * Compile props on a root element and return
  5321. * a props link function.
  5322. *
  5323. * @param {Element|DocumentFragment} el
  5324. * @param {Array} propOptions
  5325. * @param {Vue} vm
  5326. * @return {Function} propsLinkFn
  5327. */
  5328. function compileProps(el, propOptions, vm) {
  5329. var props = [];
  5330. var names = Object.keys(propOptions);
  5331. var i = names.length;
  5332. var options, name, attr, value, path, parsed, prop;
  5333. while (i--) {
  5334. name = names[i];
  5335. options = propOptions[name] || empty;
  5336. if ('development' !== 'production' && name === '$data') {
  5337. warn('Do not use $data as prop.', vm);
  5338. continue;
  5339. }
  5340. // props could contain dashes, which will be
  5341. // interpreted as minus calculations by the parser
  5342. // so we need to camelize the path here
  5343. path = camelize(name);
  5344. if (!identRE$1.test(path)) {
  5345. 'development' !== 'production' && warn('Invalid prop key: "' + name + '". Prop keys ' + 'must be valid identifiers.', vm);
  5346. continue;
  5347. }
  5348. prop = {
  5349. name: name,
  5350. path: path,
  5351. options: options,
  5352. mode: propBindingModes.ONE_WAY,
  5353. raw: null
  5354. };
  5355. attr = hyphenate(name);
  5356. // first check dynamic version
  5357. if ((value = getBindAttr(el, attr)) === null) {
  5358. if ((value = getBindAttr(el, attr + '.sync')) !== null) {
  5359. prop.mode = propBindingModes.TWO_WAY;
  5360. } else if ((value = getBindAttr(el, attr + '.once')) !== null) {
  5361. prop.mode = propBindingModes.ONE_TIME;
  5362. }
  5363. }
  5364. if (value !== null) {
  5365. // has dynamic binding!
  5366. prop.raw = value;
  5367. parsed = parseDirective(value);
  5368. value = parsed.expression;
  5369. prop.filters = parsed.filters;
  5370. // check binding type
  5371. if (isLiteral(value) && !parsed.filters) {
  5372. // for expressions containing literal numbers and
  5373. // booleans, there's no need to setup a prop binding,
  5374. // so we can optimize them as a one-time set.
  5375. prop.optimizedLiteral = true;
  5376. } else {
  5377. prop.dynamic = true;
  5378. // check non-settable path for two-way bindings
  5379. if ('development' !== 'production' && prop.mode === propBindingModes.TWO_WAY && !settablePathRE.test(value)) {
  5380. prop.mode = propBindingModes.ONE_WAY;
  5381. warn('Cannot bind two-way prop with non-settable ' + 'parent path: ' + value, vm);
  5382. }
  5383. }
  5384. prop.parentPath = value;
  5385. // warn required two-way
  5386. if ('development' !== 'production' && options.twoWay && prop.mode !== propBindingModes.TWO_WAY) {
  5387. warn('Prop "' + name + '" expects a two-way binding type.', vm);
  5388. }
  5389. } else if ((value = getAttr(el, attr)) !== null) {
  5390. // has literal binding!
  5391. prop.raw = value;
  5392. } else if ('development' !== 'production') {
  5393. // check possible camelCase prop usage
  5394. var lowerCaseName = path.toLowerCase();
  5395. value = /[A-Z\-]/.test(name) && (el.getAttribute(lowerCaseName) || el.getAttribute(':' + lowerCaseName) || el.getAttribute('v-bind:' + lowerCaseName) || el.getAttribute(':' + lowerCaseName + '.once') || el.getAttribute('v-bind:' + lowerCaseName + '.once') || el.getAttribute(':' + lowerCaseName + '.sync') || el.getAttribute('v-bind:' + lowerCaseName + '.sync'));
  5396. if (value) {
  5397. warn('Possible usage error for prop `' + lowerCaseName + '` - ' + 'did you mean `' + attr + '`? HTML is case-insensitive, remember to use ' + 'kebab-case for props in templates.', vm);
  5398. } else if (options.required) {
  5399. // warn missing required
  5400. warn('Missing required prop: ' + name, vm);
  5401. }
  5402. }
  5403. // push prop
  5404. props.push(prop);
  5405. }
  5406. return makePropsLinkFn(props);
  5407. }
  5408. /**
  5409. * Build a function that applies props to a vm.
  5410. *
  5411. * @param {Array} props
  5412. * @return {Function} propsLinkFn
  5413. */
  5414. function makePropsLinkFn(props) {
  5415. return function propsLinkFn(vm, scope) {
  5416. // store resolved props info
  5417. vm._props = {};
  5418. var inlineProps = vm.$options.propsData;
  5419. var i = props.length;
  5420. var prop, path, options, value, raw;
  5421. while (i--) {
  5422. prop = props[i];
  5423. raw = prop.raw;
  5424. path = prop.path;
  5425. options = prop.options;
  5426. vm._props[path] = prop;
  5427. if (inlineProps && hasOwn(inlineProps, path)) {
  5428. initProp(vm, prop, inlineProps[path]);
  5429. }if (raw === null) {
  5430. // initialize absent prop
  5431. initProp(vm, prop, undefined);
  5432. } else if (prop.dynamic) {
  5433. // dynamic prop
  5434. if (prop.mode === propBindingModes.ONE_TIME) {
  5435. // one time binding
  5436. value = (scope || vm._context || vm).$get(prop.parentPath);
  5437. initProp(vm, prop, value);
  5438. } else {
  5439. if (vm._context) {
  5440. // dynamic binding
  5441. vm._bindDir({
  5442. name: 'prop',
  5443. def: propDef,
  5444. prop: prop
  5445. }, null, null, scope); // el, host, scope
  5446. } else {
  5447. // root instance
  5448. initProp(vm, prop, vm.$get(prop.parentPath));
  5449. }
  5450. }
  5451. } else if (prop.optimizedLiteral) {
  5452. // optimized literal, cast it and just set once
  5453. var stripped = stripQuotes(raw);
  5454. value = stripped === raw ? toBoolean(toNumber(raw)) : stripped;
  5455. initProp(vm, prop, value);
  5456. } else {
  5457. // string literal, but we need to cater for
  5458. // Boolean props with no value, or with same
  5459. // literal value (e.g. disabled="disabled")
  5460. // see https://github.com/vuejs/vue-loader/issues/182
  5461. value = options.type === Boolean && (raw === '' || raw === hyphenate(prop.name)) ? true : raw;
  5462. initProp(vm, prop, value);
  5463. }
  5464. }
  5465. };
  5466. }
  5467. /**
  5468. * Process a prop with a rawValue, applying necessary coersions,
  5469. * default values & assertions and call the given callback with
  5470. * processed value.
  5471. *
  5472. * @param {Vue} vm
  5473. * @param {Object} prop
  5474. * @param {*} rawValue
  5475. * @param {Function} fn
  5476. */
  5477. function processPropValue(vm, prop, rawValue, fn) {
  5478. var isSimple = prop.dynamic && isSimplePath(prop.parentPath);
  5479. var value = rawValue;
  5480. if (value === undefined) {
  5481. value = getPropDefaultValue(vm, prop);
  5482. }
  5483. value = coerceProp(prop, value);
  5484. var coerced = value !== rawValue;
  5485. if (!assertProp(prop, value, vm)) {
  5486. value = undefined;
  5487. }
  5488. if (isSimple && !coerced) {
  5489. withoutConversion(function () {
  5490. fn(value);
  5491. });
  5492. } else {
  5493. fn(value);
  5494. }
  5495. }
  5496. /**
  5497. * Set a prop's initial value on a vm and its data object.
  5498. *
  5499. * @param {Vue} vm
  5500. * @param {Object} prop
  5501. * @param {*} value
  5502. */
  5503. function initProp(vm, prop, value) {
  5504. processPropValue(vm, prop, value, function (value) {
  5505. defineReactive(vm, prop.path, value);
  5506. });
  5507. }
  5508. /**
  5509. * Update a prop's value on a vm.
  5510. *
  5511. * @param {Vue} vm
  5512. * @param {Object} prop
  5513. * @param {*} value
  5514. */
  5515. function updateProp(vm, prop, value) {
  5516. processPropValue(vm, prop, value, function (value) {
  5517. vm[prop.path] = value;
  5518. });
  5519. }
  5520. /**
  5521. * Get the default value of a prop.
  5522. *
  5523. * @param {Vue} vm
  5524. * @param {Object} prop
  5525. * @return {*}
  5526. */
  5527. function getPropDefaultValue(vm, prop) {
  5528. // no default, return undefined
  5529. var options = prop.options;
  5530. if (!hasOwn(options, 'default')) {
  5531. // absent boolean value defaults to false
  5532. return options.type === Boolean ? false : undefined;
  5533. }
  5534. var def = options['default'];
  5535. // warn against non-factory defaults for Object & Array
  5536. if (isObject(def)) {
  5537. 'development' !== 'production' && warn('Invalid default value for prop "' + prop.name + '": ' + 'Props with type Object/Array must use a factory function ' + 'to return the default value.', vm);
  5538. }
  5539. // call factory function for non-Function types
  5540. return typeof def === 'function' && options.type !== Function ? def.call(vm) : def;
  5541. }
  5542. /**
  5543. * Assert whether a prop is valid.
  5544. *
  5545. * @param {Object} prop
  5546. * @param {*} value
  5547. * @param {Vue} vm
  5548. */
  5549. function assertProp(prop, value, vm) {
  5550. if (!prop.options.required && ( // non-required
  5551. prop.raw === null || // abscent
  5552. value == null) // null or undefined
  5553. ) {
  5554. return true;
  5555. }
  5556. var options = prop.options;
  5557. var type = options.type;
  5558. var valid = !type;
  5559. var expectedTypes = [];
  5560. if (type) {
  5561. if (!isArray(type)) {
  5562. type = [type];
  5563. }
  5564. for (var i = 0; i < type.length && !valid; i++) {
  5565. var assertedType = assertType(value, type[i]);
  5566. expectedTypes.push(assertedType.expectedType);
  5567. valid = assertedType.valid;
  5568. }
  5569. }
  5570. if (!valid) {
  5571. if ('development' !== 'production') {
  5572. warn('Invalid prop: type check failed for prop "' + prop.name + '".' + ' Expected ' + expectedTypes.map(formatType).join(', ') + ', got ' + formatValue(value) + '.', vm);
  5573. }
  5574. return false;
  5575. }
  5576. var validator = options.validator;
  5577. if (validator) {
  5578. if (!validator(value)) {
  5579. 'development' !== 'production' && warn('Invalid prop: custom validator check failed for prop "' + prop.name + '".', vm);
  5580. return false;
  5581. }
  5582. }
  5583. return true;
  5584. }
  5585. /**
  5586. * Force parsing value with coerce option.
  5587. *
  5588. * @param {*} value
  5589. * @param {Object} options
  5590. * @return {*}
  5591. */
  5592. function coerceProp(prop, value) {
  5593. var coerce = prop.options.coerce;
  5594. if (!coerce) {
  5595. return value;
  5596. }
  5597. // coerce is a function
  5598. return coerce(value);
  5599. }
  5600. /**
  5601. * Assert the type of a value
  5602. *
  5603. * @param {*} value
  5604. * @param {Function} type
  5605. * @return {Object}
  5606. */
  5607. function assertType(value, type) {
  5608. var valid;
  5609. var expectedType;
  5610. if (type === String) {
  5611. expectedType = 'string';
  5612. valid = typeof value === expectedType;
  5613. } else if (type === Number) {
  5614. expectedType = 'number';
  5615. valid = typeof value === expectedType;
  5616. } else if (type === Boolean) {
  5617. expectedType = 'boolean';
  5618. valid = typeof value === expectedType;
  5619. } else if (type === Function) {
  5620. expectedType = 'function';
  5621. valid = typeof value === expectedType;
  5622. } else if (type === Object) {
  5623. expectedType = 'object';
  5624. valid = isPlainObject(value);
  5625. } else if (type === Array) {
  5626. expectedType = 'array';
  5627. valid = isArray(value);
  5628. } else {
  5629. valid = value instanceof type;
  5630. }
  5631. return {
  5632. valid: valid,
  5633. expectedType: expectedType
  5634. };
  5635. }
  5636. /**
  5637. * Format type for output
  5638. *
  5639. * @param {String} type
  5640. * @return {String}
  5641. */
  5642. function formatType(type) {
  5643. return type ? type.charAt(0).toUpperCase() + type.slice(1) : 'custom type';
  5644. }
  5645. /**
  5646. * Format value
  5647. *
  5648. * @param {*} value
  5649. * @return {String}
  5650. */
  5651. function formatValue(val) {
  5652. return Object.prototype.toString.call(val).slice(8, -1);
  5653. }
  5654. var bindingModes = config._propBindingModes;
  5655. var propDef = {
  5656. bind: function bind() {
  5657. var child = this.vm;
  5658. var parent = child._context;
  5659. // passed in from compiler directly
  5660. var prop = this.descriptor.prop;
  5661. var childKey = prop.path;
  5662. var parentKey = prop.parentPath;
  5663. var twoWay = prop.mode === bindingModes.TWO_WAY;
  5664. var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
  5665. updateProp(child, prop, val);
  5666. }, {
  5667. twoWay: twoWay,
  5668. filters: prop.filters,
  5669. // important: props need to be observed on the
  5670. // v-for scope if present
  5671. scope: this._scope
  5672. });
  5673. // set the child initial value.
  5674. initProp(child, prop, parentWatcher.value);
  5675. // setup two-way binding
  5676. if (twoWay) {
  5677. // important: defer the child watcher creation until
  5678. // the created hook (after data observation)
  5679. var self = this;
  5680. child.$once('pre-hook:created', function () {
  5681. self.childWatcher = new Watcher(child, childKey, function (val) {
  5682. parentWatcher.set(val);
  5683. }, {
  5684. // ensure sync upward before parent sync down.
  5685. // this is necessary in cases e.g. the child
  5686. // mutates a prop array, then replaces it. (#1683)
  5687. sync: true
  5688. });
  5689. });
  5690. }
  5691. },
  5692. unbind: function unbind() {
  5693. this.parentWatcher.teardown();
  5694. if (this.childWatcher) {
  5695. this.childWatcher.teardown();
  5696. }
  5697. }
  5698. };
  5699. var queue$1 = [];
  5700. var queued = false;
  5701. /**
  5702. * Push a job into the queue.
  5703. *
  5704. * @param {Function} job
  5705. */
  5706. function pushJob(job) {
  5707. queue$1.push(job);
  5708. if (!queued) {
  5709. queued = true;
  5710. nextTick(flush);
  5711. }
  5712. }
  5713. /**
  5714. * Flush the queue, and do one forced reflow before
  5715. * triggering transitions.
  5716. */
  5717. function flush() {
  5718. // Force layout
  5719. var f = document.documentElement.offsetHeight;
  5720. for (var i = 0; i < queue$1.length; i++) {
  5721. queue$1[i]();
  5722. }
  5723. queue$1 = [];
  5724. queued = false;
  5725. // dummy return, so js linters don't complain about
  5726. // unused variable f
  5727. return f;
  5728. }
  5729. var TYPE_TRANSITION = 'transition';
  5730. var TYPE_ANIMATION = 'animation';
  5731. var transDurationProp = transitionProp + 'Duration';
  5732. var animDurationProp = animationProp + 'Duration';
  5733. /**
  5734. * If a just-entered element is applied the
  5735. * leave class while its enter transition hasn't started yet,
  5736. * and the transitioned property has the same value for both
  5737. * enter/leave, then the leave transition will be skipped and
  5738. * the transitionend event never fires. This function ensures
  5739. * its callback to be called after a transition has started
  5740. * by waiting for double raf.
  5741. *
  5742. * It falls back to setTimeout on devices that support CSS
  5743. * transitions but not raf (e.g. Android 4.2 browser) - since
  5744. * these environments are usually slow, we are giving it a
  5745. * relatively large timeout.
  5746. */
  5747. var raf = inBrowser && window.requestAnimationFrame;
  5748. var waitForTransitionStart = raf
  5749. /* istanbul ignore next */
  5750. ? function (fn) {
  5751. raf(function () {
  5752. raf(fn);
  5753. });
  5754. } : function (fn) {
  5755. setTimeout(fn, 50);
  5756. };
  5757. /**
  5758. * A Transition object that encapsulates the state and logic
  5759. * of the transition.
  5760. *
  5761. * @param {Element} el
  5762. * @param {String} id
  5763. * @param {Object} hooks
  5764. * @param {Vue} vm
  5765. */
  5766. function Transition(el, id, hooks, vm) {
  5767. this.id = id;
  5768. this.el = el;
  5769. this.enterClass = hooks && hooks.enterClass || id + '-enter';
  5770. this.leaveClass = hooks && hooks.leaveClass || id + '-leave';
  5771. this.hooks = hooks;
  5772. this.vm = vm;
  5773. // async state
  5774. this.pendingCssEvent = this.pendingCssCb = this.cancel = this.pendingJsCb = this.op = this.cb = null;
  5775. this.justEntered = false;
  5776. this.entered = this.left = false;
  5777. this.typeCache = {};
  5778. // check css transition type
  5779. this.type = hooks && hooks.type;
  5780. /* istanbul ignore if */
  5781. if ('development' !== 'production') {
  5782. if (this.type && this.type !== TYPE_TRANSITION && this.type !== TYPE_ANIMATION) {
  5783. warn('invalid CSS transition type for transition="' + this.id + '": ' + this.type, vm);
  5784. }
  5785. }
  5786. // bind
  5787. var self = this;['enterNextTick', 'enterDone', 'leaveNextTick', 'leaveDone'].forEach(function (m) {
  5788. self[m] = bind(self[m], self);
  5789. });
  5790. }
  5791. var p$1 = Transition.prototype;
  5792. /**
  5793. * Start an entering transition.
  5794. *
  5795. * 1. enter transition triggered
  5796. * 2. call beforeEnter hook
  5797. * 3. add enter class
  5798. * 4. insert/show element
  5799. * 5. call enter hook (with possible explicit js callback)
  5800. * 6. reflow
  5801. * 7. based on transition type:
  5802. * - transition:
  5803. * remove class now, wait for transitionend,
  5804. * then done if there's no explicit js callback.
  5805. * - animation:
  5806. * wait for animationend, remove class,
  5807. * then done if there's no explicit js callback.
  5808. * - no css transition:
  5809. * done now if there's no explicit js callback.
  5810. * 8. wait for either done or js callback, then call
  5811. * afterEnter hook.
  5812. *
  5813. * @param {Function} op - insert/show the element
  5814. * @param {Function} [cb]
  5815. */
  5816. p$1.enter = function (op, cb) {
  5817. this.cancelPending();
  5818. this.callHook('beforeEnter');
  5819. this.cb = cb;
  5820. addClass(this.el, this.enterClass);
  5821. op();
  5822. this.entered = false;
  5823. this.callHookWithCb('enter');
  5824. if (this.entered) {
  5825. return; // user called done synchronously.
  5826. }
  5827. this.cancel = this.hooks && this.hooks.enterCancelled;
  5828. pushJob(this.enterNextTick);
  5829. };
  5830. /**
  5831. * The "nextTick" phase of an entering transition, which is
  5832. * to be pushed into a queue and executed after a reflow so
  5833. * that removing the class can trigger a CSS transition.
  5834. */
  5835. p$1.enterNextTick = function () {
  5836. var _this = this;
  5837. // prevent transition skipping
  5838. this.justEntered = true;
  5839. waitForTransitionStart(function () {
  5840. _this.justEntered = false;
  5841. });
  5842. var enterDone = this.enterDone;
  5843. var type = this.getCssTransitionType(this.enterClass);
  5844. if (!this.pendingJsCb) {
  5845. if (type === TYPE_TRANSITION) {
  5846. // trigger transition by removing enter class now
  5847. removeClass(this.el, this.enterClass);
  5848. this.setupCssCb(transitionEndEvent, enterDone);
  5849. } else if (type === TYPE_ANIMATION) {
  5850. this.setupCssCb(animationEndEvent, enterDone);
  5851. } else {
  5852. enterDone();
  5853. }
  5854. } else if (type === TYPE_TRANSITION) {
  5855. removeClass(this.el, this.enterClass);
  5856. }
  5857. };
  5858. /**
  5859. * The "cleanup" phase of an entering transition.
  5860. */
  5861. p$1.enterDone = function () {
  5862. this.entered = true;
  5863. this.cancel = this.pendingJsCb = null;
  5864. removeClass(this.el, this.enterClass);
  5865. this.callHook('afterEnter');
  5866. if (this.cb) this.cb();
  5867. };
  5868. /**
  5869. * Start a leaving transition.
  5870. *
  5871. * 1. leave transition triggered.
  5872. * 2. call beforeLeave hook
  5873. * 3. add leave class (trigger css transition)
  5874. * 4. call leave hook (with possible explicit js callback)
  5875. * 5. reflow if no explicit js callback is provided
  5876. * 6. based on transition type:
  5877. * - transition or animation:
  5878. * wait for end event, remove class, then done if
  5879. * there's no explicit js callback.
  5880. * - no css transition:
  5881. * done if there's no explicit js callback.
  5882. * 7. wait for either done or js callback, then call
  5883. * afterLeave hook.
  5884. *
  5885. * @param {Function} op - remove/hide the element
  5886. * @param {Function} [cb]
  5887. */
  5888. p$1.leave = function (op, cb) {
  5889. this.cancelPending();
  5890. this.callHook('beforeLeave');
  5891. this.op = op;
  5892. this.cb = cb;
  5893. addClass(this.el, this.leaveClass);
  5894. this.left = false;
  5895. this.callHookWithCb('leave');
  5896. if (this.left) {
  5897. return; // user called done synchronously.
  5898. }
  5899. this.cancel = this.hooks && this.hooks.leaveCancelled;
  5900. // only need to handle leaveDone if
  5901. // 1. the transition is already done (synchronously called
  5902. // by the user, which causes this.op set to null)
  5903. // 2. there's no explicit js callback
  5904. if (this.op && !this.pendingJsCb) {
  5905. // if a CSS transition leaves immediately after enter,
  5906. // the transitionend event never fires. therefore we
  5907. // detect such cases and end the leave immediately.
  5908. if (this.justEntered) {
  5909. this.leaveDone();
  5910. } else {
  5911. pushJob(this.leaveNextTick);
  5912. }
  5913. }
  5914. };
  5915. /**
  5916. * The "nextTick" phase of a leaving transition.
  5917. */
  5918. p$1.leaveNextTick = function () {
  5919. var type = this.getCssTransitionType(this.leaveClass);
  5920. if (type) {
  5921. var event = type === TYPE_TRANSITION ? transitionEndEvent : animationEndEvent;
  5922. this.setupCssCb(event, this.leaveDone);
  5923. } else {
  5924. this.leaveDone();
  5925. }
  5926. };
  5927. /**
  5928. * The "cleanup" phase of a leaving transition.
  5929. */
  5930. p$1.leaveDone = function () {
  5931. this.left = true;
  5932. this.cancel = this.pendingJsCb = null;
  5933. this.op();
  5934. removeClass(this.el, this.leaveClass);
  5935. this.callHook('afterLeave');
  5936. if (this.cb) this.cb();
  5937. this.op = null;
  5938. };
  5939. /**
  5940. * Cancel any pending callbacks from a previously running
  5941. * but not finished transition.
  5942. */
  5943. p$1.cancelPending = function () {
  5944. this.op = this.cb = null;
  5945. var hasPending = false;
  5946. if (this.pendingCssCb) {
  5947. hasPending = true;
  5948. off(this.el, this.pendingCssEvent, this.pendingCssCb);
  5949. this.pendingCssEvent = this.pendingCssCb = null;
  5950. }
  5951. if (this.pendingJsCb) {
  5952. hasPending = true;
  5953. this.pendingJsCb.cancel();
  5954. this.pendingJsCb = null;
  5955. }
  5956. if (hasPending) {
  5957. removeClass(this.el, this.enterClass);
  5958. removeClass(this.el, this.leaveClass);
  5959. }
  5960. if (this.cancel) {
  5961. this.cancel.call(this.vm, this.el);
  5962. this.cancel = null;
  5963. }
  5964. };
  5965. /**
  5966. * Call a user-provided synchronous hook function.
  5967. *
  5968. * @param {String} type
  5969. */
  5970. p$1.callHook = function (type) {
  5971. if (this.hooks && this.hooks[type]) {
  5972. this.hooks[type].call(this.vm, this.el);
  5973. }
  5974. };
  5975. /**
  5976. * Call a user-provided, potentially-async hook function.
  5977. * We check for the length of arguments to see if the hook
  5978. * expects a `done` callback. If true, the transition's end
  5979. * will be determined by when the user calls that callback;
  5980. * otherwise, the end is determined by the CSS transition or
  5981. * animation.
  5982. *
  5983. * @param {String} type
  5984. */
  5985. p$1.callHookWithCb = function (type) {
  5986. var hook = this.hooks && this.hooks[type];
  5987. if (hook) {
  5988. if (hook.length > 1) {
  5989. this.pendingJsCb = cancellable(this[type + 'Done']);
  5990. }
  5991. hook.call(this.vm, this.el, this.pendingJsCb);
  5992. }
  5993. };
  5994. /**
  5995. * Get an element's transition type based on the
  5996. * calculated styles.
  5997. *
  5998. * @param {String} className
  5999. * @return {Number}
  6000. */
  6001. p$1.getCssTransitionType = function (className) {
  6002. /* istanbul ignore if */
  6003. if (!transitionEndEvent ||
  6004. // skip CSS transitions if page is not visible -
  6005. // this solves the issue of transitionend events not
  6006. // firing until the page is visible again.
  6007. // pageVisibility API is supported in IE10+, same as
  6008. // CSS transitions.
  6009. document.hidden ||
  6010. // explicit js-only transition
  6011. this.hooks && this.hooks.css === false ||
  6012. // element is hidden
  6013. isHidden(this.el)) {
  6014. return;
  6015. }
  6016. var type = this.type || this.typeCache[className];
  6017. if (type) return type;
  6018. var inlineStyles = this.el.style;
  6019. var computedStyles = window.getComputedStyle(this.el);
  6020. var transDuration = inlineStyles[transDurationProp] || computedStyles[transDurationProp];
  6021. if (transDuration && transDuration !== '0s') {
  6022. type = TYPE_TRANSITION;
  6023. } else {
  6024. var animDuration = inlineStyles[animDurationProp] || computedStyles[animDurationProp];
  6025. if (animDuration && animDuration !== '0s') {
  6026. type = TYPE_ANIMATION;
  6027. }
  6028. }
  6029. if (type) {
  6030. this.typeCache[className] = type;
  6031. }
  6032. return type;
  6033. };
  6034. /**
  6035. * Setup a CSS transitionend/animationend callback.
  6036. *
  6037. * @param {String} event
  6038. * @param {Function} cb
  6039. */
  6040. p$1.setupCssCb = function (event, cb) {
  6041. this.pendingCssEvent = event;
  6042. var self = this;
  6043. var el = this.el;
  6044. var onEnd = this.pendingCssCb = function (e) {
  6045. if (e.target === el) {
  6046. off(el, event, onEnd);
  6047. self.pendingCssEvent = self.pendingCssCb = null;
  6048. if (!self.pendingJsCb && cb) {
  6049. cb();
  6050. }
  6051. }
  6052. };
  6053. on(el, event, onEnd);
  6054. };
  6055. /**
  6056. * Check if an element is hidden - in that case we can just
  6057. * skip the transition alltogether.
  6058. *
  6059. * @param {Element} el
  6060. * @return {Boolean}
  6061. */
  6062. function isHidden(el) {
  6063. if (/svg$/.test(el.namespaceURI)) {
  6064. // SVG elements do not have offset(Width|Height)
  6065. // so we need to check the client rect
  6066. var rect = el.getBoundingClientRect();
  6067. return !(rect.width || rect.height);
  6068. } else {
  6069. return !(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
  6070. }
  6071. }
  6072. var transition$1 = {
  6073. priority: TRANSITION,
  6074. update: function update(id, oldId) {
  6075. var el = this.el;
  6076. // resolve on owner vm
  6077. var hooks = resolveAsset(this.vm.$options, 'transitions', id);
  6078. id = id || 'v';
  6079. el.__v_trans = new Transition(el, id, hooks, this.vm);
  6080. if (oldId) {
  6081. removeClass(el, oldId + '-transition');
  6082. }
  6083. addClass(el, id + '-transition');
  6084. }
  6085. };
  6086. var internalDirectives = {
  6087. style: style,
  6088. 'class': vClass,
  6089. component: component,
  6090. prop: propDef,
  6091. transition: transition$1
  6092. };
  6093. // special binding prefixes
  6094. var bindRE = /^v-bind:|^:/;
  6095. var onRE = /^v-on:|^@/;
  6096. var dirAttrRE = /^v-([^:]+)(?:$|:(.*)$)/;
  6097. var modifierRE = /\.[^\.]+/g;
  6098. var transitionRE = /^(v-bind:|:)?transition$/;
  6099. // default directive priority
  6100. var DEFAULT_PRIORITY = 1000;
  6101. var DEFAULT_TERMINAL_PRIORITY = 2000;
  6102. /**
  6103. * Compile a template and return a reusable composite link
  6104. * function, which recursively contains more link functions
  6105. * inside. This top level compile function would normally
  6106. * be called on instance root nodes, but can also be used
  6107. * for partial compilation if the partial argument is true.
  6108. *
  6109. * The returned composite link function, when called, will
  6110. * return an unlink function that tearsdown all directives
  6111. * created during the linking phase.
  6112. *
  6113. * @param {Element|DocumentFragment} el
  6114. * @param {Object} options
  6115. * @param {Boolean} partial
  6116. * @return {Function}
  6117. */
  6118. function compile(el, options, partial) {
  6119. // link function for the node itself.
  6120. var nodeLinkFn = partial || !options._asComponent ? compileNode(el, options) : null;
  6121. // link function for the childNodes
  6122. var childLinkFn = !(nodeLinkFn && nodeLinkFn.terminal) && !isScript(el) && el.hasChildNodes() ? compileNodeList(el.childNodes, options) : null;
  6123. /**
  6124. * A composite linker function to be called on a already
  6125. * compiled piece of DOM, which instantiates all directive
  6126. * instances.
  6127. *
  6128. * @param {Vue} vm
  6129. * @param {Element|DocumentFragment} el
  6130. * @param {Vue} [host] - host vm of transcluded content
  6131. * @param {Object} [scope] - v-for scope
  6132. * @param {Fragment} [frag] - link context fragment
  6133. * @return {Function|undefined}
  6134. */
  6135. return function compositeLinkFn(vm, el, host, scope, frag) {
  6136. // cache childNodes before linking parent, fix #657
  6137. var childNodes = toArray(el.childNodes);
  6138. // link
  6139. var dirs = linkAndCapture(function compositeLinkCapturer() {
  6140. if (nodeLinkFn) nodeLinkFn(vm, el, host, scope, frag);
  6141. if (childLinkFn) childLinkFn(vm, childNodes, host, scope, frag);
  6142. }, vm);
  6143. return makeUnlinkFn(vm, dirs);
  6144. };
  6145. }
  6146. /**
  6147. * Apply a linker to a vm/element pair and capture the
  6148. * directives created during the process.
  6149. *
  6150. * @param {Function} linker
  6151. * @param {Vue} vm
  6152. */
  6153. function linkAndCapture(linker, vm) {
  6154. /* istanbul ignore if */
  6155. if ('development' === 'production') {}
  6156. var originalDirCount = vm._directives.length;
  6157. linker();
  6158. var dirs = vm._directives.slice(originalDirCount);
  6159. dirs.sort(directiveComparator);
  6160. for (var i = 0, l = dirs.length; i < l; i++) {
  6161. dirs[i]._bind();
  6162. }
  6163. return dirs;
  6164. }
  6165. /**
  6166. * Directive priority sort comparator
  6167. *
  6168. * @param {Object} a
  6169. * @param {Object} b
  6170. */
  6171. function directiveComparator(a, b) {
  6172. a = a.descriptor.def.priority || DEFAULT_PRIORITY;
  6173. b = b.descriptor.def.priority || DEFAULT_PRIORITY;
  6174. return a > b ? -1 : a === b ? 0 : 1;
  6175. }
  6176. /**
  6177. * Linker functions return an unlink function that
  6178. * tearsdown all directives instances generated during
  6179. * the process.
  6180. *
  6181. * We create unlink functions with only the necessary
  6182. * information to avoid retaining additional closures.
  6183. *
  6184. * @param {Vue} vm
  6185. * @param {Array} dirs
  6186. * @param {Vue} [context]
  6187. * @param {Array} [contextDirs]
  6188. * @return {Function}
  6189. */
  6190. function makeUnlinkFn(vm, dirs, context, contextDirs) {
  6191. function unlink(destroying) {
  6192. teardownDirs(vm, dirs, destroying);
  6193. if (context && contextDirs) {
  6194. teardownDirs(context, contextDirs);
  6195. }
  6196. }
  6197. // expose linked directives
  6198. unlink.dirs = dirs;
  6199. return unlink;
  6200. }
  6201. /**
  6202. * Teardown partial linked directives.
  6203. *
  6204. * @param {Vue} vm
  6205. * @param {Array} dirs
  6206. * @param {Boolean} destroying
  6207. */
  6208. function teardownDirs(vm, dirs, destroying) {
  6209. var i = dirs.length;
  6210. while (i--) {
  6211. dirs[i]._teardown();
  6212. if ('development' !== 'production' && !destroying) {
  6213. vm._directives.$remove(dirs[i]);
  6214. }
  6215. }
  6216. }
  6217. /**
  6218. * Compile link props on an instance.
  6219. *
  6220. * @param {Vue} vm
  6221. * @param {Element} el
  6222. * @param {Object} props
  6223. * @param {Object} [scope]
  6224. * @return {Function}
  6225. */
  6226. function compileAndLinkProps(vm, el, props, scope) {
  6227. var propsLinkFn = compileProps(el, props, vm);
  6228. var propDirs = linkAndCapture(function () {
  6229. propsLinkFn(vm, scope);
  6230. }, vm);
  6231. return makeUnlinkFn(vm, propDirs);
  6232. }
  6233. /**
  6234. * Compile the root element of an instance.
  6235. *
  6236. * 1. attrs on context container (context scope)
  6237. * 2. attrs on the component template root node, if
  6238. * replace:true (child scope)
  6239. *
  6240. * If this is a fragment instance, we only need to compile 1.
  6241. *
  6242. * @param {Element} el
  6243. * @param {Object} options
  6244. * @param {Object} contextOptions
  6245. * @return {Function}
  6246. */
  6247. function compileRoot(el, options, contextOptions) {
  6248. var containerAttrs = options._containerAttrs;
  6249. var replacerAttrs = options._replacerAttrs;
  6250. var contextLinkFn, replacerLinkFn;
  6251. // only need to compile other attributes for
  6252. // non-fragment instances
  6253. if (el.nodeType !== 11) {
  6254. // for components, container and replacer need to be
  6255. // compiled separately and linked in different scopes.
  6256. if (options._asComponent) {
  6257. // 2. container attributes
  6258. if (containerAttrs && contextOptions) {
  6259. contextLinkFn = compileDirectives(containerAttrs, contextOptions);
  6260. }
  6261. if (replacerAttrs) {
  6262. // 3. replacer attributes
  6263. replacerLinkFn = compileDirectives(replacerAttrs, options);
  6264. }
  6265. } else {
  6266. // non-component, just compile as a normal element.
  6267. replacerLinkFn = compileDirectives(el.attributes, options);
  6268. }
  6269. } else if ('development' !== 'production' && containerAttrs) {
  6270. // warn container directives for fragment instances
  6271. var names = containerAttrs.filter(function (attr) {
  6272. // allow vue-loader/vueify scoped css attributes
  6273. return attr.name.indexOf('_v-') < 0 &&
  6274. // allow event listeners
  6275. !onRE.test(attr.name) &&
  6276. // allow slots
  6277. attr.name !== 'slot';
  6278. }).map(function (attr) {
  6279. return '"' + attr.name + '"';
  6280. });
  6281. if (names.length) {
  6282. var plural = names.length > 1;
  6283. warn('Attribute' + (plural ? 's ' : ' ') + names.join(', ') + (plural ? ' are' : ' is') + ' ignored on component ' + '<' + options.el.tagName.toLowerCase() + '> because ' + 'the component is a fragment instance: ' + 'http://vuejs.org/guide/components.html#Fragment-Instance');
  6284. }
  6285. }
  6286. options._containerAttrs = options._replacerAttrs = null;
  6287. return function rootLinkFn(vm, el, scope) {
  6288. // link context scope dirs
  6289. var context = vm._context;
  6290. var contextDirs;
  6291. if (context && contextLinkFn) {
  6292. contextDirs = linkAndCapture(function () {
  6293. contextLinkFn(context, el, null, scope);
  6294. }, context);
  6295. }
  6296. // link self
  6297. var selfDirs = linkAndCapture(function () {
  6298. if (replacerLinkFn) replacerLinkFn(vm, el);
  6299. }, vm);
  6300. // return the unlink function that tearsdown context
  6301. // container directives.
  6302. return makeUnlinkFn(vm, selfDirs, context, contextDirs);
  6303. };
  6304. }
  6305. /**
  6306. * Compile a node and return a nodeLinkFn based on the
  6307. * node type.
  6308. *
  6309. * @param {Node} node
  6310. * @param {Object} options
  6311. * @return {Function|null}
  6312. */
  6313. function compileNode(node, options) {
  6314. var type = node.nodeType;
  6315. if (type === 1 && !isScript(node)) {
  6316. return compileElement(node, options);
  6317. } else if (type === 3 && node.data.trim()) {
  6318. return compileTextNode(node, options);
  6319. } else {
  6320. return null;
  6321. }
  6322. }
  6323. /**
  6324. * Compile an element and return a nodeLinkFn.
  6325. *
  6326. * @param {Element} el
  6327. * @param {Object} options
  6328. * @return {Function|null}
  6329. */
  6330. function compileElement(el, options) {
  6331. // preprocess textareas.
  6332. // textarea treats its text content as the initial value.
  6333. // just bind it as an attr directive for value.
  6334. if (el.tagName === 'TEXTAREA') {
  6335. var tokens = parseText(el.value);
  6336. if (tokens) {
  6337. el.setAttribute(':value', tokensToExp(tokens));
  6338. el.value = '';
  6339. }
  6340. }
  6341. var linkFn;
  6342. var hasAttrs = el.hasAttributes();
  6343. var attrs = hasAttrs && toArray(el.attributes);
  6344. // check terminal directives (for & if)
  6345. if (hasAttrs) {
  6346. linkFn = checkTerminalDirectives(el, attrs, options);
  6347. }
  6348. // check element directives
  6349. if (!linkFn) {
  6350. linkFn = checkElementDirectives(el, options);
  6351. }
  6352. // check component
  6353. if (!linkFn) {
  6354. linkFn = checkComponent(el, options);
  6355. }
  6356. // normal directives
  6357. if (!linkFn && hasAttrs) {
  6358. linkFn = compileDirectives(attrs, options);
  6359. }
  6360. return linkFn;
  6361. }
  6362. /**
  6363. * Compile a textNode and return a nodeLinkFn.
  6364. *
  6365. * @param {TextNode} node
  6366. * @param {Object} options
  6367. * @return {Function|null} textNodeLinkFn
  6368. */
  6369. function compileTextNode(node, options) {
  6370. // skip marked text nodes
  6371. if (node._skip) {
  6372. return removeText;
  6373. }
  6374. var tokens = parseText(node.wholeText);
  6375. if (!tokens) {
  6376. return null;
  6377. }
  6378. // mark adjacent text nodes as skipped,
  6379. // because we are using node.wholeText to compile
  6380. // all adjacent text nodes together. This fixes
  6381. // issues in IE where sometimes it splits up a single
  6382. // text node into multiple ones.
  6383. var next = node.nextSibling;
  6384. while (next && next.nodeType === 3) {
  6385. next._skip = true;
  6386. next = next.nextSibling;
  6387. }
  6388. var frag = document.createDocumentFragment();
  6389. var el, token;
  6390. for (var i = 0, l = tokens.length; i < l; i++) {
  6391. token = tokens[i];
  6392. el = token.tag ? processTextToken(token, options) : document.createTextNode(token.value);
  6393. frag.appendChild(el);
  6394. }
  6395. return makeTextNodeLinkFn(tokens, frag, options);
  6396. }
  6397. /**
  6398. * Linker for an skipped text node.
  6399. *
  6400. * @param {Vue} vm
  6401. * @param {Text} node
  6402. */
  6403. function removeText(vm, node) {
  6404. remove(node);
  6405. }
  6406. /**
  6407. * Process a single text token.
  6408. *
  6409. * @param {Object} token
  6410. * @param {Object} options
  6411. * @return {Node}
  6412. */
  6413. function processTextToken(token, options) {
  6414. var el;
  6415. if (token.oneTime) {
  6416. el = document.createTextNode(token.value);
  6417. } else {
  6418. if (token.html) {
  6419. el = document.createComment('v-html');
  6420. setTokenType('html');
  6421. } else {
  6422. // IE will clean up empty textNodes during
  6423. // frag.cloneNode(true), so we have to give it
  6424. // something here...
  6425. el = document.createTextNode(' ');
  6426. setTokenType('text');
  6427. }
  6428. }
  6429. function setTokenType(type) {
  6430. if (token.descriptor) return;
  6431. var parsed = parseDirective(token.value);
  6432. token.descriptor = {
  6433. name: type,
  6434. def: directives[type],
  6435. expression: parsed.expression,
  6436. filters: parsed.filters
  6437. };
  6438. }
  6439. return el;
  6440. }
  6441. /**
  6442. * Build a function that processes a textNode.
  6443. *
  6444. * @param {Array<Object>} tokens
  6445. * @param {DocumentFragment} frag
  6446. */
  6447. function makeTextNodeLinkFn(tokens, frag) {
  6448. return function textNodeLinkFn(vm, el, host, scope) {
  6449. var fragClone = frag.cloneNode(true);
  6450. var childNodes = toArray(fragClone.childNodes);
  6451. var token, value, node;
  6452. for (var i = 0, l = tokens.length; i < l; i++) {
  6453. token = tokens[i];
  6454. value = token.value;
  6455. if (token.tag) {
  6456. node = childNodes[i];
  6457. if (token.oneTime) {
  6458. value = (scope || vm).$eval(value);
  6459. if (token.html) {
  6460. replace(node, parseTemplate(value, true));
  6461. } else {
  6462. node.data = value;
  6463. }
  6464. } else {
  6465. vm._bindDir(token.descriptor, node, host, scope);
  6466. }
  6467. }
  6468. }
  6469. replace(el, fragClone);
  6470. };
  6471. }
  6472. /**
  6473. * Compile a node list and return a childLinkFn.
  6474. *
  6475. * @param {NodeList} nodeList
  6476. * @param {Object} options
  6477. * @return {Function|undefined}
  6478. */
  6479. function compileNodeList(nodeList, options) {
  6480. var linkFns = [];
  6481. var nodeLinkFn, childLinkFn, node;
  6482. for (var i = 0, l = nodeList.length; i < l; i++) {
  6483. node = nodeList[i];
  6484. nodeLinkFn = compileNode(node, options);
  6485. childLinkFn = !(nodeLinkFn && nodeLinkFn.terminal) && node.tagName !== 'SCRIPT' && node.hasChildNodes() ? compileNodeList(node.childNodes, options) : null;
  6486. linkFns.push(nodeLinkFn, childLinkFn);
  6487. }
  6488. return linkFns.length ? makeChildLinkFn(linkFns) : null;
  6489. }
  6490. /**
  6491. * Make a child link function for a node's childNodes.
  6492. *
  6493. * @param {Array<Function>} linkFns
  6494. * @return {Function} childLinkFn
  6495. */
  6496. function makeChildLinkFn(linkFns) {
  6497. return function childLinkFn(vm, nodes, host, scope, frag) {
  6498. var node, nodeLinkFn, childrenLinkFn;
  6499. for (var i = 0, n = 0, l = linkFns.length; i < l; n++) {
  6500. node = nodes[n];
  6501. nodeLinkFn = linkFns[i++];
  6502. childrenLinkFn = linkFns[i++];
  6503. // cache childNodes before linking parent, fix #657
  6504. var childNodes = toArray(node.childNodes);
  6505. if (nodeLinkFn) {
  6506. nodeLinkFn(vm, node, host, scope, frag);
  6507. }
  6508. if (childrenLinkFn) {
  6509. childrenLinkFn(vm, childNodes, host, scope, frag);
  6510. }
  6511. }
  6512. };
  6513. }
  6514. /**
  6515. * Check for element directives (custom elements that should
  6516. * be resovled as terminal directives).
  6517. *
  6518. * @param {Element} el
  6519. * @param {Object} options
  6520. */
  6521. function checkElementDirectives(el, options) {
  6522. var tag = el.tagName.toLowerCase();
  6523. if (commonTagRE.test(tag)) {
  6524. return;
  6525. }
  6526. var def = resolveAsset(options, 'elementDirectives', tag);
  6527. if (def) {
  6528. return makeTerminalNodeLinkFn(el, tag, '', options, def);
  6529. }
  6530. }
  6531. /**
  6532. * Check if an element is a component. If yes, return
  6533. * a component link function.
  6534. *
  6535. * @param {Element} el
  6536. * @param {Object} options
  6537. * @return {Function|undefined}
  6538. */
  6539. function checkComponent(el, options) {
  6540. var component = checkComponentAttr(el, options);
  6541. if (component) {
  6542. var ref = findRef(el);
  6543. var descriptor = {
  6544. name: 'component',
  6545. ref: ref,
  6546. expression: component.id,
  6547. def: internalDirectives.component,
  6548. modifiers: {
  6549. literal: !component.dynamic
  6550. }
  6551. };
  6552. var componentLinkFn = function componentLinkFn(vm, el, host, scope, frag) {
  6553. if (ref) {
  6554. defineReactive((scope || vm).$refs, ref, null);
  6555. }
  6556. vm._bindDir(descriptor, el, host, scope, frag);
  6557. };
  6558. componentLinkFn.terminal = true;
  6559. return componentLinkFn;
  6560. }
  6561. }
  6562. /**
  6563. * Check an element for terminal directives in fixed order.
  6564. * If it finds one, return a terminal link function.
  6565. *
  6566. * @param {Element} el
  6567. * @param {Array} attrs
  6568. * @param {Object} options
  6569. * @return {Function} terminalLinkFn
  6570. */
  6571. function checkTerminalDirectives(el, attrs, options) {
  6572. // skip v-pre
  6573. if (getAttr(el, 'v-pre') !== null) {
  6574. return skip;
  6575. }
  6576. // skip v-else block, but only if following v-if
  6577. if (el.hasAttribute('v-else')) {
  6578. var prev = el.previousElementSibling;
  6579. if (prev && prev.hasAttribute('v-if')) {
  6580. return skip;
  6581. }
  6582. }
  6583. var attr, name, value, modifiers, matched, dirName, rawName, arg, def, termDef;
  6584. for (var i = 0, j = attrs.length; i < j; i++) {
  6585. attr = attrs[i];
  6586. name = attr.name.replace(modifierRE, '');
  6587. if (matched = name.match(dirAttrRE)) {
  6588. def = resolveAsset(options, 'directives', matched[1]);
  6589. if (def && def.terminal) {
  6590. if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
  6591. termDef = def;
  6592. rawName = attr.name;
  6593. modifiers = parseModifiers(attr.name);
  6594. value = attr.value;
  6595. dirName = matched[1];
  6596. arg = matched[2];
  6597. }
  6598. }
  6599. }
  6600. }
  6601. if (termDef) {
  6602. return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, rawName, arg, modifiers);
  6603. }
  6604. }
  6605. function skip() {}
  6606. skip.terminal = true;
  6607. /**
  6608. * Build a node link function for a terminal directive.
  6609. * A terminal link function terminates the current
  6610. * compilation recursion and handles compilation of the
  6611. * subtree in the directive.
  6612. *
  6613. * @param {Element} el
  6614. * @param {String} dirName
  6615. * @param {String} value
  6616. * @param {Object} options
  6617. * @param {Object} def
  6618. * @param {String} [rawName]
  6619. * @param {String} [arg]
  6620. * @param {Object} [modifiers]
  6621. * @return {Function} terminalLinkFn
  6622. */
  6623. function makeTerminalNodeLinkFn(el, dirName, value, options, def, rawName, arg, modifiers) {
  6624. var parsed = parseDirective(value);
  6625. var descriptor = {
  6626. name: dirName,
  6627. arg: arg,
  6628. expression: parsed.expression,
  6629. filters: parsed.filters,
  6630. raw: value,
  6631. attr: rawName,
  6632. modifiers: modifiers,
  6633. def: def
  6634. };
  6635. // check ref for v-for and router-view
  6636. if (dirName === 'for' || dirName === 'router-view') {
  6637. descriptor.ref = findRef(el);
  6638. }
  6639. var fn = function terminalNodeLinkFn(vm, el, host, scope, frag) {
  6640. if (descriptor.ref) {
  6641. defineReactive((scope || vm).$refs, descriptor.ref, null);
  6642. }
  6643. vm._bindDir(descriptor, el, host, scope, frag);
  6644. };
  6645. fn.terminal = true;
  6646. return fn;
  6647. }
  6648. /**
  6649. * Compile the directives on an element and return a linker.
  6650. *
  6651. * @param {Array|NamedNodeMap} attrs
  6652. * @param {Object} options
  6653. * @return {Function}
  6654. */
  6655. function compileDirectives(attrs, options) {
  6656. var i = attrs.length;
  6657. var dirs = [];
  6658. var attr, name, value, rawName, rawValue, dirName, arg, modifiers, dirDef, tokens, matched;
  6659. while (i--) {
  6660. attr = attrs[i];
  6661. name = rawName = attr.name;
  6662. value = rawValue = attr.value;
  6663. tokens = parseText(value);
  6664. // reset arg
  6665. arg = null;
  6666. // check modifiers
  6667. modifiers = parseModifiers(name);
  6668. name = name.replace(modifierRE, '');
  6669. // attribute interpolations
  6670. if (tokens) {
  6671. value = tokensToExp(tokens);
  6672. arg = name;
  6673. pushDir('bind', directives.bind, tokens);
  6674. // warn against mixing mustaches with v-bind
  6675. if ('development' !== 'production') {
  6676. if (name === 'class' && Array.prototype.some.call(attrs, function (attr) {
  6677. return attr.name === ':class' || attr.name === 'v-bind:class';
  6678. })) {
  6679. warn('class="' + rawValue + '": Do not mix mustache interpolation ' + 'and v-bind for "class" on the same element. Use one or the other.', options);
  6680. }
  6681. }
  6682. } else
  6683. // special attribute: transition
  6684. if (transitionRE.test(name)) {
  6685. modifiers.literal = !bindRE.test(name);
  6686. pushDir('transition', internalDirectives.transition);
  6687. } else
  6688. // event handlers
  6689. if (onRE.test(name)) {
  6690. arg = name.replace(onRE, '');
  6691. pushDir('on', directives.on);
  6692. } else
  6693. // attribute bindings
  6694. if (bindRE.test(name)) {
  6695. dirName = name.replace(bindRE, '');
  6696. if (dirName === 'style' || dirName === 'class') {
  6697. pushDir(dirName, internalDirectives[dirName]);
  6698. } else {
  6699. arg = dirName;
  6700. pushDir('bind', directives.bind);
  6701. }
  6702. } else
  6703. // normal directives
  6704. if (matched = name.match(dirAttrRE)) {
  6705. dirName = matched[1];
  6706. arg = matched[2];
  6707. // skip v-else (when used with v-show)
  6708. if (dirName === 'else') {
  6709. continue;
  6710. }
  6711. dirDef = resolveAsset(options, 'directives', dirName, true);
  6712. if (dirDef) {
  6713. pushDir(dirName, dirDef);
  6714. }
  6715. }
  6716. }
  6717. /**
  6718. * Push a directive.
  6719. *
  6720. * @param {String} dirName
  6721. * @param {Object|Function} def
  6722. * @param {Array} [interpTokens]
  6723. */
  6724. function pushDir(dirName, def, interpTokens) {
  6725. var hasOneTimeToken = interpTokens && hasOneTime(interpTokens);
  6726. var parsed = !hasOneTimeToken && parseDirective(value);
  6727. dirs.push({
  6728. name: dirName,
  6729. attr: rawName,
  6730. raw: rawValue,
  6731. def: def,
  6732. arg: arg,
  6733. modifiers: modifiers,
  6734. // conversion from interpolation strings with one-time token
  6735. // to expression is differed until directive bind time so that we
  6736. // have access to the actual vm context for one-time bindings.
  6737. expression: parsed && parsed.expression,
  6738. filters: parsed && parsed.filters,
  6739. interp: interpTokens,
  6740. hasOneTime: hasOneTimeToken
  6741. });
  6742. }
  6743. if (dirs.length) {
  6744. return makeNodeLinkFn(dirs);
  6745. }
  6746. }
  6747. /**
  6748. * Parse modifiers from directive attribute name.
  6749. *
  6750. * @param {String} name
  6751. * @return {Object}
  6752. */
  6753. function parseModifiers(name) {
  6754. var res = Object.create(null);
  6755. var match = name.match(modifierRE);
  6756. if (match) {
  6757. var i = match.length;
  6758. while (i--) {
  6759. res[match[i].slice(1)] = true;
  6760. }
  6761. }
  6762. return res;
  6763. }
  6764. /**
  6765. * Build a link function for all directives on a single node.
  6766. *
  6767. * @param {Array} directives
  6768. * @return {Function} directivesLinkFn
  6769. */
  6770. function makeNodeLinkFn(directives) {
  6771. return function nodeLinkFn(vm, el, host, scope, frag) {
  6772. // reverse apply because it's sorted low to high
  6773. var i = directives.length;
  6774. while (i--) {
  6775. vm._bindDir(directives[i], el, host, scope, frag);
  6776. }
  6777. };
  6778. }
  6779. /**
  6780. * Check if an interpolation string contains one-time tokens.
  6781. *
  6782. * @param {Array} tokens
  6783. * @return {Boolean}
  6784. */
  6785. function hasOneTime(tokens) {
  6786. var i = tokens.length;
  6787. while (i--) {
  6788. if (tokens[i].oneTime) return true;
  6789. }
  6790. }
  6791. function isScript(el) {
  6792. return el.tagName === 'SCRIPT' && (!el.hasAttribute('type') || el.getAttribute('type') === 'text/javascript');
  6793. }
  6794. var specialCharRE = /[^\w\-:\.]/;
  6795. /**
  6796. * Process an element or a DocumentFragment based on a
  6797. * instance option object. This allows us to transclude
  6798. * a template node/fragment before the instance is created,
  6799. * so the processed fragment can then be cloned and reused
  6800. * in v-for.
  6801. *
  6802. * @param {Element} el
  6803. * @param {Object} options
  6804. * @return {Element|DocumentFragment}
  6805. */
  6806. function transclude(el, options) {
  6807. // extract container attributes to pass them down
  6808. // to compiler, because they need to be compiled in
  6809. // parent scope. we are mutating the options object here
  6810. // assuming the same object will be used for compile
  6811. // right after this.
  6812. if (options) {
  6813. options._containerAttrs = extractAttrs(el);
  6814. }
  6815. // for template tags, what we want is its content as
  6816. // a documentFragment (for fragment instances)
  6817. if (isTemplate(el)) {
  6818. el = parseTemplate(el);
  6819. }
  6820. if (options) {
  6821. if (options._asComponent && !options.template) {
  6822. options.template = '<slot></slot>';
  6823. }
  6824. if (options.template) {
  6825. options._content = extractContent(el);
  6826. el = transcludeTemplate(el, options);
  6827. }
  6828. }
  6829. if (isFragment(el)) {
  6830. // anchors for fragment instance
  6831. // passing in `persist: true` to avoid them being
  6832. // discarded by IE during template cloning
  6833. prepend(createAnchor('v-start', true), el);
  6834. el.appendChild(createAnchor('v-end', true));
  6835. }
  6836. return el;
  6837. }
  6838. /**
  6839. * Process the template option.
  6840. * If the replace option is true this will swap the $el.
  6841. *
  6842. * @param {Element} el
  6843. * @param {Object} options
  6844. * @return {Element|DocumentFragment}
  6845. */
  6846. function transcludeTemplate(el, options) {
  6847. var template = options.template;
  6848. var frag = parseTemplate(template, true);
  6849. if (frag) {
  6850. var replacer = frag.firstChild;
  6851. var tag = replacer.tagName && replacer.tagName.toLowerCase();
  6852. if (options.replace) {
  6853. /* istanbul ignore if */
  6854. if (el === document.body) {
  6855. 'development' !== 'production' && warn('You are mounting an instance with a template to ' + '<body>. This will replace <body> entirely. You ' + 'should probably use `replace: false` here.');
  6856. }
  6857. // there are many cases where the instance must
  6858. // become a fragment instance: basically anything that
  6859. // can create more than 1 root nodes.
  6860. if (
  6861. // multi-children template
  6862. frag.childNodes.length > 1 ||
  6863. // non-element template
  6864. replacer.nodeType !== 1 ||
  6865. // single nested component
  6866. tag === 'component' || resolveAsset(options, 'components', tag) || hasBindAttr(replacer, 'is') ||
  6867. // element directive
  6868. resolveAsset(options, 'elementDirectives', tag) ||
  6869. // for block
  6870. replacer.hasAttribute('v-for') ||
  6871. // if block
  6872. replacer.hasAttribute('v-if')) {
  6873. return frag;
  6874. } else {
  6875. options._replacerAttrs = extractAttrs(replacer);
  6876. mergeAttrs(el, replacer);
  6877. return replacer;
  6878. }
  6879. } else {
  6880. el.appendChild(frag);
  6881. return el;
  6882. }
  6883. } else {
  6884. 'development' !== 'production' && warn('Invalid template option: ' + template);
  6885. }
  6886. }
  6887. /**
  6888. * Helper to extract a component container's attributes
  6889. * into a plain object array.
  6890. *
  6891. * @param {Element} el
  6892. * @return {Array}
  6893. */
  6894. function extractAttrs(el) {
  6895. if (el.nodeType === 1 && el.hasAttributes()) {
  6896. return toArray(el.attributes);
  6897. }
  6898. }
  6899. /**
  6900. * Merge the attributes of two elements, and make sure
  6901. * the class names are merged properly.
  6902. *
  6903. * @param {Element} from
  6904. * @param {Element} to
  6905. */
  6906. function mergeAttrs(from, to) {
  6907. var attrs = from.attributes;
  6908. var i = attrs.length;
  6909. var name, value;
  6910. while (i--) {
  6911. name = attrs[i].name;
  6912. value = attrs[i].value;
  6913. if (!to.hasAttribute(name) && !specialCharRE.test(name)) {
  6914. to.setAttribute(name, value);
  6915. } else if (name === 'class' && !parseText(value) && (value = value.trim())) {
  6916. value.split(/\s+/).forEach(function (cls) {
  6917. addClass(to, cls);
  6918. });
  6919. }
  6920. }
  6921. }
  6922. /**
  6923. * Scan and determine slot content distribution.
  6924. * We do this during transclusion instead at compile time so that
  6925. * the distribution is decoupled from the compilation order of
  6926. * the slots.
  6927. *
  6928. * @param {Element|DocumentFragment} template
  6929. * @param {Element} content
  6930. * @param {Vue} vm
  6931. */
  6932. function resolveSlots(vm, content) {
  6933. if (!content) {
  6934. return;
  6935. }
  6936. var contents = vm._slotContents = Object.create(null);
  6937. var el, name;
  6938. for (var i = 0, l = content.children.length; i < l; i++) {
  6939. el = content.children[i];
  6940. /* eslint-disable no-cond-assign */
  6941. if (name = el.getAttribute('slot')) {
  6942. (contents[name] || (contents[name] = [])).push(el);
  6943. }
  6944. /* eslint-enable no-cond-assign */
  6945. if ('development' !== 'production' && getBindAttr(el, 'slot')) {
  6946. warn('The "slot" attribute must be static.', vm.$parent);
  6947. }
  6948. }
  6949. for (name in contents) {
  6950. contents[name] = extractFragment(contents[name], content);
  6951. }
  6952. if (content.hasChildNodes()) {
  6953. var nodes = content.childNodes;
  6954. if (nodes.length === 1 && nodes[0].nodeType === 3 && !nodes[0].data.trim()) {
  6955. return;
  6956. }
  6957. contents['default'] = extractFragment(content.childNodes, content);
  6958. }
  6959. }
  6960. /**
  6961. * Extract qualified content nodes from a node list.
  6962. *
  6963. * @param {NodeList} nodes
  6964. * @return {DocumentFragment}
  6965. */
  6966. function extractFragment(nodes, parent) {
  6967. var frag = document.createDocumentFragment();
  6968. nodes = toArray(nodes);
  6969. for (var i = 0, l = nodes.length; i < l; i++) {
  6970. var node = nodes[i];
  6971. if (isTemplate(node) && !node.hasAttribute('v-if') && !node.hasAttribute('v-for')) {
  6972. parent.removeChild(node);
  6973. node = parseTemplate(node, true);
  6974. }
  6975. frag.appendChild(node);
  6976. }
  6977. return frag;
  6978. }
  6979. var compiler = Object.freeze({
  6980. compile: compile,
  6981. compileAndLinkProps: compileAndLinkProps,
  6982. compileRoot: compileRoot,
  6983. transclude: transclude,
  6984. resolveSlots: resolveSlots
  6985. });
  6986. function stateMixin (Vue) {
  6987. /**
  6988. * Accessor for `$data` property, since setting $data
  6989. * requires observing the new object and updating
  6990. * proxied properties.
  6991. */
  6992. Object.defineProperty(Vue.prototype, '$data', {
  6993. get: function get() {
  6994. return this._data;
  6995. },
  6996. set: function set(newData) {
  6997. if (newData !== this._data) {
  6998. this._setData(newData);
  6999. }
  7000. }
  7001. });
  7002. /**
  7003. * Setup the scope of an instance, which contains:
  7004. * - observed data
  7005. * - computed properties
  7006. * - user methods
  7007. * - meta properties
  7008. */
  7009. Vue.prototype._initState = function () {
  7010. this._initProps();
  7011. this._initMeta();
  7012. this._initMethods();
  7013. this._initData();
  7014. this._initComputed();
  7015. };
  7016. /**
  7017. * Initialize props.
  7018. */
  7019. Vue.prototype._initProps = function () {
  7020. var options = this.$options;
  7021. var el = options.el;
  7022. var props = options.props;
  7023. if (props && !el) {
  7024. 'development' !== 'production' && warn('Props will not be compiled if no `el` option is ' + 'provided at instantiation.', this);
  7025. }
  7026. // make sure to convert string selectors into element now
  7027. el = options.el = query(el);
  7028. this._propsUnlinkFn = el && el.nodeType === 1 && props
  7029. // props must be linked in proper scope if inside v-for
  7030. ? compileAndLinkProps(this, el, props, this._scope) : null;
  7031. };
  7032. /**
  7033. * Initialize the data.
  7034. */
  7035. Vue.prototype._initData = function () {
  7036. var dataFn = this.$options.data;
  7037. var data = this._data = dataFn ? dataFn() : {};
  7038. if (!isPlainObject(data)) {
  7039. data = {};
  7040. 'development' !== 'production' && warn('data functions should return an object.', this);
  7041. }
  7042. var props = this._props;
  7043. // proxy data on instance
  7044. var keys = Object.keys(data);
  7045. var i, key;
  7046. i = keys.length;
  7047. while (i--) {
  7048. key = keys[i];
  7049. // there are two scenarios where we can proxy a data key:
  7050. // 1. it's not already defined as a prop
  7051. // 2. it's provided via a instantiation option AND there are no
  7052. // template prop present
  7053. if (!props || !hasOwn(props, key)) {
  7054. this._proxy(key);
  7055. } else if ('development' !== 'production') {
  7056. warn('Data field "' + key + '" is already defined ' + 'as a prop. To provide default value for a prop, use the "default" ' + 'prop option; if you want to pass prop values to an instantiation ' + 'call, use the "propsData" option.', this);
  7057. }
  7058. }
  7059. // observe data
  7060. observe(data, this);
  7061. };
  7062. /**
  7063. * Swap the instance's $data. Called in $data's setter.
  7064. *
  7065. * @param {Object} newData
  7066. */
  7067. Vue.prototype._setData = function (newData) {
  7068. newData = newData || {};
  7069. var oldData = this._data;
  7070. this._data = newData;
  7071. var keys, key, i;
  7072. // unproxy keys not present in new data
  7073. keys = Object.keys(oldData);
  7074. i = keys.length;
  7075. while (i--) {
  7076. key = keys[i];
  7077. if (!(key in newData)) {
  7078. this._unproxy(key);
  7079. }
  7080. }
  7081. // proxy keys not already proxied,
  7082. // and trigger change for changed values
  7083. keys = Object.keys(newData);
  7084. i = keys.length;
  7085. while (i--) {
  7086. key = keys[i];
  7087. if (!hasOwn(this, key)) {
  7088. // new property
  7089. this._proxy(key);
  7090. }
  7091. }
  7092. oldData.__ob__.removeVm(this);
  7093. observe(newData, this);
  7094. this._digest();
  7095. };
  7096. /**
  7097. * Proxy a property, so that
  7098. * vm.prop === vm._data.prop
  7099. *
  7100. * @param {String} key
  7101. */
  7102. Vue.prototype._proxy = function (key) {
  7103. if (!isReserved(key)) {
  7104. // need to store ref to self here
  7105. // because these getter/setters might
  7106. // be called by child scopes via
  7107. // prototype inheritance.
  7108. var self = this;
  7109. Object.defineProperty(self, key, {
  7110. configurable: true,
  7111. enumerable: true,
  7112. get: function proxyGetter() {
  7113. return self._data[key];
  7114. },
  7115. set: function proxySetter(val) {
  7116. self._data[key] = val;
  7117. }
  7118. });
  7119. }
  7120. };
  7121. /**
  7122. * Unproxy a property.
  7123. *
  7124. * @param {String} key
  7125. */
  7126. Vue.prototype._unproxy = function (key) {
  7127. if (!isReserved(key)) {
  7128. delete this[key];
  7129. }
  7130. };
  7131. /**
  7132. * Force update on every watcher in scope.
  7133. */
  7134. Vue.prototype._digest = function () {
  7135. for (var i = 0, l = this._watchers.length; i < l; i++) {
  7136. this._watchers[i].update(true); // shallow updates
  7137. }
  7138. };
  7139. /**
  7140. * Setup computed properties. They are essentially
  7141. * special getter/setters
  7142. */
  7143. function noop() {}
  7144. Vue.prototype._initComputed = function () {
  7145. var computed = this.$options.computed;
  7146. if (computed) {
  7147. for (var key in computed) {
  7148. var userDef = computed[key];
  7149. var def = {
  7150. enumerable: true,
  7151. configurable: true
  7152. };
  7153. if (typeof userDef === 'function') {
  7154. def.get = makeComputedGetter(userDef, this);
  7155. def.set = noop;
  7156. } else {
  7157. def.get = userDef.get ? userDef.cache !== false ? makeComputedGetter(userDef.get, this) : bind(userDef.get, this) : noop;
  7158. def.set = userDef.set ? bind(userDef.set, this) : noop;
  7159. }
  7160. Object.defineProperty(this, key, def);
  7161. }
  7162. }
  7163. };
  7164. function makeComputedGetter(getter, owner) {
  7165. var watcher = new Watcher(owner, getter, null, {
  7166. lazy: true
  7167. });
  7168. return function computedGetter() {
  7169. if (watcher.dirty) {
  7170. watcher.evaluate();
  7171. }
  7172. if (Dep.target) {
  7173. watcher.depend();
  7174. }
  7175. return watcher.value;
  7176. };
  7177. }
  7178. /**
  7179. * Setup instance methods. Methods must be bound to the
  7180. * instance since they might be passed down as a prop to
  7181. * child components.
  7182. */
  7183. Vue.prototype._initMethods = function () {
  7184. var methods = this.$options.methods;
  7185. if (methods) {
  7186. for (var key in methods) {
  7187. this[key] = bind(methods[key], this);
  7188. }
  7189. }
  7190. };
  7191. /**
  7192. * Initialize meta information like $index, $key & $value.
  7193. */
  7194. Vue.prototype._initMeta = function () {
  7195. var metas = this.$options._meta;
  7196. if (metas) {
  7197. for (var key in metas) {
  7198. defineReactive(this, key, metas[key]);
  7199. }
  7200. }
  7201. };
  7202. }
  7203. var eventRE = /^v-on:|^@/;
  7204. function eventsMixin (Vue) {
  7205. /**
  7206. * Setup the instance's option events & watchers.
  7207. * If the value is a string, we pull it from the
  7208. * instance's methods by name.
  7209. */
  7210. Vue.prototype._initEvents = function () {
  7211. var options = this.$options;
  7212. if (options._asComponent) {
  7213. registerComponentEvents(this, options.el);
  7214. }
  7215. registerCallbacks(this, '$on', options.events);
  7216. registerCallbacks(this, '$watch', options.watch);
  7217. };
  7218. /**
  7219. * Register v-on events on a child component
  7220. *
  7221. * @param {Vue} vm
  7222. * @param {Element} el
  7223. */
  7224. function registerComponentEvents(vm, el) {
  7225. var attrs = el.attributes;
  7226. var name, value, handler;
  7227. for (var i = 0, l = attrs.length; i < l; i++) {
  7228. name = attrs[i].name;
  7229. if (eventRE.test(name)) {
  7230. name = name.replace(eventRE, '');
  7231. // force the expression into a statement so that
  7232. // it always dynamically resolves the method to call (#2670)
  7233. // kinda ugly hack, but does the job.
  7234. value = attrs[i].value;
  7235. if (isSimplePath(value)) {
  7236. value += '.apply(this, $arguments)';
  7237. }
  7238. handler = (vm._scope || vm._context).$eval(value, true);
  7239. handler._fromParent = true;
  7240. vm.$on(name.replace(eventRE), handler);
  7241. }
  7242. }
  7243. }
  7244. /**
  7245. * Register callbacks for option events and watchers.
  7246. *
  7247. * @param {Vue} vm
  7248. * @param {String} action
  7249. * @param {Object} hash
  7250. */
  7251. function registerCallbacks(vm, action, hash) {
  7252. if (!hash) return;
  7253. var handlers, key, i, j;
  7254. for (key in hash) {
  7255. handlers = hash[key];
  7256. if (isArray(handlers)) {
  7257. for (i = 0, j = handlers.length; i < j; i++) {
  7258. register(vm, action, key, handlers[i]);
  7259. }
  7260. } else {
  7261. register(vm, action, key, handlers);
  7262. }
  7263. }
  7264. }
  7265. /**
  7266. * Helper to register an event/watch callback.
  7267. *
  7268. * @param {Vue} vm
  7269. * @param {String} action
  7270. * @param {String} key
  7271. * @param {Function|String|Object} handler
  7272. * @param {Object} [options]
  7273. */
  7274. function register(vm, action, key, handler, options) {
  7275. var type = typeof handler;
  7276. if (type === 'function') {
  7277. vm[action](key, handler, options);
  7278. } else if (type === 'string') {
  7279. var methods = vm.$options.methods;
  7280. var method = methods && methods[handler];
  7281. if (method) {
  7282. vm[action](key, method, options);
  7283. } else {
  7284. 'development' !== 'production' && warn('Unknown method: "' + handler + '" when ' + 'registering callback for ' + action + ': "' + key + '".', vm);
  7285. }
  7286. } else if (handler && type === 'object') {
  7287. register(vm, action, key, handler.handler, handler);
  7288. }
  7289. }
  7290. /**
  7291. * Setup recursive attached/detached calls
  7292. */
  7293. Vue.prototype._initDOMHooks = function () {
  7294. this.$on('hook:attached', onAttached);
  7295. this.$on('hook:detached', onDetached);
  7296. };
  7297. /**
  7298. * Callback to recursively call attached hook on children
  7299. */
  7300. function onAttached() {
  7301. if (!this._isAttached) {
  7302. this._isAttached = true;
  7303. this.$children.forEach(callAttach);
  7304. }
  7305. }
  7306. /**
  7307. * Iterator to call attached hook
  7308. *
  7309. * @param {Vue} child
  7310. */
  7311. function callAttach(child) {
  7312. if (!child._isAttached && inDoc(child.$el)) {
  7313. child._callHook('attached');
  7314. }
  7315. }
  7316. /**
  7317. * Callback to recursively call detached hook on children
  7318. */
  7319. function onDetached() {
  7320. if (this._isAttached) {
  7321. this._isAttached = false;
  7322. this.$children.forEach(callDetach);
  7323. }
  7324. }
  7325. /**
  7326. * Iterator to call detached hook
  7327. *
  7328. * @param {Vue} child
  7329. */
  7330. function callDetach(child) {
  7331. if (child._isAttached && !inDoc(child.$el)) {
  7332. child._callHook('detached');
  7333. }
  7334. }
  7335. /**
  7336. * Trigger all handlers for a hook
  7337. *
  7338. * @param {String} hook
  7339. */
  7340. Vue.prototype._callHook = function (hook) {
  7341. this.$emit('pre-hook:' + hook);
  7342. var handlers = this.$options[hook];
  7343. if (handlers) {
  7344. for (var i = 0, j = handlers.length; i < j; i++) {
  7345. handlers[i].call(this);
  7346. }
  7347. }
  7348. this.$emit('hook:' + hook);
  7349. };
  7350. }
  7351. function noop() {}
  7352. /**
  7353. * A directive links a DOM element with a piece of data,
  7354. * which is the result of evaluating an expression.
  7355. * It registers a watcher with the expression and calls
  7356. * the DOM update function when a change is triggered.
  7357. *
  7358. * @param {Object} descriptor
  7359. * - {String} name
  7360. * - {Object} def
  7361. * - {String} expression
  7362. * - {Array<Object>} [filters]
  7363. * - {Object} [modifiers]
  7364. * - {Boolean} literal
  7365. * - {String} attr
  7366. * - {String} arg
  7367. * - {String} raw
  7368. * - {String} [ref]
  7369. * - {Array<Object>} [interp]
  7370. * - {Boolean} [hasOneTime]
  7371. * @param {Vue} vm
  7372. * @param {Node} el
  7373. * @param {Vue} [host] - transclusion host component
  7374. * @param {Object} [scope] - v-for scope
  7375. * @param {Fragment} [frag] - owner fragment
  7376. * @constructor
  7377. */
  7378. function Directive(descriptor, vm, el, host, scope, frag) {
  7379. this.vm = vm;
  7380. this.el = el;
  7381. // copy descriptor properties
  7382. this.descriptor = descriptor;
  7383. this.name = descriptor.name;
  7384. this.expression = descriptor.expression;
  7385. this.arg = descriptor.arg;
  7386. this.modifiers = descriptor.modifiers;
  7387. this.filters = descriptor.filters;
  7388. this.literal = this.modifiers && this.modifiers.literal;
  7389. // private
  7390. this._locked = false;
  7391. this._bound = false;
  7392. this._listeners = null;
  7393. // link context
  7394. this._host = host;
  7395. this._scope = scope;
  7396. this._frag = frag;
  7397. // store directives on node in dev mode
  7398. if ('development' !== 'production' && this.el) {
  7399. this.el._vue_directives = this.el._vue_directives || [];
  7400. this.el._vue_directives.push(this);
  7401. }
  7402. }
  7403. /**
  7404. * Initialize the directive, mixin definition properties,
  7405. * setup the watcher, call definition bind() and update()
  7406. * if present.
  7407. */
  7408. Directive.prototype._bind = function () {
  7409. var name = this.name;
  7410. var descriptor = this.descriptor;
  7411. // remove attribute
  7412. if ((name !== 'cloak' || this.vm._isCompiled) && this.el && this.el.removeAttribute) {
  7413. var attr = descriptor.attr || 'v-' + name;
  7414. this.el.removeAttribute(attr);
  7415. }
  7416. // copy def properties
  7417. var def = descriptor.def;
  7418. if (typeof def === 'function') {
  7419. this.update = def;
  7420. } else {
  7421. extend(this, def);
  7422. }
  7423. // setup directive params
  7424. this._setupParams();
  7425. // initial bind
  7426. if (this.bind) {
  7427. this.bind();
  7428. }
  7429. this._bound = true;
  7430. if (this.literal) {
  7431. this.update && this.update(descriptor.raw);
  7432. } else if ((this.expression || this.modifiers) && (this.update || this.twoWay) && !this._checkStatement()) {
  7433. // wrapped updater for context
  7434. var dir = this;
  7435. if (this.update) {
  7436. this._update = function (val, oldVal) {
  7437. if (!dir._locked) {
  7438. dir.update(val, oldVal);
  7439. }
  7440. };
  7441. } else {
  7442. this._update = noop;
  7443. }
  7444. var preProcess = this._preProcess ? bind(this._preProcess, this) : null;
  7445. var postProcess = this._postProcess ? bind(this._postProcess, this) : null;
  7446. var watcher = this._watcher = new Watcher(this.vm, this.expression, this._update, // callback
  7447. {
  7448. filters: this.filters,
  7449. twoWay: this.twoWay,
  7450. deep: this.deep,
  7451. preProcess: preProcess,
  7452. postProcess: postProcess,
  7453. scope: this._scope
  7454. });
  7455. // v-model with inital inline value need to sync back to
  7456. // model instead of update to DOM on init. They would
  7457. // set the afterBind hook to indicate that.
  7458. if (this.afterBind) {
  7459. this.afterBind();
  7460. } else if (this.update) {
  7461. this.update(watcher.value);
  7462. }
  7463. }
  7464. };
  7465. /**
  7466. * Setup all param attributes, e.g. track-by,
  7467. * transition-mode, etc...
  7468. */
  7469. Directive.prototype._setupParams = function () {
  7470. if (!this.params) {
  7471. return;
  7472. }
  7473. var params = this.params;
  7474. // swap the params array with a fresh object.
  7475. this.params = Object.create(null);
  7476. var i = params.length;
  7477. var key, val, mappedKey;
  7478. while (i--) {
  7479. key = hyphenate(params[i]);
  7480. mappedKey = camelize(key);
  7481. val = getBindAttr(this.el, key);
  7482. if (val != null) {
  7483. // dynamic
  7484. this._setupParamWatcher(mappedKey, val);
  7485. } else {
  7486. // static
  7487. val = getAttr(this.el, key);
  7488. if (val != null) {
  7489. this.params[mappedKey] = val === '' ? true : val;
  7490. }
  7491. }
  7492. }
  7493. };
  7494. /**
  7495. * Setup a watcher for a dynamic param.
  7496. *
  7497. * @param {String} key
  7498. * @param {String} expression
  7499. */
  7500. Directive.prototype._setupParamWatcher = function (key, expression) {
  7501. var self = this;
  7502. var called = false;
  7503. var unwatch = (this._scope || this.vm).$watch(expression, function (val, oldVal) {
  7504. self.params[key] = val;
  7505. // since we are in immediate mode,
  7506. // only call the param change callbacks if this is not the first update.
  7507. if (called) {
  7508. var cb = self.paramWatchers && self.paramWatchers[key];
  7509. if (cb) {
  7510. cb.call(self, val, oldVal);
  7511. }
  7512. } else {
  7513. called = true;
  7514. }
  7515. }, {
  7516. immediate: true,
  7517. user: false
  7518. });(this._paramUnwatchFns || (this._paramUnwatchFns = [])).push(unwatch);
  7519. };
  7520. /**
  7521. * Check if the directive is a function caller
  7522. * and if the expression is a callable one. If both true,
  7523. * we wrap up the expression and use it as the event
  7524. * handler.
  7525. *
  7526. * e.g. on-click="a++"
  7527. *
  7528. * @return {Boolean}
  7529. */
  7530. Directive.prototype._checkStatement = function () {
  7531. var expression = this.expression;
  7532. if (expression && this.acceptStatement && !isSimplePath(expression)) {
  7533. var fn = parseExpression(expression).get;
  7534. var scope = this._scope || this.vm;
  7535. var handler = function handler(e) {
  7536. scope.$event = e;
  7537. fn.call(scope, scope);
  7538. scope.$event = null;
  7539. };
  7540. if (this.filters) {
  7541. handler = scope._applyFilters(handler, null, this.filters);
  7542. }
  7543. this.update(handler);
  7544. return true;
  7545. }
  7546. };
  7547. /**
  7548. * Set the corresponding value with the setter.
  7549. * This should only be used in two-way directives
  7550. * e.g. v-model.
  7551. *
  7552. * @param {*} value
  7553. * @public
  7554. */
  7555. Directive.prototype.set = function (value) {
  7556. /* istanbul ignore else */
  7557. if (this.twoWay) {
  7558. this._withLock(function () {
  7559. this._watcher.set(value);
  7560. });
  7561. } else if ('development' !== 'production') {
  7562. warn('Directive.set() can only be used inside twoWay' + 'directives.');
  7563. }
  7564. };
  7565. /**
  7566. * Execute a function while preventing that function from
  7567. * triggering updates on this directive instance.
  7568. *
  7569. * @param {Function} fn
  7570. */
  7571. Directive.prototype._withLock = function (fn) {
  7572. var self = this;
  7573. self._locked = true;
  7574. fn.call(self);
  7575. nextTick(function () {
  7576. self._locked = false;
  7577. });
  7578. };
  7579. /**
  7580. * Convenience method that attaches a DOM event listener
  7581. * to the directive element and autometically tears it down
  7582. * during unbind.
  7583. *
  7584. * @param {String} event
  7585. * @param {Function} handler
  7586. * @param {Boolean} [useCapture]
  7587. */
  7588. Directive.prototype.on = function (event, handler, useCapture) {
  7589. on(this.el, event, handler, useCapture);(this._listeners || (this._listeners = [])).push([event, handler]);
  7590. };
  7591. /**
  7592. * Teardown the watcher and call unbind.
  7593. */
  7594. Directive.prototype._teardown = function () {
  7595. if (this._bound) {
  7596. this._bound = false;
  7597. if (this.unbind) {
  7598. this.unbind();
  7599. }
  7600. if (this._watcher) {
  7601. this._watcher.teardown();
  7602. }
  7603. var listeners = this._listeners;
  7604. var i;
  7605. if (listeners) {
  7606. i = listeners.length;
  7607. while (i--) {
  7608. off(this.el, listeners[i][0], listeners[i][1]);
  7609. }
  7610. }
  7611. var unwatchFns = this._paramUnwatchFns;
  7612. if (unwatchFns) {
  7613. i = unwatchFns.length;
  7614. while (i--) {
  7615. unwatchFns[i]();
  7616. }
  7617. }
  7618. if ('development' !== 'production' && this.el) {
  7619. this.el._vue_directives.$remove(this);
  7620. }
  7621. this.vm = this.el = this._watcher = this._listeners = null;
  7622. }
  7623. };
  7624. function lifecycleMixin (Vue) {
  7625. /**
  7626. * Update v-ref for component.
  7627. *
  7628. * @param {Boolean} remove
  7629. */
  7630. Vue.prototype._updateRef = function (remove) {
  7631. var ref = this.$options._ref;
  7632. if (ref) {
  7633. var refs = (this._scope || this._context).$refs;
  7634. if (remove) {
  7635. if (refs[ref] === this) {
  7636. refs[ref] = null;
  7637. }
  7638. } else {
  7639. refs[ref] = this;
  7640. }
  7641. }
  7642. };
  7643. /**
  7644. * Transclude, compile and link element.
  7645. *
  7646. * If a pre-compiled linker is available, that means the
  7647. * passed in element will be pre-transcluded and compiled
  7648. * as well - all we need to do is to call the linker.
  7649. *
  7650. * Otherwise we need to call transclude/compile/link here.
  7651. *
  7652. * @param {Element} el
  7653. */
  7654. Vue.prototype._compile = function (el) {
  7655. var options = this.$options;
  7656. // transclude and init element
  7657. // transclude can potentially replace original
  7658. // so we need to keep reference; this step also injects
  7659. // the template and caches the original attributes
  7660. // on the container node and replacer node.
  7661. var original = el;
  7662. el = transclude(el, options);
  7663. this._initElement(el);
  7664. // handle v-pre on root node (#2026)
  7665. if (el.nodeType === 1 && getAttr(el, 'v-pre') !== null) {
  7666. return;
  7667. }
  7668. // root is always compiled per-instance, because
  7669. // container attrs and props can be different every time.
  7670. var contextOptions = this._context && this._context.$options;
  7671. var rootLinker = compileRoot(el, options, contextOptions);
  7672. // resolve slot distribution
  7673. resolveSlots(this, options._content);
  7674. // compile and link the rest
  7675. var contentLinkFn;
  7676. var ctor = this.constructor;
  7677. // component compilation can be cached
  7678. // as long as it's not using inline-template
  7679. if (options._linkerCachable) {
  7680. contentLinkFn = ctor.linker;
  7681. if (!contentLinkFn) {
  7682. contentLinkFn = ctor.linker = compile(el, options);
  7683. }
  7684. }
  7685. // link phase
  7686. // make sure to link root with prop scope!
  7687. var rootUnlinkFn = rootLinker(this, el, this._scope);
  7688. var contentUnlinkFn = contentLinkFn ? contentLinkFn(this, el) : compile(el, options)(this, el);
  7689. // register composite unlink function
  7690. // to be called during instance destruction
  7691. this._unlinkFn = function () {
  7692. rootUnlinkFn();
  7693. // passing destroying: true to avoid searching and
  7694. // splicing the directives
  7695. contentUnlinkFn(true);
  7696. };
  7697. // finally replace original
  7698. if (options.replace) {
  7699. replace(original, el);
  7700. }
  7701. this._isCompiled = true;
  7702. this._callHook('compiled');
  7703. };
  7704. /**
  7705. * Initialize instance element. Called in the public
  7706. * $mount() method.
  7707. *
  7708. * @param {Element} el
  7709. */
  7710. Vue.prototype._initElement = function (el) {
  7711. if (isFragment(el)) {
  7712. this._isFragment = true;
  7713. this.$el = this._fragmentStart = el.firstChild;
  7714. this._fragmentEnd = el.lastChild;
  7715. // set persisted text anchors to empty
  7716. if (this._fragmentStart.nodeType === 3) {
  7717. this._fragmentStart.data = this._fragmentEnd.data = '';
  7718. }
  7719. this._fragment = el;
  7720. } else {
  7721. this.$el = el;
  7722. }
  7723. this.$el.__vue__ = this;
  7724. this._callHook('beforeCompile');
  7725. };
  7726. /**
  7727. * Create and bind a directive to an element.
  7728. *
  7729. * @param {Object} descriptor - parsed directive descriptor
  7730. * @param {Node} node - target node
  7731. * @param {Vue} [host] - transclusion host component
  7732. * @param {Object} [scope] - v-for scope
  7733. * @param {Fragment} [frag] - owner fragment
  7734. */
  7735. Vue.prototype._bindDir = function (descriptor, node, host, scope, frag) {
  7736. this._directives.push(new Directive(descriptor, this, node, host, scope, frag));
  7737. };
  7738. /**
  7739. * Teardown an instance, unobserves the data, unbind all the
  7740. * directives, turn off all the event listeners, etc.
  7741. *
  7742. * @param {Boolean} remove - whether to remove the DOM node.
  7743. * @param {Boolean} deferCleanup - if true, defer cleanup to
  7744. * be called later
  7745. */
  7746. Vue.prototype._destroy = function (remove, deferCleanup) {
  7747. if (this._isBeingDestroyed) {
  7748. if (!deferCleanup) {
  7749. this._cleanup();
  7750. }
  7751. return;
  7752. }
  7753. var destroyReady;
  7754. var pendingRemoval;
  7755. var self = this;
  7756. // Cleanup should be called either synchronously or asynchronoysly as
  7757. // callback of this.$remove(), or if remove and deferCleanup are false.
  7758. // In any case it should be called after all other removing, unbinding and
  7759. // turning of is done
  7760. var cleanupIfPossible = function cleanupIfPossible() {
  7761. if (destroyReady && !pendingRemoval && !deferCleanup) {
  7762. self._cleanup();
  7763. }
  7764. };
  7765. // remove DOM element
  7766. if (remove && this.$el) {
  7767. pendingRemoval = true;
  7768. this.$remove(function () {
  7769. pendingRemoval = false;
  7770. cleanupIfPossible();
  7771. });
  7772. }
  7773. this._callHook('beforeDestroy');
  7774. this._isBeingDestroyed = true;
  7775. var i;
  7776. // remove self from parent. only necessary
  7777. // if parent is not being destroyed as well.
  7778. var parent = this.$parent;
  7779. if (parent && !parent._isBeingDestroyed) {
  7780. parent.$children.$remove(this);
  7781. // unregister ref (remove: true)
  7782. this._updateRef(true);
  7783. }
  7784. // destroy all children.
  7785. i = this.$children.length;
  7786. while (i--) {
  7787. this.$children[i].$destroy();
  7788. }
  7789. // teardown props
  7790. if (this._propsUnlinkFn) {
  7791. this._propsUnlinkFn();
  7792. }
  7793. // teardown all directives. this also tearsdown all
  7794. // directive-owned watchers.
  7795. if (this._unlinkFn) {
  7796. this._unlinkFn();
  7797. }
  7798. i = this._watchers.length;
  7799. while (i--) {
  7800. this._watchers[i].teardown();
  7801. }
  7802. // remove reference to self on $el
  7803. if (this.$el) {
  7804. this.$el.__vue__ = null;
  7805. }
  7806. destroyReady = true;
  7807. cleanupIfPossible();
  7808. };
  7809. /**
  7810. * Clean up to ensure garbage collection.
  7811. * This is called after the leave transition if there
  7812. * is any.
  7813. */
  7814. Vue.prototype._cleanup = function () {
  7815. if (this._isDestroyed) {
  7816. return;
  7817. }
  7818. // remove self from owner fragment
  7819. // do it in cleanup so that we can call $destroy with
  7820. // defer right when a fragment is about to be removed.
  7821. if (this._frag) {
  7822. this._frag.children.$remove(this);
  7823. }
  7824. // remove reference from data ob
  7825. // frozen object may not have observer.
  7826. if (this._data && this._data.__ob__) {
  7827. this._data.__ob__.removeVm(this);
  7828. }
  7829. // Clean up references to private properties and other
  7830. // instances. preserve reference to _data so that proxy
  7831. // accessors still work. The only potential side effect
  7832. // here is that mutating the instance after it's destroyed
  7833. // may affect the state of other components that are still
  7834. // observing the same object, but that seems to be a
  7835. // reasonable responsibility for the user rather than
  7836. // always throwing an error on them.
  7837. this.$el = this.$parent = this.$root = this.$children = this._watchers = this._context = this._scope = this._directives = null;
  7838. // call the last hook...
  7839. this._isDestroyed = true;
  7840. this._callHook('destroyed');
  7841. // turn off all instance listeners.
  7842. this.$off();
  7843. };
  7844. }
  7845. function miscMixin (Vue) {
  7846. /**
  7847. * Apply a list of filter (descriptors) to a value.
  7848. * Using plain for loops here because this will be called in
  7849. * the getter of any watcher with filters so it is very
  7850. * performance sensitive.
  7851. *
  7852. * @param {*} value
  7853. * @param {*} [oldValue]
  7854. * @param {Array} filters
  7855. * @param {Boolean} write
  7856. * @return {*}
  7857. */
  7858. Vue.prototype._applyFilters = function (value, oldValue, filters, write) {
  7859. var filter, fn, args, arg, offset, i, l, j, k;
  7860. for (i = 0, l = filters.length; i < l; i++) {
  7861. filter = filters[write ? l - i - 1 : i];
  7862. fn = resolveAsset(this.$options, 'filters', filter.name, true);
  7863. if (!fn) continue;
  7864. fn = write ? fn.write : fn.read || fn;
  7865. if (typeof fn !== 'function') continue;
  7866. args = write ? [value, oldValue] : [value];
  7867. offset = write ? 2 : 1;
  7868. if (filter.args) {
  7869. for (j = 0, k = filter.args.length; j < k; j++) {
  7870. arg = filter.args[j];
  7871. args[j + offset] = arg.dynamic ? this.$get(arg.value) : arg.value;
  7872. }
  7873. }
  7874. value = fn.apply(this, args);
  7875. }
  7876. return value;
  7877. };
  7878. /**
  7879. * Resolve a component, depending on whether the component
  7880. * is defined normally or using an async factory function.
  7881. * Resolves synchronously if already resolved, otherwise
  7882. * resolves asynchronously and caches the resolved
  7883. * constructor on the factory.
  7884. *
  7885. * @param {String|Function} value
  7886. * @param {Function} cb
  7887. */
  7888. Vue.prototype._resolveComponent = function (value, cb) {
  7889. var factory;
  7890. if (typeof value === 'function') {
  7891. factory = value;
  7892. } else {
  7893. factory = resolveAsset(this.$options, 'components', value, true);
  7894. }
  7895. /* istanbul ignore if */
  7896. if (!factory) {
  7897. return;
  7898. }
  7899. // async component factory
  7900. if (!factory.options) {
  7901. if (factory.resolved) {
  7902. // cached
  7903. cb(factory.resolved);
  7904. } else if (factory.requested) {
  7905. // pool callbacks
  7906. factory.pendingCallbacks.push(cb);
  7907. } else {
  7908. factory.requested = true;
  7909. var cbs = factory.pendingCallbacks = [cb];
  7910. factory.call(this, function resolve(res) {
  7911. if (isPlainObject(res)) {
  7912. res = Vue.extend(res);
  7913. }
  7914. // cache resolved
  7915. factory.resolved = res;
  7916. // invoke callbacks
  7917. for (var i = 0, l = cbs.length; i < l; i++) {
  7918. cbs[i](res);
  7919. }
  7920. }, function reject(reason) {
  7921. 'development' !== 'production' && warn('Failed to resolve async component' + (typeof value === 'string' ? ': ' + value : '') + '. ' + (reason ? '\nReason: ' + reason : ''));
  7922. });
  7923. }
  7924. } else {
  7925. // normal component
  7926. cb(factory);
  7927. }
  7928. };
  7929. }
  7930. var filterRE$1 = /[^|]\|[^|]/;
  7931. function dataAPI (Vue) {
  7932. /**
  7933. * Get the value from an expression on this vm.
  7934. *
  7935. * @param {String} exp
  7936. * @param {Boolean} [asStatement]
  7937. * @return {*}
  7938. */
  7939. Vue.prototype.$get = function (exp, asStatement) {
  7940. var res = parseExpression(exp);
  7941. if (res) {
  7942. if (asStatement) {
  7943. var self = this;
  7944. return function statementHandler() {
  7945. self.$arguments = toArray(arguments);
  7946. var result = res.get.call(self, self);
  7947. self.$arguments = null;
  7948. return result;
  7949. };
  7950. } else {
  7951. try {
  7952. return res.get.call(this, this);
  7953. } catch (e) {}
  7954. }
  7955. }
  7956. };
  7957. /**
  7958. * Set the value from an expression on this vm.
  7959. * The expression must be a valid left-hand
  7960. * expression in an assignment.
  7961. *
  7962. * @param {String} exp
  7963. * @param {*} val
  7964. */
  7965. Vue.prototype.$set = function (exp, val) {
  7966. var res = parseExpression(exp, true);
  7967. if (res && res.set) {
  7968. res.set.call(this, this, val);
  7969. }
  7970. };
  7971. /**
  7972. * Delete a property on the VM
  7973. *
  7974. * @param {String} key
  7975. */
  7976. Vue.prototype.$delete = function (key) {
  7977. del(this._data, key);
  7978. };
  7979. /**
  7980. * Watch an expression, trigger callback when its
  7981. * value changes.
  7982. *
  7983. * @param {String|Function} expOrFn
  7984. * @param {Function} cb
  7985. * @param {Object} [options]
  7986. * - {Boolean} deep
  7987. * - {Boolean} immediate
  7988. * @return {Function} - unwatchFn
  7989. */
  7990. Vue.prototype.$watch = function (expOrFn, cb, options) {
  7991. var vm = this;
  7992. var parsed;
  7993. if (typeof expOrFn === 'string') {
  7994. parsed = parseDirective(expOrFn);
  7995. expOrFn = parsed.expression;
  7996. }
  7997. var watcher = new Watcher(vm, expOrFn, cb, {
  7998. deep: options && options.deep,
  7999. sync: options && options.sync,
  8000. filters: parsed && parsed.filters,
  8001. user: !options || options.user !== false
  8002. });
  8003. if (options && options.immediate) {
  8004. cb.call(vm, watcher.value);
  8005. }
  8006. return function unwatchFn() {
  8007. watcher.teardown();
  8008. };
  8009. };
  8010. /**
  8011. * Evaluate a text directive, including filters.
  8012. *
  8013. * @param {String} text
  8014. * @param {Boolean} [asStatement]
  8015. * @return {String}
  8016. */
  8017. Vue.prototype.$eval = function (text, asStatement) {
  8018. // check for filters.
  8019. if (filterRE$1.test(text)) {
  8020. var dir = parseDirective(text);
  8021. // the filter regex check might give false positive
  8022. // for pipes inside strings, so it's possible that
  8023. // we don't get any filters here
  8024. var val = this.$get(dir.expression, asStatement);
  8025. return dir.filters ? this._applyFilters(val, null, dir.filters) : val;
  8026. } else {
  8027. // no filter
  8028. return this.$get(text, asStatement);
  8029. }
  8030. };
  8031. /**
  8032. * Interpolate a piece of template text.
  8033. *
  8034. * @param {String} text
  8035. * @return {String}
  8036. */
  8037. Vue.prototype.$interpolate = function (text) {
  8038. var tokens = parseText(text);
  8039. var vm = this;
  8040. if (tokens) {
  8041. if (tokens.length === 1) {
  8042. return vm.$eval(tokens[0].value) + '';
  8043. } else {
  8044. return tokens.map(function (token) {
  8045. return token.tag ? vm.$eval(token.value) : token.value;
  8046. }).join('');
  8047. }
  8048. } else {
  8049. return text;
  8050. }
  8051. };
  8052. /**
  8053. * Log instance data as a plain JS object
  8054. * so that it is easier to inspect in console.
  8055. * This method assumes console is available.
  8056. *
  8057. * @param {String} [path]
  8058. */
  8059. Vue.prototype.$log = function (path) {
  8060. var data = path ? getPath(this._data, path) : this._data;
  8061. if (data) {
  8062. data = clean(data);
  8063. }
  8064. // include computed fields
  8065. if (!path) {
  8066. var key;
  8067. for (key in this.$options.computed) {
  8068. data[key] = clean(this[key]);
  8069. }
  8070. if (this._props) {
  8071. for (key in this._props) {
  8072. data[key] = clean(this[key]);
  8073. }
  8074. }
  8075. }
  8076. console.log(data);
  8077. };
  8078. /**
  8079. * "clean" a getter/setter converted object into a plain
  8080. * object copy.
  8081. *
  8082. * @param {Object} - obj
  8083. * @return {Object}
  8084. */
  8085. function clean(obj) {
  8086. return JSON.parse(JSON.stringify(obj));
  8087. }
  8088. }
  8089. function domAPI (Vue) {
  8090. /**
  8091. * Convenience on-instance nextTick. The callback is
  8092. * auto-bound to the instance, and this avoids component
  8093. * modules having to rely on the global Vue.
  8094. *
  8095. * @param {Function} fn
  8096. */
  8097. Vue.prototype.$nextTick = function (fn) {
  8098. nextTick(fn, this);
  8099. };
  8100. /**
  8101. * Append instance to target
  8102. *
  8103. * @param {Node} target
  8104. * @param {Function} [cb]
  8105. * @param {Boolean} [withTransition] - defaults to true
  8106. */
  8107. Vue.prototype.$appendTo = function (target, cb, withTransition) {
  8108. return insert(this, target, cb, withTransition, append, appendWithTransition);
  8109. };
  8110. /**
  8111. * Prepend instance to target
  8112. *
  8113. * @param {Node} target
  8114. * @param {Function} [cb]
  8115. * @param {Boolean} [withTransition] - defaults to true
  8116. */
  8117. Vue.prototype.$prependTo = function (target, cb, withTransition) {
  8118. target = query(target);
  8119. if (target.hasChildNodes()) {
  8120. this.$before(target.firstChild, cb, withTransition);
  8121. } else {
  8122. this.$appendTo(target, cb, withTransition);
  8123. }
  8124. return this;
  8125. };
  8126. /**
  8127. * Insert instance before target
  8128. *
  8129. * @param {Node} target
  8130. * @param {Function} [cb]
  8131. * @param {Boolean} [withTransition] - defaults to true
  8132. */
  8133. Vue.prototype.$before = function (target, cb, withTransition) {
  8134. return insert(this, target, cb, withTransition, beforeWithCb, beforeWithTransition);
  8135. };
  8136. /**
  8137. * Insert instance after target
  8138. *
  8139. * @param {Node} target
  8140. * @param {Function} [cb]
  8141. * @param {Boolean} [withTransition] - defaults to true
  8142. */
  8143. Vue.prototype.$after = function (target, cb, withTransition) {
  8144. target = query(target);
  8145. if (target.nextSibling) {
  8146. this.$before(target.nextSibling, cb, withTransition);
  8147. } else {
  8148. this.$appendTo(target.parentNode, cb, withTransition);
  8149. }
  8150. return this;
  8151. };
  8152. /**
  8153. * Remove instance from DOM
  8154. *
  8155. * @param {Function} [cb]
  8156. * @param {Boolean} [withTransition] - defaults to true
  8157. */
  8158. Vue.prototype.$remove = function (cb, withTransition) {
  8159. if (!this.$el.parentNode) {
  8160. return cb && cb();
  8161. }
  8162. var inDocument = this._isAttached && inDoc(this.$el);
  8163. // if we are not in document, no need to check
  8164. // for transitions
  8165. if (!inDocument) withTransition = false;
  8166. var self = this;
  8167. var realCb = function realCb() {
  8168. if (inDocument) self._callHook('detached');
  8169. if (cb) cb();
  8170. };
  8171. if (this._isFragment) {
  8172. removeNodeRange(this._fragmentStart, this._fragmentEnd, this, this._fragment, realCb);
  8173. } else {
  8174. var op = withTransition === false ? removeWithCb : removeWithTransition;
  8175. op(this.$el, this, realCb);
  8176. }
  8177. return this;
  8178. };
  8179. /**
  8180. * Shared DOM insertion function.
  8181. *
  8182. * @param {Vue} vm
  8183. * @param {Element} target
  8184. * @param {Function} [cb]
  8185. * @param {Boolean} [withTransition]
  8186. * @param {Function} op1 - op for non-transition insert
  8187. * @param {Function} op2 - op for transition insert
  8188. * @return vm
  8189. */
  8190. function insert(vm, target, cb, withTransition, op1, op2) {
  8191. target = query(target);
  8192. var targetIsDetached = !inDoc(target);
  8193. var op = withTransition === false || targetIsDetached ? op1 : op2;
  8194. var shouldCallHook = !targetIsDetached && !vm._isAttached && !inDoc(vm.$el);
  8195. if (vm._isFragment) {
  8196. mapNodeRange(vm._fragmentStart, vm._fragmentEnd, function (node) {
  8197. op(node, target, vm);
  8198. });
  8199. cb && cb();
  8200. } else {
  8201. op(vm.$el, target, vm, cb);
  8202. }
  8203. if (shouldCallHook) {
  8204. vm._callHook('attached');
  8205. }
  8206. return vm;
  8207. }
  8208. /**
  8209. * Check for selectors
  8210. *
  8211. * @param {String|Element} el
  8212. */
  8213. function query(el) {
  8214. return typeof el === 'string' ? document.querySelector(el) : el;
  8215. }
  8216. /**
  8217. * Append operation that takes a callback.
  8218. *
  8219. * @param {Node} el
  8220. * @param {Node} target
  8221. * @param {Vue} vm - unused
  8222. * @param {Function} [cb]
  8223. */
  8224. function append(el, target, vm, cb) {
  8225. target.appendChild(el);
  8226. if (cb) cb();
  8227. }
  8228. /**
  8229. * InsertBefore operation that takes a callback.
  8230. *
  8231. * @param {Node} el
  8232. * @param {Node} target
  8233. * @param {Vue} vm - unused
  8234. * @param {Function} [cb]
  8235. */
  8236. function beforeWithCb(el, target, vm, cb) {
  8237. before(el, target);
  8238. if (cb) cb();
  8239. }
  8240. /**
  8241. * Remove operation that takes a callback.
  8242. *
  8243. * @param {Node} el
  8244. * @param {Vue} vm - unused
  8245. * @param {Function} [cb]
  8246. */
  8247. function removeWithCb(el, vm, cb) {
  8248. remove(el);
  8249. if (cb) cb();
  8250. }
  8251. }
  8252. function eventsAPI (Vue) {
  8253. /**
  8254. * Listen on the given `event` with `fn`.
  8255. *
  8256. * @param {String} event
  8257. * @param {Function} fn
  8258. */
  8259. Vue.prototype.$on = function (event, fn) {
  8260. (this._events[event] || (this._events[event] = [])).push(fn);
  8261. modifyListenerCount(this, event, 1);
  8262. return this;
  8263. };
  8264. /**
  8265. * Adds an `event` listener that will be invoked a single
  8266. * time then automatically removed.
  8267. *
  8268. * @param {String} event
  8269. * @param {Function} fn
  8270. */
  8271. Vue.prototype.$once = function (event, fn) {
  8272. var self = this;
  8273. function on() {
  8274. self.$off(event, on);
  8275. fn.apply(this, arguments);
  8276. }
  8277. on.fn = fn;
  8278. this.$on(event, on);
  8279. return this;
  8280. };
  8281. /**
  8282. * Remove the given callback for `event` or all
  8283. * registered callbacks.
  8284. *
  8285. * @param {String} event
  8286. * @param {Function} fn
  8287. */
  8288. Vue.prototype.$off = function (event, fn) {
  8289. var cbs;
  8290. // all
  8291. if (!arguments.length) {
  8292. if (this.$parent) {
  8293. for (event in this._events) {
  8294. cbs = this._events[event];
  8295. if (cbs) {
  8296. modifyListenerCount(this, event, -cbs.length);
  8297. }
  8298. }
  8299. }
  8300. this._events = {};
  8301. return this;
  8302. }
  8303. // specific event
  8304. cbs = this._events[event];
  8305. if (!cbs) {
  8306. return this;
  8307. }
  8308. if (arguments.length === 1) {
  8309. modifyListenerCount(this, event, -cbs.length);
  8310. this._events[event] = null;
  8311. return this;
  8312. }
  8313. // specific handler
  8314. var cb;
  8315. var i = cbs.length;
  8316. while (i--) {
  8317. cb = cbs[i];
  8318. if (cb === fn || cb.fn === fn) {
  8319. modifyListenerCount(this, event, -1);
  8320. cbs.splice(i, 1);
  8321. break;
  8322. }
  8323. }
  8324. return this;
  8325. };
  8326. /**
  8327. * Trigger an event on self.
  8328. *
  8329. * @param {String|Object} event
  8330. * @return {Boolean} shouldPropagate
  8331. */
  8332. Vue.prototype.$emit = function (event) {
  8333. var isSource = typeof event === 'string';
  8334. event = isSource ? event : event.name;
  8335. var cbs = this._events[event];
  8336. var shouldPropagate = isSource || !cbs;
  8337. if (cbs) {
  8338. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  8339. // this is a somewhat hacky solution to the question raised
  8340. // in #2102: for an inline component listener like <comp @test="doThis">,
  8341. // the propagation handling is somewhat broken. Therefore we
  8342. // need to treat these inline callbacks differently.
  8343. var hasParentCbs = isSource && cbs.some(function (cb) {
  8344. return cb._fromParent;
  8345. });
  8346. if (hasParentCbs) {
  8347. shouldPropagate = false;
  8348. }
  8349. var args = toArray(arguments, 1);
  8350. for (var i = 0, l = cbs.length; i < l; i++) {
  8351. var cb = cbs[i];
  8352. var res = cb.apply(this, args);
  8353. if (res === true && (!hasParentCbs || cb._fromParent)) {
  8354. shouldPropagate = true;
  8355. }
  8356. }
  8357. }
  8358. return shouldPropagate;
  8359. };
  8360. /**
  8361. * Recursively broadcast an event to all children instances.
  8362. *
  8363. * @param {String|Object} event
  8364. * @param {...*} additional arguments
  8365. */
  8366. Vue.prototype.$broadcast = function (event) {
  8367. var isSource = typeof event === 'string';
  8368. event = isSource ? event : event.name;
  8369. // if no child has registered for this event,
  8370. // then there's no need to broadcast.
  8371. if (!this._eventsCount[event]) return;
  8372. var children = this.$children;
  8373. var args = toArray(arguments);
  8374. if (isSource) {
  8375. // use object event to indicate non-source emit
  8376. // on children
  8377. args[0] = { name: event, source: this };
  8378. }
  8379. for (var i = 0, l = children.length; i < l; i++) {
  8380. var child = children[i];
  8381. var shouldPropagate = child.$emit.apply(child, args);
  8382. if (shouldPropagate) {
  8383. child.$broadcast.apply(child, args);
  8384. }
  8385. }
  8386. return this;
  8387. };
  8388. /**
  8389. * Recursively propagate an event up the parent chain.
  8390. *
  8391. * @param {String} event
  8392. * @param {...*} additional arguments
  8393. */
  8394. Vue.prototype.$dispatch = function (event) {
  8395. var shouldPropagate = this.$emit.apply(this, arguments);
  8396. if (!shouldPropagate) return;
  8397. var parent = this.$parent;
  8398. var args = toArray(arguments);
  8399. // use object event to indicate non-source emit
  8400. // on parents
  8401. args[0] = { name: event, source: this };
  8402. while (parent) {
  8403. shouldPropagate = parent.$emit.apply(parent, args);
  8404. parent = shouldPropagate ? parent.$parent : null;
  8405. }
  8406. return this;
  8407. };
  8408. /**
  8409. * Modify the listener counts on all parents.
  8410. * This bookkeeping allows $broadcast to return early when
  8411. * no child has listened to a certain event.
  8412. *
  8413. * @param {Vue} vm
  8414. * @param {String} event
  8415. * @param {Number} count
  8416. */
  8417. var hookRE = /^hook:/;
  8418. function modifyListenerCount(vm, event, count) {
  8419. var parent = vm.$parent;
  8420. // hooks do not get broadcasted so no need
  8421. // to do bookkeeping for them
  8422. if (!parent || !count || hookRE.test(event)) return;
  8423. while (parent) {
  8424. parent._eventsCount[event] = (parent._eventsCount[event] || 0) + count;
  8425. parent = parent.$parent;
  8426. }
  8427. }
  8428. }
  8429. function lifecycleAPI (Vue) {
  8430. /**
  8431. * Set instance target element and kick off the compilation
  8432. * process. The passed in `el` can be a selector string, an
  8433. * existing Element, or a DocumentFragment (for block
  8434. * instances).
  8435. *
  8436. * @param {Element|DocumentFragment|string} el
  8437. * @public
  8438. */
  8439. Vue.prototype.$mount = function (el) {
  8440. if (this._isCompiled) {
  8441. 'development' !== 'production' && warn('$mount() should be called only once.', this);
  8442. return;
  8443. }
  8444. el = query(el);
  8445. if (!el) {
  8446. el = document.createElement('div');
  8447. }
  8448. this._compile(el);
  8449. this._initDOMHooks();
  8450. if (inDoc(this.$el)) {
  8451. this._callHook('attached');
  8452. ready.call(this);
  8453. } else {
  8454. this.$once('hook:attached', ready);
  8455. }
  8456. return this;
  8457. };
  8458. /**
  8459. * Mark an instance as ready.
  8460. */
  8461. function ready() {
  8462. this._isAttached = true;
  8463. this._isReady = true;
  8464. this._callHook('ready');
  8465. }
  8466. /**
  8467. * Teardown the instance, simply delegate to the internal
  8468. * _destroy.
  8469. *
  8470. * @param {Boolean} remove
  8471. * @param {Boolean} deferCleanup
  8472. */
  8473. Vue.prototype.$destroy = function (remove, deferCleanup) {
  8474. this._destroy(remove, deferCleanup);
  8475. };
  8476. /**
  8477. * Partially compile a piece of DOM and return a
  8478. * decompile function.
  8479. *
  8480. * @param {Element|DocumentFragment} el
  8481. * @param {Vue} [host]
  8482. * @param {Object} [scope]
  8483. * @param {Fragment} [frag]
  8484. * @return {Function}
  8485. */
  8486. Vue.prototype.$compile = function (el, host, scope, frag) {
  8487. return compile(el, this.$options, true)(this, el, host, scope, frag);
  8488. };
  8489. }
  8490. /**
  8491. * The exposed Vue constructor.
  8492. *
  8493. * API conventions:
  8494. * - public API methods/properties are prefixed with `$`
  8495. * - internal methods/properties are prefixed with `_`
  8496. * - non-prefixed properties are assumed to be proxied user
  8497. * data.
  8498. *
  8499. * @constructor
  8500. * @param {Object} [options]
  8501. * @public
  8502. */
  8503. function Vue(options) {
  8504. this._init(options);
  8505. }
  8506. // install internals
  8507. initMixin(Vue);
  8508. stateMixin(Vue);
  8509. eventsMixin(Vue);
  8510. lifecycleMixin(Vue);
  8511. miscMixin(Vue);
  8512. // install instance APIs
  8513. dataAPI(Vue);
  8514. domAPI(Vue);
  8515. eventsAPI(Vue);
  8516. lifecycleAPI(Vue);
  8517. var slot = {
  8518. priority: SLOT,
  8519. params: ['name'],
  8520. bind: function bind() {
  8521. // this was resolved during component transclusion
  8522. var name = this.params.name || 'default';
  8523. var content = this.vm._slotContents && this.vm._slotContents[name];
  8524. if (!content || !content.hasChildNodes()) {
  8525. this.fallback();
  8526. } else {
  8527. this.compile(content.cloneNode(true), this.vm._context, this.vm);
  8528. }
  8529. },
  8530. compile: function compile(content, context, host) {
  8531. if (content && context) {
  8532. if (this.el.hasChildNodes() && content.childNodes.length === 1 && content.childNodes[0].nodeType === 1 && content.childNodes[0].hasAttribute('v-if')) {
  8533. // if the inserted slot has v-if
  8534. // inject fallback content as the v-else
  8535. var elseBlock = document.createElement('template');
  8536. elseBlock.setAttribute('v-else', '');
  8537. elseBlock.innerHTML = this.el.innerHTML;
  8538. // the else block should be compiled in child scope
  8539. elseBlock._context = this.vm;
  8540. content.appendChild(elseBlock);
  8541. }
  8542. var scope = host ? host._scope : this._scope;
  8543. this.unlink = context.$compile(content, host, scope, this._frag);
  8544. }
  8545. if (content) {
  8546. replace(this.el, content);
  8547. } else {
  8548. remove(this.el);
  8549. }
  8550. },
  8551. fallback: function fallback() {
  8552. this.compile(extractContent(this.el, true), this.vm);
  8553. },
  8554. unbind: function unbind() {
  8555. if (this.unlink) {
  8556. this.unlink();
  8557. }
  8558. }
  8559. };
  8560. var partial = {
  8561. priority: PARTIAL,
  8562. params: ['name'],
  8563. // watch changes to name for dynamic partials
  8564. paramWatchers: {
  8565. name: function name(value) {
  8566. vIf.remove.call(this);
  8567. if (value) {
  8568. this.insert(value);
  8569. }
  8570. }
  8571. },
  8572. bind: function bind() {
  8573. this.anchor = createAnchor('v-partial');
  8574. replace(this.el, this.anchor);
  8575. this.insert(this.params.name);
  8576. },
  8577. insert: function insert(id) {
  8578. var partial = resolveAsset(this.vm.$options, 'partials', id, true);
  8579. if (partial) {
  8580. this.factory = new FragmentFactory(this.vm, partial);
  8581. vIf.insert.call(this);
  8582. }
  8583. },
  8584. unbind: function unbind() {
  8585. if (this.frag) {
  8586. this.frag.destroy();
  8587. }
  8588. }
  8589. };
  8590. var elementDirectives = {
  8591. slot: slot,
  8592. partial: partial
  8593. };
  8594. var convertArray = vFor._postProcess;
  8595. /**
  8596. * Limit filter for arrays
  8597. *
  8598. * @param {Number} n
  8599. * @param {Number} offset (Decimal expected)
  8600. */
  8601. function limitBy(arr, n, offset) {
  8602. offset = offset ? parseInt(offset, 10) : 0;
  8603. n = toNumber(n);
  8604. return typeof n === 'number' ? arr.slice(offset, offset + n) : arr;
  8605. }
  8606. /**
  8607. * Filter filter for arrays
  8608. *
  8609. * @param {String} search
  8610. * @param {String} [delimiter]
  8611. * @param {String} ...dataKeys
  8612. */
  8613. function filterBy(arr, search, delimiter) {
  8614. arr = convertArray(arr);
  8615. if (search == null) {
  8616. return arr;
  8617. }
  8618. if (typeof search === 'function') {
  8619. return arr.filter(search);
  8620. }
  8621. // cast to lowercase string
  8622. search = ('' + search).toLowerCase();
  8623. // allow optional `in` delimiter
  8624. // because why not
  8625. var n = delimiter === 'in' ? 3 : 2;
  8626. // extract and flatten keys
  8627. var keys = Array.prototype.concat.apply([], toArray(arguments, n));
  8628. var res = [];
  8629. var item, key, val, j;
  8630. for (var i = 0, l = arr.length; i < l; i++) {
  8631. item = arr[i];
  8632. val = item && item.$value || item;
  8633. j = keys.length;
  8634. if (j) {
  8635. while (j--) {
  8636. key = keys[j];
  8637. if (key === '$key' && contains(item.$key, search) || contains(getPath(val, key), search)) {
  8638. res.push(item);
  8639. break;
  8640. }
  8641. }
  8642. } else if (contains(item, search)) {
  8643. res.push(item);
  8644. }
  8645. }
  8646. return res;
  8647. }
  8648. /**
  8649. * Filter filter for arrays
  8650. *
  8651. * @param {String|Array<String>|Function} ...sortKeys
  8652. * @param {Number} [order]
  8653. */
  8654. function orderBy(arr) {
  8655. var comparator = null;
  8656. var sortKeys = undefined;
  8657. arr = convertArray(arr);
  8658. // determine order (last argument)
  8659. var args = toArray(arguments, 1);
  8660. var order = args[args.length - 1];
  8661. if (typeof order === 'number') {
  8662. order = order < 0 ? -1 : 1;
  8663. args = args.length > 1 ? args.slice(0, -1) : args;
  8664. } else {
  8665. order = 1;
  8666. }
  8667. // determine sortKeys & comparator
  8668. var firstArg = args[0];
  8669. if (!firstArg) {
  8670. return arr;
  8671. } else if (typeof firstArg === 'function') {
  8672. // custom comparator
  8673. comparator = function (a, b) {
  8674. return firstArg(a, b) * order;
  8675. };
  8676. } else {
  8677. // string keys. flatten first
  8678. sortKeys = Array.prototype.concat.apply([], args);
  8679. comparator = function (a, b, i) {
  8680. i = i || 0;
  8681. return i >= sortKeys.length - 1 ? baseCompare(a, b, i) : baseCompare(a, b, i) || comparator(a, b, i + 1);
  8682. };
  8683. }
  8684. function baseCompare(a, b, sortKeyIndex) {
  8685. var sortKey = sortKeys[sortKeyIndex];
  8686. if (sortKey) {
  8687. if (sortKey !== '$key') {
  8688. if (isObject(a) && '$value' in a) a = a.$value;
  8689. if (isObject(b) && '$value' in b) b = b.$value;
  8690. }
  8691. a = isObject(a) ? getPath(a, sortKey) : a;
  8692. b = isObject(b) ? getPath(b, sortKey) : b;
  8693. }
  8694. return a === b ? 0 : a > b ? order : -order;
  8695. }
  8696. // sort on a copy to avoid mutating original array
  8697. return arr.slice().sort(comparator);
  8698. }
  8699. /**
  8700. * String contain helper
  8701. *
  8702. * @param {*} val
  8703. * @param {String} search
  8704. */
  8705. function contains(val, search) {
  8706. var i;
  8707. if (isPlainObject(val)) {
  8708. var keys = Object.keys(val);
  8709. i = keys.length;
  8710. while (i--) {
  8711. if (contains(val[keys[i]], search)) {
  8712. return true;
  8713. }
  8714. }
  8715. } else if (isArray(val)) {
  8716. i = val.length;
  8717. while (i--) {
  8718. if (contains(val[i], search)) {
  8719. return true;
  8720. }
  8721. }
  8722. } else if (val != null) {
  8723. return val.toString().toLowerCase().indexOf(search) > -1;
  8724. }
  8725. }
  8726. var digitsRE = /(\d{3})(?=\d)/g;
  8727. // asset collections must be a plain object.
  8728. var filters = {
  8729. orderBy: orderBy,
  8730. filterBy: filterBy,
  8731. limitBy: limitBy,
  8732. /**
  8733. * Stringify value.
  8734. *
  8735. * @param {Number} indent
  8736. */
  8737. json: {
  8738. read: function read(value, indent) {
  8739. return typeof value === 'string' ? value : JSON.stringify(value, null, Number(indent) || 2);
  8740. },
  8741. write: function write(value) {
  8742. try {
  8743. return JSON.parse(value);
  8744. } catch (e) {
  8745. return value;
  8746. }
  8747. }
  8748. },
  8749. /**
  8750. * 'abc' => 'Abc'
  8751. */
  8752. capitalize: function capitalize(value) {
  8753. if (!value && value !== 0) return '';
  8754. value = value.toString();
  8755. return value.charAt(0).toUpperCase() + value.slice(1);
  8756. },
  8757. /**
  8758. * 'abc' => 'ABC'
  8759. */
  8760. uppercase: function uppercase(value) {
  8761. return value || value === 0 ? value.toString().toUpperCase() : '';
  8762. },
  8763. /**
  8764. * 'AbC' => 'abc'
  8765. */
  8766. lowercase: function lowercase(value) {
  8767. return value || value === 0 ? value.toString().toLowerCase() : '';
  8768. },
  8769. /**
  8770. * 12345 => $12,345.00
  8771. *
  8772. * @param {String} sign
  8773. * @param {Number} decimals Decimal places
  8774. */
  8775. currency: function currency(value, _currency, decimals) {
  8776. value = parseFloat(value);
  8777. if (!isFinite(value) || !value && value !== 0) return '';
  8778. _currency = _currency != null ? _currency : '$';
  8779. decimals = decimals != null ? decimals : 2;
  8780. var stringified = Math.abs(value).toFixed(decimals);
  8781. var _int = decimals ? stringified.slice(0, -1 - decimals) : stringified;
  8782. var i = _int.length % 3;
  8783. var head = i > 0 ? _int.slice(0, i) + (_int.length > 3 ? ',' : '') : '';
  8784. var _float = decimals ? stringified.slice(-1 - decimals) : '';
  8785. var sign = value < 0 ? '-' : '';
  8786. return sign + _currency + head + _int.slice(i).replace(digitsRE, '$1,') + _float;
  8787. },
  8788. /**
  8789. * 'item' => 'items'
  8790. *
  8791. * @params
  8792. * an array of strings corresponding to
  8793. * the single, double, triple ... forms of the word to
  8794. * be pluralized. When the number to be pluralized
  8795. * exceeds the length of the args, it will use the last
  8796. * entry in the array.
  8797. *
  8798. * e.g. ['single', 'double', 'triple', 'multiple']
  8799. */
  8800. pluralize: function pluralize(value) {
  8801. var args = toArray(arguments, 1);
  8802. return args.length > 1 ? args[value % 10 - 1] || args[args.length - 1] : args[0] + (value === 1 ? '' : 's');
  8803. },
  8804. /**
  8805. * Debounce a handler function.
  8806. *
  8807. * @param {Function} handler
  8808. * @param {Number} delay = 300
  8809. * @return {Function}
  8810. */
  8811. debounce: function debounce(handler, delay) {
  8812. if (!handler) return;
  8813. if (!delay) {
  8814. delay = 300;
  8815. }
  8816. return _debounce(handler, delay);
  8817. }
  8818. };
  8819. function installGlobalAPI (Vue) {
  8820. /**
  8821. * Vue and every constructor that extends Vue has an
  8822. * associated options object, which can be accessed during
  8823. * compilation steps as `this.constructor.options`.
  8824. *
  8825. * These can be seen as the default options of every
  8826. * Vue instance.
  8827. */
  8828. Vue.options = {
  8829. directives: directives,
  8830. elementDirectives: elementDirectives,
  8831. filters: filters,
  8832. transitions: {},
  8833. components: {},
  8834. partials: {},
  8835. replace: true
  8836. };
  8837. /**
  8838. * Expose useful internals
  8839. */
  8840. Vue.util = util;
  8841. Vue.config = config;
  8842. Vue.set = set;
  8843. Vue['delete'] = del;
  8844. Vue.nextTick = nextTick;
  8845. /**
  8846. * The following are exposed for advanced usage / plugins
  8847. */
  8848. Vue.compiler = compiler;
  8849. Vue.FragmentFactory = FragmentFactory;
  8850. Vue.internalDirectives = internalDirectives;
  8851. Vue.parsers = {
  8852. path: path,
  8853. text: text,
  8854. template: template,
  8855. directive: directive,
  8856. expression: expression
  8857. };
  8858. /**
  8859. * Each instance constructor, including Vue, has a unique
  8860. * cid. This enables us to create wrapped "child
  8861. * constructors" for prototypal inheritance and cache them.
  8862. */
  8863. Vue.cid = 0;
  8864. var cid = 1;
  8865. /**
  8866. * Class inheritance
  8867. *
  8868. * @param {Object} extendOptions
  8869. */
  8870. Vue.extend = function (extendOptions) {
  8871. extendOptions = extendOptions || {};
  8872. var Super = this;
  8873. var isFirstExtend = Super.cid === 0;
  8874. if (isFirstExtend && extendOptions._Ctor) {
  8875. return extendOptions._Ctor;
  8876. }
  8877. var name = extendOptions.name || Super.options.name;
  8878. if ('development' !== 'production') {
  8879. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  8880. warn('Invalid component name: "' + name + '". Component names ' + 'can only contain alphanumeric characaters and the hyphen.');
  8881. name = null;
  8882. }
  8883. }
  8884. var Sub = createClass(name || 'VueComponent');
  8885. Sub.prototype = Object.create(Super.prototype);
  8886. Sub.prototype.constructor = Sub;
  8887. Sub.cid = cid++;
  8888. Sub.options = mergeOptions(Super.options, extendOptions);
  8889. Sub['super'] = Super;
  8890. // allow further extension
  8891. Sub.extend = Super.extend;
  8892. // create asset registers, so extended classes
  8893. // can have their private assets too.
  8894. config._assetTypes.forEach(function (type) {
  8895. Sub[type] = Super[type];
  8896. });
  8897. // enable recursive self-lookup
  8898. if (name) {
  8899. Sub.options.components[name] = Sub;
  8900. }
  8901. // cache constructor
  8902. if (isFirstExtend) {
  8903. extendOptions._Ctor = Sub;
  8904. }
  8905. return Sub;
  8906. };
  8907. /**
  8908. * A function that returns a sub-class constructor with the
  8909. * given name. This gives us much nicer output when
  8910. * logging instances in the console.
  8911. *
  8912. * @param {String} name
  8913. * @return {Function}
  8914. */
  8915. function createClass(name) {
  8916. /* eslint-disable no-new-func */
  8917. return new Function('return function ' + classify(name) + ' (options) { this._init(options) }')();
  8918. /* eslint-enable no-new-func */
  8919. }
  8920. /**
  8921. * Plugin system
  8922. *
  8923. * @param {Object} plugin
  8924. */
  8925. Vue.use = function (plugin) {
  8926. /* istanbul ignore if */
  8927. if (plugin.installed) {
  8928. return;
  8929. }
  8930. // additional parameters
  8931. var args = toArray(arguments, 1);
  8932. args.unshift(this);
  8933. if (typeof plugin.install === 'function') {
  8934. plugin.install.apply(plugin, args);
  8935. } else {
  8936. plugin.apply(null, args);
  8937. }
  8938. plugin.installed = true;
  8939. return this;
  8940. };
  8941. /**
  8942. * Apply a global mixin by merging it into the default
  8943. * options.
  8944. */
  8945. Vue.mixin = function (mixin) {
  8946. Vue.options = mergeOptions(Vue.options, mixin);
  8947. };
  8948. /**
  8949. * Create asset registration methods with the following
  8950. * signature:
  8951. *
  8952. * @param {String} id
  8953. * @param {*} definition
  8954. */
  8955. config._assetTypes.forEach(function (type) {
  8956. Vue[type] = function (id, definition) {
  8957. if (!definition) {
  8958. return this.options[type + 's'][id];
  8959. } else {
  8960. /* istanbul ignore if */
  8961. if ('development' !== 'production') {
  8962. if (type === 'component' && (commonTagRE.test(id) || reservedTagRE.test(id))) {
  8963. warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + id);
  8964. }
  8965. }
  8966. if (type === 'component' && isPlainObject(definition)) {
  8967. definition.name = id;
  8968. definition = Vue.extend(definition);
  8969. }
  8970. this.options[type + 's'][id] = definition;
  8971. return definition;
  8972. }
  8973. };
  8974. });
  8975. // expose internal transition API
  8976. extend(Vue.transition, transition);
  8977. }
  8978. installGlobalAPI(Vue);
  8979. Vue.version = '1.0.24';
  8980. // devtools global hook
  8981. /* istanbul ignore next */
  8982. setTimeout(function () {
  8983. if (config.devtools) {
  8984. if (devtools) {
  8985. devtools.emit('init', Vue);
  8986. } else if ('development' !== 'production' && inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent)) {
  8987. console.log('Download the Vue Devtools for a better development experience:\n' + 'https://github.com/vuejs/vue-devtools');
  8988. }
  8989. }
  8990. }, 0);
  8991. return Vue;
  8992. }));