factory.js 178 KB

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