vue.runtime.common.js 170 KB

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