factory.js 183 KB

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