vue.runtime.js 151 KB

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