vue.common.js 145 KB

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