vue.runtime.common.js 156 KB

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