vue.js 175 KB

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