build.js 135 KB

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