项目原始demo,不改动
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var deindent = _interopDefault(require('de-indent'));
  5. var he = _interopDefault(require('he'));
  6. /* */
  7. var emptyObject = Object.freeze({});
  8. // these helpers produces better vm code in JS engines due to their
  9. // explicitness and function inlining
  10. function isUndef (v) {
  11. return v === undefined || v === null
  12. }
  13. /**
  14. * Check if value is primitive
  15. */
  16. function isPrimitive (value) {
  17. return (
  18. typeof value === 'string' ||
  19. typeof value === 'number' ||
  20. // $flow-disable-line
  21. typeof value === 'symbol' ||
  22. typeof value === 'boolean'
  23. )
  24. }
  25. /**
  26. * Quick object check - this is primarily used to tell
  27. * Objects from primitive values when we know the value
  28. * is a JSON-compliant type.
  29. */
  30. function isObject (obj) {
  31. return obj !== null && typeof obj === 'object'
  32. }
  33. /**
  34. * Get the raw type string of a value e.g. [object Object]
  35. */
  36. var _toString = Object.prototype.toString;
  37. function toRawType (value) {
  38. return _toString.call(value).slice(8, -1)
  39. }
  40. /**
  41. * Strict object type check. Only returns true
  42. * for plain JavaScript objects.
  43. */
  44. function isPlainObject (obj) {
  45. return _toString.call(obj) === '[object Object]'
  46. }
  47. /**
  48. * Check if val is a valid array index.
  49. */
  50. function isValidArrayIndex (val) {
  51. var n = parseFloat(String(val));
  52. return n >= 0 && Math.floor(n) === n && isFinite(val)
  53. }
  54. /**
  55. * Convert a value to a string that is actually rendered.
  56. */
  57. /**
  58. * Convert a input value to a number for persistence.
  59. * If the conversion fails, return original string.
  60. */
  61. /**
  62. * Make a map and return a function for checking if a key
  63. * is in that map.
  64. */
  65. function makeMap (
  66. str,
  67. expectsLowerCase
  68. ) {
  69. var map = Object.create(null);
  70. var list = str.split(',');
  71. for (var i = 0; i < list.length; i++) {
  72. map[list[i]] = true;
  73. }
  74. return expectsLowerCase
  75. ? function (val) { return map[val.toLowerCase()]; }
  76. : function (val) { return map[val]; }
  77. }
  78. /**
  79. * Check if a tag is a built-in tag.
  80. */
  81. var isBuiltInTag = makeMap('slot,component', true);
  82. /**
  83. * Check if a attribute is a reserved attribute.
  84. */
  85. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  86. /**
  87. * Remove an item from an array
  88. */
  89. function remove (arr, item) {
  90. if (arr.length) {
  91. var index = arr.indexOf(item);
  92. if (index > -1) {
  93. return arr.splice(index, 1)
  94. }
  95. }
  96. }
  97. /**
  98. * Check whether the object has the property.
  99. */
  100. var hasOwnProperty = Object.prototype.hasOwnProperty;
  101. function hasOwn (obj, key) {
  102. return hasOwnProperty.call(obj, key)
  103. }
  104. /**
  105. * Create a cached version of a pure function.
  106. */
  107. function cached (fn) {
  108. var cache = Object.create(null);
  109. return (function cachedFn (str) {
  110. var hit = cache[str];
  111. return hit || (cache[str] = fn(str))
  112. })
  113. }
  114. /**
  115. * Camelize a hyphen-delimited string.
  116. */
  117. var camelizeRE = /-(\w)/g;
  118. var camelize = cached(function (str) {
  119. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  120. });
  121. /**
  122. * Capitalize a string.
  123. */
  124. /**
  125. * Simple bind polyfill for environments that do not support it... e.g.
  126. * PhantomJS 1.x. Technically we don't need this anymore since native bind is
  127. * now more performant in most browsers, but removing it would be breaking for
  128. * code that was able to run in PhantomJS 1.x, so this must be kept for
  129. * backwards compatibility.
  130. */
  131. /* istanbul ignore next */
  132. function polyfillBind (fn, ctx) {
  133. function boundFn (a) {
  134. var l = arguments.length;
  135. return l
  136. ? l > 1
  137. ? fn.apply(ctx, arguments)
  138. : fn.call(ctx, a)
  139. : fn.call(ctx)
  140. }
  141. boundFn._length = fn.length;
  142. return boundFn
  143. }
  144. function nativeBind (fn, ctx) {
  145. return fn.bind(ctx)
  146. }
  147. var bind = Function.prototype.bind
  148. ? nativeBind
  149. : polyfillBind;
  150. /**
  151. * Convert an Array-like object to a real Array.
  152. */
  153. /**
  154. * Mix properties into target object.
  155. */
  156. function extend (to, _from) {
  157. for (var key in _from) {
  158. to[key] = _from[key];
  159. }
  160. return to
  161. }
  162. /**
  163. * Merge an Array of Objects into a single Object.
  164. */
  165. /**
  166. * Perform no operation.
  167. * Stubbing args to make Flow happy without leaving useless transpiled code
  168. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
  169. */
  170. function noop (a, b, c) {}
  171. /**
  172. * Always return false.
  173. */
  174. var no = function (a, b, c) { return false; };
  175. /**
  176. * Return same value
  177. */
  178. var identity = function (_) { return _; };
  179. /**
  180. * Generate a static keys string from compiler modules.
  181. */
  182. function genStaticKeys (modules) {
  183. return modules.reduce(function (keys, m) {
  184. return keys.concat(m.staticKeys || [])
  185. }, []).join(',')
  186. }
  187. /**
  188. * Check if two values are loosely equal - that is,
  189. * if they are plain objects, do they have the same shape?
  190. */
  191. /**
  192. * Ensure a function is called only once.
  193. */
  194. /* */
  195. var isUnaryTag = makeMap(
  196. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  197. 'link,meta,param,source,track,wbr'
  198. );
  199. // Elements that you can, intentionally, leave open
  200. // (and which close themselves)
  201. var canBeLeftOpenTag = makeMap(
  202. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  203. );
  204. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  205. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  206. var isNonPhrasingTag = makeMap(
  207. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  208. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  209. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  210. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  211. 'title,tr,track'
  212. );
  213. /**
  214. * Not type-checking this file because it's mostly vendor code.
  215. */
  216. /*!
  217. * HTML Parser By John Resig (ejohn.org)
  218. * Modified by Juriy "kangax" Zaytsev
  219. * Original code by Erik Arvidsson, Mozilla Public License
  220. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  221. */
  222. // Regular Expressions for parsing tags and attributes
  223. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  224. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  225. // but for Vue templates we can enforce a simple charset
  226. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  227. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  228. var startTagOpen = new RegExp(("^<" + qnameCapture));
  229. var startTagClose = /^\s*(\/?)>/;
  230. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  231. var doctype = /^<!DOCTYPE [^>]+>/i;
  232. // #7298: escape - to avoid being pased as HTML comment when inlined in page
  233. var comment = /^<!\--/;
  234. var conditionalComment = /^<!\[/;
  235. var IS_REGEX_CAPTURING_BROKEN = false;
  236. 'x'.replace(/x(.)?/g, function (m, g) {
  237. IS_REGEX_CAPTURING_BROKEN = g === '';
  238. });
  239. // Special Elements (can contain anything)
  240. var isPlainTextElement = makeMap('script,style,textarea', true);
  241. var reCache = {};
  242. var decodingMap = {
  243. '&lt;': '<',
  244. '&gt;': '>',
  245. '&quot;': '"',
  246. '&amp;': '&',
  247. '&#10;': '\n',
  248. '&#9;': '\t'
  249. };
  250. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  251. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g;
  252. // #5992
  253. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  254. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  255. function decodeAttr (value, shouldDecodeNewlines) {
  256. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  257. return value.replace(re, function (match) { return decodingMap[match]; })
  258. }
  259. function parseHTML (html, options) {
  260. var stack = [];
  261. var expectHTML = options.expectHTML;
  262. var isUnaryTag$$1 = options.isUnaryTag || no;
  263. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  264. var index = 0;
  265. var last, lastTag;
  266. while (html) {
  267. last = html;
  268. // Make sure we're not in a plaintext content element like script/style
  269. if (!lastTag || !isPlainTextElement(lastTag)) {
  270. var textEnd = html.indexOf('<');
  271. if (textEnd === 0) {
  272. // Comment:
  273. if (comment.test(html)) {
  274. var commentEnd = html.indexOf('-->');
  275. if (commentEnd >= 0) {
  276. if (options.shouldKeepComment) {
  277. options.comment(html.substring(4, commentEnd));
  278. }
  279. advance(commentEnd + 3);
  280. continue
  281. }
  282. }
  283. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  284. if (conditionalComment.test(html)) {
  285. var conditionalEnd = html.indexOf(']>');
  286. if (conditionalEnd >= 0) {
  287. advance(conditionalEnd + 2);
  288. continue
  289. }
  290. }
  291. // Doctype:
  292. var doctypeMatch = html.match(doctype);
  293. if (doctypeMatch) {
  294. advance(doctypeMatch[0].length);
  295. continue
  296. }
  297. // End tag:
  298. var endTagMatch = html.match(endTag);
  299. if (endTagMatch) {
  300. var curIndex = index;
  301. advance(endTagMatch[0].length);
  302. parseEndTag(endTagMatch[1], curIndex, index);
  303. continue
  304. }
  305. // Start tag:
  306. var startTagMatch = parseStartTag();
  307. if (startTagMatch) {
  308. handleStartTag(startTagMatch);
  309. if (shouldIgnoreFirstNewline(lastTag, html)) {
  310. advance(1);
  311. }
  312. continue
  313. }
  314. }
  315. var text = (void 0), rest = (void 0), next = (void 0);
  316. if (textEnd >= 0) {
  317. rest = html.slice(textEnd);
  318. while (
  319. !endTag.test(rest) &&
  320. !startTagOpen.test(rest) &&
  321. !comment.test(rest) &&
  322. !conditionalComment.test(rest)
  323. ) {
  324. // < in plain text, be forgiving and treat it as text
  325. next = rest.indexOf('<', 1);
  326. if (next < 0) { break }
  327. textEnd += next;
  328. rest = html.slice(textEnd);
  329. }
  330. text = html.substring(0, textEnd);
  331. advance(textEnd);
  332. }
  333. if (textEnd < 0) {
  334. text = html;
  335. html = '';
  336. }
  337. if (options.chars && text) {
  338. options.chars(text);
  339. }
  340. } else {
  341. var endTagLength = 0;
  342. var stackedTag = lastTag.toLowerCase();
  343. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  344. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  345. endTagLength = endTag.length;
  346. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  347. text = text
  348. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  349. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  350. }
  351. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  352. text = text.slice(1);
  353. }
  354. if (options.chars) {
  355. options.chars(text);
  356. }
  357. return ''
  358. });
  359. index += html.length - rest$1.length;
  360. html = rest$1;
  361. parseEndTag(stackedTag, index - endTagLength, index);
  362. }
  363. if (html === last) {
  364. options.chars && options.chars(html);
  365. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  366. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  367. }
  368. break
  369. }
  370. }
  371. // Clean up any remaining tags
  372. parseEndTag();
  373. function advance (n) {
  374. index += n;
  375. html = html.substring(n);
  376. }
  377. function parseStartTag () {
  378. var start = html.match(startTagOpen);
  379. if (start) {
  380. var match = {
  381. tagName: start[1],
  382. attrs: [],
  383. start: index
  384. };
  385. advance(start[0].length);
  386. var end, attr;
  387. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  388. advance(attr[0].length);
  389. match.attrs.push(attr);
  390. }
  391. if (end) {
  392. match.unarySlash = end[1];
  393. advance(end[0].length);
  394. match.end = index;
  395. return match
  396. }
  397. }
  398. }
  399. function handleStartTag (match) {
  400. var tagName = match.tagName;
  401. var unarySlash = match.unarySlash;
  402. if (expectHTML) {
  403. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  404. parseEndTag(lastTag);
  405. }
  406. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  407. parseEndTag(tagName);
  408. }
  409. }
  410. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  411. var l = match.attrs.length;
  412. var attrs = new Array(l);
  413. for (var i = 0; i < l; i++) {
  414. var args = match.attrs[i];
  415. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  416. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  417. if (args[3] === '') { delete args[3]; }
  418. if (args[4] === '') { delete args[4]; }
  419. if (args[5] === '') { delete args[5]; }
  420. }
  421. var value = args[3] || args[4] || args[5] || '';
  422. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  423. ? options.shouldDecodeNewlinesForHref
  424. : options.shouldDecodeNewlines;
  425. attrs[i] = {
  426. name: args[1],
  427. value: decodeAttr(value, shouldDecodeNewlines)
  428. };
  429. }
  430. if (!unary) {
  431. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  432. lastTag = tagName;
  433. }
  434. if (options.start) {
  435. options.start(tagName, attrs, unary, match.start, match.end);
  436. }
  437. }
  438. function parseEndTag (tagName, start, end) {
  439. var pos, lowerCasedTagName;
  440. if (start == null) { start = index; }
  441. if (end == null) { end = index; }
  442. if (tagName) {
  443. lowerCasedTagName = tagName.toLowerCase();
  444. }
  445. // Find the closest opened tag of the same type
  446. if (tagName) {
  447. for (pos = stack.length - 1; pos >= 0; pos--) {
  448. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  449. break
  450. }
  451. }
  452. } else {
  453. // If no tag name is provided, clean shop
  454. pos = 0;
  455. }
  456. if (pos >= 0) {
  457. // Close all the open elements, up the stack
  458. for (var i = stack.length - 1; i >= pos; i--) {
  459. if (process.env.NODE_ENV !== 'production' &&
  460. (i > pos || !tagName) &&
  461. options.warn
  462. ) {
  463. options.warn(
  464. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  465. );
  466. }
  467. if (options.end) {
  468. options.end(stack[i].tag, start, end);
  469. }
  470. }
  471. // Remove the open elements from the stack
  472. stack.length = pos;
  473. lastTag = pos && stack[pos - 1].tag;
  474. } else if (lowerCasedTagName === 'br') {
  475. if (options.start) {
  476. options.start(tagName, [], true, start, end);
  477. }
  478. } else if (lowerCasedTagName === 'p') {
  479. if (options.start) {
  480. options.start(tagName, [], false, start, end);
  481. }
  482. if (options.end) {
  483. options.end(tagName, start, end);
  484. }
  485. }
  486. }
  487. }
  488. /* */
  489. var splitRE = /\r?\n/g;
  490. var replaceRE = /./g;
  491. var isSpecialTag = makeMap('script,style,template', true);
  492. /**
  493. * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
  494. */
  495. function parseComponent (
  496. content,
  497. options
  498. ) {
  499. if ( options === void 0 ) options = {};
  500. var sfc = {
  501. template: null,
  502. script: null,
  503. styles: [],
  504. customBlocks: []
  505. };
  506. var depth = 0;
  507. var currentBlock = null;
  508. function start (
  509. tag,
  510. attrs,
  511. unary,
  512. start,
  513. end
  514. ) {
  515. if (depth === 0) {
  516. currentBlock = {
  517. type: tag,
  518. content: '',
  519. start: end,
  520. attrs: attrs.reduce(function (cumulated, ref) {
  521. var name = ref.name;
  522. var value = ref.value;
  523. cumulated[name] = value || true;
  524. return cumulated
  525. }, {})
  526. };
  527. if (isSpecialTag(tag)) {
  528. checkAttrs(currentBlock, attrs);
  529. if (tag === 'style') {
  530. sfc.styles.push(currentBlock);
  531. } else {
  532. sfc[tag] = currentBlock;
  533. }
  534. } else { // custom blocks
  535. sfc.customBlocks.push(currentBlock);
  536. }
  537. }
  538. if (!unary) {
  539. depth++;
  540. }
  541. }
  542. function checkAttrs (block, attrs) {
  543. for (var i = 0; i < attrs.length; i++) {
  544. var attr = attrs[i];
  545. if (attr.name === 'lang') {
  546. block.lang = attr.value;
  547. }
  548. if (attr.name === 'scoped') {
  549. block.scoped = true;
  550. }
  551. if (attr.name === 'module') {
  552. block.module = attr.value || true;
  553. }
  554. if (attr.name === 'src') {
  555. block.src = attr.value;
  556. }
  557. }
  558. }
  559. function end (tag, start, end) {
  560. if (depth === 1 && currentBlock) {
  561. currentBlock.end = start;
  562. var text = deindent(content.slice(currentBlock.start, currentBlock.end));
  563. // pad content so that linters and pre-processors can output correct
  564. // line numbers in errors and warnings
  565. if (currentBlock.type !== 'template' && options.pad) {
  566. text = padContent(currentBlock, options.pad) + text;
  567. }
  568. currentBlock.content = text;
  569. currentBlock = null;
  570. }
  571. depth--;
  572. }
  573. function padContent (block, pad) {
  574. if (pad === 'space') {
  575. return content.slice(0, block.start).replace(replaceRE, ' ')
  576. } else {
  577. var offset = content.slice(0, block.start).split(splitRE).length;
  578. var padChar = block.type === 'script' && !block.lang
  579. ? '//\n'
  580. : '\n';
  581. return Array(offset).join(padChar)
  582. }
  583. }
  584. parseHTML(content, {
  585. start: start,
  586. end: end
  587. });
  588. return sfc
  589. }
  590. /* */
  591. /**
  592. * Check if a string starts with $ or _
  593. */
  594. /**
  595. * Define a property.
  596. */
  597. function def (obj, key, val, enumerable) {
  598. Object.defineProperty(obj, key, {
  599. value: val,
  600. enumerable: !!enumerable,
  601. writable: true,
  602. configurable: true
  603. });
  604. }
  605. /* */
  606. // can we use __proto__?
  607. var hasProto = '__proto__' in {};
  608. // Browser environment sniffing
  609. var inBrowser = typeof window !== 'undefined';
  610. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  611. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  612. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  613. var isIE = UA && /msie|trident/.test(UA);
  614. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  615. var isEdge = UA && UA.indexOf('edge/') > 0;
  616. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  617. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  618. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  619. // Firefox has a "watch" function on Object.prototype...
  620. var nativeWatch = ({}).watch;
  621. if (inBrowser) {
  622. try {
  623. var opts = {};
  624. Object.defineProperty(opts, 'passive', ({
  625. get: function get () {
  626. /* istanbul ignore next */
  627. }
  628. })); // https://github.com/facebook/flow/issues/285
  629. window.addEventListener('test-passive', null, opts);
  630. } catch (e) {}
  631. }
  632. // this needs to be lazy-evaled because vue may be required before
  633. // vue-server-renderer can set VUE_ENV
  634. var _isServer;
  635. var isServerRendering = function () {
  636. if (_isServer === undefined) {
  637. /* istanbul ignore if */
  638. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  639. // detect presence of vue-server-renderer and avoid
  640. // Webpack shimming the process
  641. _isServer = global['process'].env.VUE_ENV === 'server';
  642. } else {
  643. _isServer = false;
  644. }
  645. }
  646. return _isServer
  647. };
  648. // detect devtools
  649. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  650. /* istanbul ignore next */
  651. function isNative (Ctor) {
  652. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  653. }
  654. var hasSymbol =
  655. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  656. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  657. /* istanbul ignore if */ // $flow-disable-line
  658. if (typeof Set !== 'undefined' && isNative(Set)) {
  659. // use native Set when available.
  660. } else {
  661. // a non-standard Set polyfill that only works with primitive keys.
  662. }
  663. var ASSET_TYPES = [
  664. 'component',
  665. 'directive',
  666. 'filter'
  667. ];
  668. var LIFECYCLE_HOOKS = [
  669. 'beforeCreate',
  670. 'created',
  671. 'beforeMount',
  672. 'mounted',
  673. 'beforeUpdate',
  674. 'updated',
  675. 'beforeDestroy',
  676. 'destroyed',
  677. 'activated',
  678. 'deactivated',
  679. 'errorCaptured'
  680. ];
  681. /* */
  682. var config = ({
  683. /**
  684. * Option merge strategies (used in core/util/options)
  685. */
  686. // $flow-disable-line
  687. optionMergeStrategies: Object.create(null),
  688. /**
  689. * Whether to suppress warnings.
  690. */
  691. silent: false,
  692. /**
  693. * Show production mode tip message on boot?
  694. */
  695. productionTip: process.env.NODE_ENV !== 'production',
  696. /**
  697. * Whether to enable devtools
  698. */
  699. devtools: process.env.NODE_ENV !== 'production',
  700. /**
  701. * Whether to record perf
  702. */
  703. performance: false,
  704. /**
  705. * Error handler for watcher errors
  706. */
  707. errorHandler: null,
  708. /**
  709. * Warn handler for watcher warns
  710. */
  711. warnHandler: null,
  712. /**
  713. * Ignore certain custom elements
  714. */
  715. ignoredElements: [],
  716. /**
  717. * Custom user key aliases for v-on
  718. */
  719. // $flow-disable-line
  720. keyCodes: Object.create(null),
  721. /**
  722. * Check if a tag is reserved so that it cannot be registered as a
  723. * component. This is platform-dependent and may be overwritten.
  724. */
  725. isReservedTag: no,
  726. /**
  727. * Check if an attribute is reserved so that it cannot be used as a component
  728. * prop. This is platform-dependent and may be overwritten.
  729. */
  730. isReservedAttr: no,
  731. /**
  732. * Check if a tag is an unknown element.
  733. * Platform-dependent.
  734. */
  735. isUnknownElement: no,
  736. /**
  737. * Get the namespace of an element
  738. */
  739. getTagNamespace: noop,
  740. /**
  741. * Parse the real tag name for the specific platform.
  742. */
  743. parsePlatformTagName: identity,
  744. /**
  745. * Check if an attribute must be bound using property, e.g. value
  746. * Platform-dependent.
  747. */
  748. mustUseProp: no,
  749. /**
  750. * Exposed for legacy reasons
  751. */
  752. _lifecycleHooks: LIFECYCLE_HOOKS
  753. })
  754. /* */
  755. var warn = noop;
  756. var tip = noop;
  757. var generateComponentTrace = (noop); // work around flow check
  758. var formatComponentName = (noop);
  759. if (process.env.NODE_ENV !== 'production') {
  760. var hasConsole = typeof console !== 'undefined';
  761. var classifyRE = /(?:^|[-_])(\w)/g;
  762. var classify = function (str) { return str
  763. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  764. .replace(/[-_]/g, ''); };
  765. warn = function (msg, vm) {
  766. var trace = vm ? generateComponentTrace(vm) : '';
  767. if (config.warnHandler) {
  768. config.warnHandler.call(null, msg, vm, trace);
  769. } else if (hasConsole && (!config.silent)) {
  770. console.error(("[Vue warn]: " + msg + trace));
  771. }
  772. };
  773. tip = function (msg, vm) {
  774. if (hasConsole && (!config.silent)) {
  775. console.warn("[Vue tip]: " + msg + (
  776. vm ? generateComponentTrace(vm) : ''
  777. ));
  778. }
  779. };
  780. formatComponentName = function (vm, includeFile) {
  781. if (vm.$root === vm) {
  782. return '<Root>'
  783. }
  784. var options = typeof vm === 'function' && vm.cid != null
  785. ? vm.options
  786. : vm._isVue
  787. ? vm.$options || vm.constructor.options
  788. : vm || {};
  789. var name = options.name || options._componentTag;
  790. var file = options.__file;
  791. if (!name && file) {
  792. var match = file.match(/([^/\\]+)\.vue$/);
  793. name = match && match[1];
  794. }
  795. return (
  796. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  797. (file && includeFile !== false ? (" at " + file) : '')
  798. )
  799. };
  800. var repeat = function (str, n) {
  801. var res = '';
  802. while (n) {
  803. if (n % 2 === 1) { res += str; }
  804. if (n > 1) { str += str; }
  805. n >>= 1;
  806. }
  807. return res
  808. };
  809. generateComponentTrace = function (vm) {
  810. if (vm._isVue && vm.$parent) {
  811. var tree = [];
  812. var currentRecursiveSequence = 0;
  813. while (vm) {
  814. if (tree.length > 0) {
  815. var last = tree[tree.length - 1];
  816. if (last.constructor === vm.constructor) {
  817. currentRecursiveSequence++;
  818. vm = vm.$parent;
  819. continue
  820. } else if (currentRecursiveSequence > 0) {
  821. tree[tree.length - 1] = [last, currentRecursiveSequence];
  822. currentRecursiveSequence = 0;
  823. }
  824. }
  825. tree.push(vm);
  826. vm = vm.$parent;
  827. }
  828. return '\n\nfound in\n\n' + tree
  829. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  830. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  831. : formatComponentName(vm))); })
  832. .join('\n')
  833. } else {
  834. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  835. }
  836. };
  837. }
  838. /* */
  839. var uid = 0;
  840. /**
  841. * A dep is an observable that can have multiple
  842. * directives subscribing to it.
  843. */
  844. var Dep = function Dep () {
  845. this.id = uid++;
  846. this.subs = [];
  847. };
  848. Dep.prototype.addSub = function addSub (sub) {
  849. this.subs.push(sub);
  850. };
  851. Dep.prototype.removeSub = function removeSub (sub) {
  852. remove(this.subs, sub);
  853. };
  854. Dep.prototype.depend = function depend () {
  855. if (Dep.target) {
  856. Dep.target.addDep(this);
  857. }
  858. };
  859. Dep.prototype.notify = function notify () {
  860. // stabilize the subscriber list first
  861. var subs = this.subs.slice();
  862. for (var i = 0, l = subs.length; i < l; i++) {
  863. subs[i].update();
  864. }
  865. };
  866. // the current target watcher being evaluated.
  867. // this is globally unique because there could be only one
  868. // watcher being evaluated at any time.
  869. Dep.target = null;
  870. /* */
  871. var VNode = function VNode (
  872. tag,
  873. data,
  874. children,
  875. text,
  876. elm,
  877. context,
  878. componentOptions,
  879. asyncFactory
  880. ) {
  881. this.tag = tag;
  882. this.data = data;
  883. this.children = children;
  884. this.text = text;
  885. this.elm = elm;
  886. this.ns = undefined;
  887. this.context = context;
  888. this.fnContext = undefined;
  889. this.fnOptions = undefined;
  890. this.fnScopeId = undefined;
  891. this.key = data && data.key;
  892. this.componentOptions = componentOptions;
  893. this.componentInstance = undefined;
  894. this.parent = undefined;
  895. this.raw = false;
  896. this.isStatic = false;
  897. this.isRootInsert = true;
  898. this.isComment = false;
  899. this.isCloned = false;
  900. this.isOnce = false;
  901. this.asyncFactory = asyncFactory;
  902. this.asyncMeta = undefined;
  903. this.isAsyncPlaceholder = false;
  904. };
  905. var prototypeAccessors = { child: { configurable: true } };
  906. // DEPRECATED: alias for componentInstance for backwards compat.
  907. /* istanbul ignore next */
  908. prototypeAccessors.child.get = function () {
  909. return this.componentInstance
  910. };
  911. Object.defineProperties( VNode.prototype, prototypeAccessors );
  912. // optimized shallow clone
  913. // used for static nodes and slot nodes because they may be reused across
  914. // multiple renders, cloning them avoids errors when DOM manipulations rely
  915. // on their elm reference.
  916. /*
  917. * not type checking this file because flow doesn't play well with
  918. * dynamically accessing methods on Array prototype
  919. */
  920. var arrayProto = Array.prototype;
  921. var arrayMethods = Object.create(arrayProto);
  922. var methodsToPatch = [
  923. 'push',
  924. 'pop',
  925. 'shift',
  926. 'unshift',
  927. 'splice',
  928. 'sort',
  929. 'reverse'
  930. ];
  931. /**
  932. * Intercept mutating methods and emit events
  933. */
  934. methodsToPatch.forEach(function (method) {
  935. // cache original method
  936. var original = arrayProto[method];
  937. def(arrayMethods, method, function mutator () {
  938. var args = [], len = arguments.length;
  939. while ( len-- ) args[ len ] = arguments[ len ];
  940. var result = original.apply(this, args);
  941. var ob = this.__ob__;
  942. var inserted;
  943. switch (method) {
  944. case 'push':
  945. case 'unshift':
  946. inserted = args;
  947. break
  948. case 'splice':
  949. inserted = args.slice(2);
  950. break
  951. }
  952. if (inserted) { ob.observeArray(inserted); }
  953. // notify change
  954. ob.dep.notify();
  955. return result
  956. });
  957. });
  958. /* */
  959. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  960. /**
  961. * In some cases we may want to disable observation inside a component's
  962. * update computation.
  963. */
  964. var shouldObserve = true;
  965. /**
  966. * Observer class that is attached to each observed
  967. * object. Once attached, the observer converts the target
  968. * object's property keys into getter/setters that
  969. * collect dependencies and dispatch updates.
  970. */
  971. var Observer = function Observer (value) {
  972. this.value = value;
  973. this.dep = new Dep();
  974. this.vmCount = 0;
  975. def(value, '__ob__', this);
  976. if (Array.isArray(value)) {
  977. var augment = hasProto
  978. ? protoAugment
  979. : copyAugment;
  980. augment(value, arrayMethods, arrayKeys);
  981. this.observeArray(value);
  982. } else {
  983. this.walk(value);
  984. }
  985. };
  986. /**
  987. * Walk through each property and convert them into
  988. * getter/setters. This method should only be called when
  989. * value type is Object.
  990. */
  991. Observer.prototype.walk = function walk (obj) {
  992. var keys = Object.keys(obj);
  993. for (var i = 0; i < keys.length; i++) {
  994. defineReactive(obj, keys[i]);
  995. }
  996. };
  997. /**
  998. * Observe a list of Array items.
  999. */
  1000. Observer.prototype.observeArray = function observeArray (items) {
  1001. for (var i = 0, l = items.length; i < l; i++) {
  1002. observe(items[i]);
  1003. }
  1004. };
  1005. // helpers
  1006. /**
  1007. * Augment an target Object or Array by intercepting
  1008. * the prototype chain using __proto__
  1009. */
  1010. function protoAugment (target, src, keys) {
  1011. /* eslint-disable no-proto */
  1012. target.__proto__ = src;
  1013. /* eslint-enable no-proto */
  1014. }
  1015. /**
  1016. * Augment an target Object or Array by defining
  1017. * hidden properties.
  1018. */
  1019. /* istanbul ignore next */
  1020. function copyAugment (target, src, keys) {
  1021. for (var i = 0, l = keys.length; i < l; i++) {
  1022. var key = keys[i];
  1023. def(target, key, src[key]);
  1024. }
  1025. }
  1026. /**
  1027. * Attempt to create an observer instance for a value,
  1028. * returns the new observer if successfully observed,
  1029. * or the existing observer if the value already has one.
  1030. */
  1031. function observe (value, asRootData) {
  1032. if (!isObject(value) || value instanceof VNode) {
  1033. return
  1034. }
  1035. var ob;
  1036. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  1037. ob = value.__ob__;
  1038. } else if (
  1039. shouldObserve &&
  1040. !isServerRendering() &&
  1041. (Array.isArray(value) || isPlainObject(value)) &&
  1042. Object.isExtensible(value) &&
  1043. !value._isVue
  1044. ) {
  1045. ob = new Observer(value);
  1046. }
  1047. if (asRootData && ob) {
  1048. ob.vmCount++;
  1049. }
  1050. return ob
  1051. }
  1052. /**
  1053. * Define a reactive property on an Object.
  1054. */
  1055. function defineReactive (
  1056. obj,
  1057. key,
  1058. val,
  1059. customSetter,
  1060. shallow
  1061. ) {
  1062. var dep = new Dep();
  1063. var property = Object.getOwnPropertyDescriptor(obj, key);
  1064. if (property && property.configurable === false) {
  1065. return
  1066. }
  1067. // cater for pre-defined getter/setters
  1068. var getter = property && property.get;
  1069. if (!getter && arguments.length === 2) {
  1070. val = obj[key];
  1071. }
  1072. var setter = property && property.set;
  1073. var childOb = !shallow && observe(val);
  1074. Object.defineProperty(obj, key, {
  1075. enumerable: true,
  1076. configurable: true,
  1077. get: function reactiveGetter () {
  1078. var value = getter ? getter.call(obj) : val;
  1079. if (Dep.target) {
  1080. dep.depend();
  1081. if (childOb) {
  1082. childOb.dep.depend();
  1083. if (Array.isArray(value)) {
  1084. dependArray(value);
  1085. }
  1086. }
  1087. }
  1088. return value
  1089. },
  1090. set: function reactiveSetter (newVal) {
  1091. var value = getter ? getter.call(obj) : val;
  1092. /* eslint-disable no-self-compare */
  1093. if (newVal === value || (newVal !== newVal && value !== value)) {
  1094. return
  1095. }
  1096. /* eslint-enable no-self-compare */
  1097. if (process.env.NODE_ENV !== 'production' && customSetter) {
  1098. customSetter();
  1099. }
  1100. if (setter) {
  1101. setter.call(obj, newVal);
  1102. } else {
  1103. val = newVal;
  1104. }
  1105. childOb = !shallow && observe(newVal);
  1106. dep.notify();
  1107. }
  1108. });
  1109. }
  1110. /**
  1111. * Set a property on an object. Adds the new property and
  1112. * triggers change notification if the property doesn't
  1113. * already exist.
  1114. */
  1115. function set (target, key, val) {
  1116. if (process.env.NODE_ENV !== 'production' &&
  1117. (isUndef(target) || isPrimitive(target))
  1118. ) {
  1119. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  1120. }
  1121. if (Array.isArray(target) && isValidArrayIndex(key)) {
  1122. target.length = Math.max(target.length, key);
  1123. target.splice(key, 1, val);
  1124. return val
  1125. }
  1126. if (key in target && !(key in Object.prototype)) {
  1127. target[key] = val;
  1128. return val
  1129. }
  1130. var ob = (target).__ob__;
  1131. if (target._isVue || (ob && ob.vmCount)) {
  1132. process.env.NODE_ENV !== 'production' && warn(
  1133. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  1134. 'at runtime - declare it upfront in the data option.'
  1135. );
  1136. return val
  1137. }
  1138. if (!ob) {
  1139. target[key] = val;
  1140. return val
  1141. }
  1142. defineReactive(ob.value, key, val);
  1143. ob.dep.notify();
  1144. return val
  1145. }
  1146. /**
  1147. * Delete a property and trigger change if necessary.
  1148. */
  1149. /**
  1150. * Collect dependencies on array elements when the array is touched, since
  1151. * we cannot intercept array element access like property getters.
  1152. */
  1153. function dependArray (value) {
  1154. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  1155. e = value[i];
  1156. e && e.__ob__ && e.__ob__.dep.depend();
  1157. if (Array.isArray(e)) {
  1158. dependArray(e);
  1159. }
  1160. }
  1161. }
  1162. /* */
  1163. /**
  1164. * Option overwriting strategies are functions that handle
  1165. * how to merge a parent option value and a child option
  1166. * value into the final value.
  1167. */
  1168. var strats = config.optionMergeStrategies;
  1169. /**
  1170. * Options with restrictions
  1171. */
  1172. if (process.env.NODE_ENV !== 'production') {
  1173. strats.el = strats.propsData = function (parent, child, vm, key) {
  1174. if (!vm) {
  1175. warn(
  1176. "option \"" + key + "\" can only be used during instance " +
  1177. 'creation with the `new` keyword.'
  1178. );
  1179. }
  1180. return defaultStrat(parent, child)
  1181. };
  1182. }
  1183. /**
  1184. * Helper that recursively merges two data objects together.
  1185. */
  1186. function mergeData (to, from) {
  1187. if (!from) { return to }
  1188. var key, toVal, fromVal;
  1189. var keys = Object.keys(from);
  1190. for (var i = 0; i < keys.length; i++) {
  1191. key = keys[i];
  1192. toVal = to[key];
  1193. fromVal = from[key];
  1194. if (!hasOwn(to, key)) {
  1195. set(to, key, fromVal);
  1196. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  1197. mergeData(toVal, fromVal);
  1198. }
  1199. }
  1200. return to
  1201. }
  1202. /**
  1203. * Data
  1204. */
  1205. function mergeDataOrFn (
  1206. parentVal,
  1207. childVal,
  1208. vm
  1209. ) {
  1210. if (!vm) {
  1211. // in a Vue.extend merge, both should be functions
  1212. if (!childVal) {
  1213. return parentVal
  1214. }
  1215. if (!parentVal) {
  1216. return childVal
  1217. }
  1218. // when parentVal & childVal are both present,
  1219. // we need to return a function that returns the
  1220. // merged result of both functions... no need to
  1221. // check if parentVal is a function here because
  1222. // it has to be a function to pass previous merges.
  1223. return function mergedDataFn () {
  1224. return mergeData(
  1225. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1226. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1227. )
  1228. }
  1229. } else {
  1230. return function mergedInstanceDataFn () {
  1231. // instance merge
  1232. var instanceData = typeof childVal === 'function'
  1233. ? childVal.call(vm, vm)
  1234. : childVal;
  1235. var defaultData = typeof parentVal === 'function'
  1236. ? parentVal.call(vm, vm)
  1237. : parentVal;
  1238. if (instanceData) {
  1239. return mergeData(instanceData, defaultData)
  1240. } else {
  1241. return defaultData
  1242. }
  1243. }
  1244. }
  1245. }
  1246. strats.data = function (
  1247. parentVal,
  1248. childVal,
  1249. vm
  1250. ) {
  1251. if (!vm) {
  1252. if (childVal && typeof childVal !== 'function') {
  1253. process.env.NODE_ENV !== 'production' && warn(
  1254. 'The "data" option should be a function ' +
  1255. 'that returns a per-instance value in component ' +
  1256. 'definitions.',
  1257. vm
  1258. );
  1259. return parentVal
  1260. }
  1261. return mergeDataOrFn(parentVal, childVal)
  1262. }
  1263. return mergeDataOrFn(parentVal, childVal, vm)
  1264. };
  1265. /**
  1266. * Hooks and props are merged as arrays.
  1267. */
  1268. function mergeHook (
  1269. parentVal,
  1270. childVal
  1271. ) {
  1272. return childVal
  1273. ? parentVal
  1274. ? parentVal.concat(childVal)
  1275. : Array.isArray(childVal)
  1276. ? childVal
  1277. : [childVal]
  1278. : parentVal
  1279. }
  1280. LIFECYCLE_HOOKS.forEach(function (hook) {
  1281. strats[hook] = mergeHook;
  1282. });
  1283. /**
  1284. * Assets
  1285. *
  1286. * When a vm is present (instance creation), we need to do
  1287. * a three-way merge between constructor options, instance
  1288. * options and parent options.
  1289. */
  1290. function mergeAssets (
  1291. parentVal,
  1292. childVal,
  1293. vm,
  1294. key
  1295. ) {
  1296. var res = Object.create(parentVal || null);
  1297. if (childVal) {
  1298. process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
  1299. return extend(res, childVal)
  1300. } else {
  1301. return res
  1302. }
  1303. }
  1304. ASSET_TYPES.forEach(function (type) {
  1305. strats[type + 's'] = mergeAssets;
  1306. });
  1307. /**
  1308. * Watchers.
  1309. *
  1310. * Watchers hashes should not overwrite one
  1311. * another, so we merge them as arrays.
  1312. */
  1313. strats.watch = function (
  1314. parentVal,
  1315. childVal,
  1316. vm,
  1317. key
  1318. ) {
  1319. // work around Firefox's Object.prototype.watch...
  1320. if (parentVal === nativeWatch) { parentVal = undefined; }
  1321. if (childVal === nativeWatch) { childVal = undefined; }
  1322. /* istanbul ignore if */
  1323. if (!childVal) { return Object.create(parentVal || null) }
  1324. if (process.env.NODE_ENV !== 'production') {
  1325. assertObjectType(key, childVal, vm);
  1326. }
  1327. if (!parentVal) { return childVal }
  1328. var ret = {};
  1329. extend(ret, parentVal);
  1330. for (var key$1 in childVal) {
  1331. var parent = ret[key$1];
  1332. var child = childVal[key$1];
  1333. if (parent && !Array.isArray(parent)) {
  1334. parent = [parent];
  1335. }
  1336. ret[key$1] = parent
  1337. ? parent.concat(child)
  1338. : Array.isArray(child) ? child : [child];
  1339. }
  1340. return ret
  1341. };
  1342. /**
  1343. * Other object hashes.
  1344. */
  1345. strats.props =
  1346. strats.methods =
  1347. strats.inject =
  1348. strats.computed = function (
  1349. parentVal,
  1350. childVal,
  1351. vm,
  1352. key
  1353. ) {
  1354. if (childVal && process.env.NODE_ENV !== 'production') {
  1355. assertObjectType(key, childVal, vm);
  1356. }
  1357. if (!parentVal) { return childVal }
  1358. var ret = Object.create(null);
  1359. extend(ret, parentVal);
  1360. if (childVal) { extend(ret, childVal); }
  1361. return ret
  1362. };
  1363. strats.provide = mergeDataOrFn;
  1364. /**
  1365. * Default strategy.
  1366. */
  1367. var defaultStrat = function (parentVal, childVal) {
  1368. return childVal === undefined
  1369. ? parentVal
  1370. : childVal
  1371. };
  1372. function assertObjectType (name, value, vm) {
  1373. if (!isPlainObject(value)) {
  1374. warn(
  1375. "Invalid value for option \"" + name + "\": expected an Object, " +
  1376. "but got " + (toRawType(value)) + ".",
  1377. vm
  1378. );
  1379. }
  1380. }
  1381. /**
  1382. * Merge two option objects into a new one.
  1383. * Core utility used in both instantiation and inheritance.
  1384. */
  1385. /**
  1386. * Resolve an asset.
  1387. * This function is used because child instances need access
  1388. * to assets defined in its ancestor chain.
  1389. */
  1390. /* */
  1391. /* */
  1392. /* */
  1393. /* globals MessageChannel */
  1394. var callbacks = [];
  1395. function flushCallbacks () {
  1396. var copies = callbacks.slice(0);
  1397. callbacks.length = 0;
  1398. for (var i = 0; i < copies.length; i++) {
  1399. copies[i]();
  1400. }
  1401. }
  1402. // Determine (macro) task defer implementation.
  1403. // Technically setImmediate should be the ideal choice, but it's only available
  1404. // in IE. The only polyfill that consistently queues the callback after all DOM
  1405. // events triggered in the same loop is by using MessageChannel.
  1406. /* istanbul ignore if */
  1407. if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  1408. } else if (typeof MessageChannel !== 'undefined' && (
  1409. isNative(MessageChannel) ||
  1410. // PhantomJS
  1411. MessageChannel.toString() === '[object MessageChannelConstructor]'
  1412. )) {
  1413. var channel = new MessageChannel();
  1414. channel.port1.onmessage = flushCallbacks;
  1415. } else {
  1416. /* istanbul ignore next */
  1417. }
  1418. // Determine microtask defer implementation.
  1419. /* istanbul ignore next, $flow-disable-line */
  1420. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  1421. } else {
  1422. // fallback to macro
  1423. }
  1424. /**
  1425. * Wrap a function so that if any code inside triggers state change,
  1426. * the changes are queued using a (macro) task instead of a microtask.
  1427. */
  1428. /* */
  1429. /* */
  1430. // these are reserved for web because they are directly compiled away
  1431. // during template compilation
  1432. var isReservedAttr = makeMap('style,class');
  1433. // attributes that should be using props for binding
  1434. var acceptValue = makeMap('input,textarea,option,select,progress');
  1435. var mustUseProp = function (tag, type, attr) {
  1436. return (
  1437. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  1438. (attr === 'selected' && tag === 'option') ||
  1439. (attr === 'checked' && tag === 'input') ||
  1440. (attr === 'muted' && tag === 'video')
  1441. )
  1442. };
  1443. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  1444. var isBooleanAttr = makeMap(
  1445. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  1446. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  1447. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  1448. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  1449. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  1450. 'truespeed,typemustmatch,visible'
  1451. );
  1452. /* */
  1453. /* */
  1454. var isHTMLTag = makeMap(
  1455. 'html,body,base,head,link,meta,style,title,' +
  1456. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  1457. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  1458. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  1459. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  1460. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  1461. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  1462. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  1463. 'output,progress,select,textarea,' +
  1464. 'details,dialog,menu,menuitem,summary,' +
  1465. 'content,element,shadow,template,blockquote,iframe,tfoot'
  1466. );
  1467. // this map is intentionally selective, only covering SVG elements that may
  1468. // contain child elements.
  1469. var isSVG = makeMap(
  1470. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  1471. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  1472. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  1473. true
  1474. );
  1475. var isPreTag = function (tag) { return tag === 'pre'; };
  1476. var isReservedTag = function (tag) {
  1477. return isHTMLTag(tag) || isSVG(tag)
  1478. };
  1479. function getTagNamespace (tag) {
  1480. if (isSVG(tag)) {
  1481. return 'svg'
  1482. }
  1483. // basic support for MathML
  1484. // note it doesn't support other MathML elements being component roots
  1485. if (tag === 'math') {
  1486. return 'math'
  1487. }
  1488. }
  1489. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  1490. /* */
  1491. /**
  1492. * Query an element selector if it's not an element already.
  1493. */
  1494. /* */
  1495. var validDivisionCharRE = /[\w).+\-_$\]]/;
  1496. function parseFilters (exp) {
  1497. var inSingle = false;
  1498. var inDouble = false;
  1499. var inTemplateString = false;
  1500. var inRegex = false;
  1501. var curly = 0;
  1502. var square = 0;
  1503. var paren = 0;
  1504. var lastFilterIndex = 0;
  1505. var c, prev, i, expression, filters;
  1506. for (i = 0; i < exp.length; i++) {
  1507. prev = c;
  1508. c = exp.charCodeAt(i);
  1509. if (inSingle) {
  1510. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  1511. } else if (inDouble) {
  1512. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  1513. } else if (inTemplateString) {
  1514. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  1515. } else if (inRegex) {
  1516. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  1517. } else if (
  1518. c === 0x7C && // pipe
  1519. exp.charCodeAt(i + 1) !== 0x7C &&
  1520. exp.charCodeAt(i - 1) !== 0x7C &&
  1521. !curly && !square && !paren
  1522. ) {
  1523. if (expression === undefined) {
  1524. // first filter, end of expression
  1525. lastFilterIndex = i + 1;
  1526. expression = exp.slice(0, i).trim();
  1527. } else {
  1528. pushFilter();
  1529. }
  1530. } else {
  1531. switch (c) {
  1532. case 0x22: inDouble = true; break // "
  1533. case 0x27: inSingle = true; break // '
  1534. case 0x60: inTemplateString = true; break // `
  1535. case 0x28: paren++; break // (
  1536. case 0x29: paren--; break // )
  1537. case 0x5B: square++; break // [
  1538. case 0x5D: square--; break // ]
  1539. case 0x7B: curly++; break // {
  1540. case 0x7D: curly--; break // }
  1541. }
  1542. if (c === 0x2f) { // /
  1543. var j = i - 1;
  1544. var p = (void 0);
  1545. // find first non-whitespace prev char
  1546. for (; j >= 0; j--) {
  1547. p = exp.charAt(j);
  1548. if (p !== ' ') { break }
  1549. }
  1550. if (!p || !validDivisionCharRE.test(p)) {
  1551. inRegex = true;
  1552. }
  1553. }
  1554. }
  1555. }
  1556. if (expression === undefined) {
  1557. expression = exp.slice(0, i).trim();
  1558. } else if (lastFilterIndex !== 0) {
  1559. pushFilter();
  1560. }
  1561. function pushFilter () {
  1562. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  1563. lastFilterIndex = i + 1;
  1564. }
  1565. if (filters) {
  1566. for (i = 0; i < filters.length; i++) {
  1567. expression = wrapFilter(expression, filters[i]);
  1568. }
  1569. }
  1570. return expression
  1571. }
  1572. function wrapFilter (exp, filter) {
  1573. var i = filter.indexOf('(');
  1574. if (i < 0) {
  1575. // _f: resolveFilter
  1576. return ("_f(\"" + filter + "\")(" + exp + ")")
  1577. } else {
  1578. var name = filter.slice(0, i);
  1579. var args = filter.slice(i + 1);
  1580. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  1581. }
  1582. }
  1583. /* */
  1584. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  1585. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  1586. var buildRegex = cached(function (delimiters) {
  1587. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  1588. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  1589. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  1590. });
  1591. function parseText (
  1592. text,
  1593. delimiters
  1594. ) {
  1595. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  1596. if (!tagRE.test(text)) {
  1597. return
  1598. }
  1599. var tokens = [];
  1600. var rawTokens = [];
  1601. var lastIndex = tagRE.lastIndex = 0;
  1602. var match, index, tokenValue;
  1603. while ((match = tagRE.exec(text))) {
  1604. index = match.index;
  1605. // push text token
  1606. if (index > lastIndex) {
  1607. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  1608. tokens.push(JSON.stringify(tokenValue));
  1609. }
  1610. // tag token
  1611. var exp = parseFilters(match[1].trim());
  1612. tokens.push(("_s(" + exp + ")"));
  1613. rawTokens.push({ '@binding': exp });
  1614. lastIndex = index + match[0].length;
  1615. }
  1616. if (lastIndex < text.length) {
  1617. rawTokens.push(tokenValue = text.slice(lastIndex));
  1618. tokens.push(JSON.stringify(tokenValue));
  1619. }
  1620. return {
  1621. expression: tokens.join('+'),
  1622. tokens: rawTokens
  1623. }
  1624. }
  1625. /* */
  1626. function baseWarn (msg) {
  1627. console.error(("[Vue compiler]: " + msg));
  1628. }
  1629. function pluckModuleFunction (
  1630. modules,
  1631. key
  1632. ) {
  1633. return modules
  1634. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  1635. : []
  1636. }
  1637. function addProp (el, name, value) {
  1638. (el.props || (el.props = [])).push({ name: name, value: value });
  1639. el.plain = false;
  1640. }
  1641. function addAttr (el, name, value) {
  1642. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  1643. el.plain = false;
  1644. }
  1645. // add a raw attr (use this in preTransforms)
  1646. function addRawAttr (el, name, value) {
  1647. el.attrsMap[name] = value;
  1648. el.attrsList.push({ name: name, value: value });
  1649. }
  1650. function addDirective (
  1651. el,
  1652. name,
  1653. rawName,
  1654. value,
  1655. arg,
  1656. modifiers
  1657. ) {
  1658. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  1659. el.plain = false;
  1660. }
  1661. function addHandler (
  1662. el,
  1663. name,
  1664. value,
  1665. modifiers,
  1666. important,
  1667. warn
  1668. ) {
  1669. modifiers = modifiers || emptyObject;
  1670. // warn prevent and passive modifier
  1671. /* istanbul ignore if */
  1672. if (
  1673. process.env.NODE_ENV !== 'production' && warn &&
  1674. modifiers.prevent && modifiers.passive
  1675. ) {
  1676. warn(
  1677. 'passive and prevent can\'t be used together. ' +
  1678. 'Passive handler can\'t prevent default event.'
  1679. );
  1680. }
  1681. // check capture modifier
  1682. if (modifiers.capture) {
  1683. delete modifiers.capture;
  1684. name = '!' + name; // mark the event as captured
  1685. }
  1686. if (modifiers.once) {
  1687. delete modifiers.once;
  1688. name = '~' + name; // mark the event as once
  1689. }
  1690. /* istanbul ignore if */
  1691. if (modifiers.passive) {
  1692. delete modifiers.passive;
  1693. name = '&' + name; // mark the event as passive
  1694. }
  1695. // normalize click.right and click.middle since they don't actually fire
  1696. // this is technically browser-specific, but at least for now browsers are
  1697. // the only target envs that have right/middle clicks.
  1698. if (name === 'click') {
  1699. if (modifiers.right) {
  1700. name = 'contextmenu';
  1701. delete modifiers.right;
  1702. } else if (modifiers.middle) {
  1703. name = 'mouseup';
  1704. }
  1705. }
  1706. var events;
  1707. if (modifiers.native) {
  1708. delete modifiers.native;
  1709. events = el.nativeEvents || (el.nativeEvents = {});
  1710. } else {
  1711. events = el.events || (el.events = {});
  1712. }
  1713. var newHandler = {
  1714. value: value.trim()
  1715. };
  1716. if (modifiers !== emptyObject) {
  1717. newHandler.modifiers = modifiers;
  1718. }
  1719. var handlers = events[name];
  1720. /* istanbul ignore if */
  1721. if (Array.isArray(handlers)) {
  1722. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  1723. } else if (handlers) {
  1724. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  1725. } else {
  1726. events[name] = newHandler;
  1727. }
  1728. el.plain = false;
  1729. }
  1730. function getBindingAttr (
  1731. el,
  1732. name,
  1733. getStatic
  1734. ) {
  1735. var dynamicValue =
  1736. getAndRemoveAttr(el, ':' + name) ||
  1737. getAndRemoveAttr(el, 'v-bind:' + name);
  1738. if (dynamicValue != null) {
  1739. return parseFilters(dynamicValue)
  1740. } else if (getStatic !== false) {
  1741. var staticValue = getAndRemoveAttr(el, name);
  1742. if (staticValue != null) {
  1743. return JSON.stringify(staticValue)
  1744. }
  1745. }
  1746. }
  1747. // note: this only removes the attr from the Array (attrsList) so that it
  1748. // doesn't get processed by processAttrs.
  1749. // By default it does NOT remove it from the map (attrsMap) because the map is
  1750. // needed during codegen.
  1751. function getAndRemoveAttr (
  1752. el,
  1753. name,
  1754. removeFromMap
  1755. ) {
  1756. var val;
  1757. if ((val = el.attrsMap[name]) != null) {
  1758. var list = el.attrsList;
  1759. for (var i = 0, l = list.length; i < l; i++) {
  1760. if (list[i].name === name) {
  1761. list.splice(i, 1);
  1762. break
  1763. }
  1764. }
  1765. }
  1766. if (removeFromMap) {
  1767. delete el.attrsMap[name];
  1768. }
  1769. return val
  1770. }
  1771. /* */
  1772. function transformNode (el, options) {
  1773. var warn = options.warn || baseWarn;
  1774. var staticClass = getAndRemoveAttr(el, 'class');
  1775. if (process.env.NODE_ENV !== 'production' && staticClass) {
  1776. var res = parseText(staticClass, options.delimiters);
  1777. if (res) {
  1778. warn(
  1779. "class=\"" + staticClass + "\": " +
  1780. 'Interpolation inside attributes has been removed. ' +
  1781. 'Use v-bind or the colon shorthand instead. For example, ' +
  1782. 'instead of <div class="{{ val }}">, use <div :class="val">.'
  1783. );
  1784. }
  1785. }
  1786. if (staticClass) {
  1787. el.staticClass = JSON.stringify(staticClass);
  1788. }
  1789. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  1790. if (classBinding) {
  1791. el.classBinding = classBinding;
  1792. }
  1793. }
  1794. function genData (el) {
  1795. var data = '';
  1796. if (el.staticClass) {
  1797. data += "staticClass:" + (el.staticClass) + ",";
  1798. }
  1799. if (el.classBinding) {
  1800. data += "class:" + (el.classBinding) + ",";
  1801. }
  1802. return data
  1803. }
  1804. var klass = {
  1805. staticKeys: ['staticClass'],
  1806. transformNode: transformNode,
  1807. genData: genData
  1808. }
  1809. /* */
  1810. var parseStyleText = cached(function (cssText) {
  1811. var res = {};
  1812. var listDelimiter = /;(?![^(]*\))/g;
  1813. var propertyDelimiter = /:(.+)/;
  1814. cssText.split(listDelimiter).forEach(function (item) {
  1815. if (item) {
  1816. var tmp = item.split(propertyDelimiter);
  1817. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  1818. }
  1819. });
  1820. return res
  1821. });
  1822. // normalize possible array / string values into Object
  1823. /**
  1824. * parent component style should be after child's
  1825. * so that parent component's style could override it
  1826. */
  1827. /* */
  1828. function transformNode$1 (el, options) {
  1829. var warn = options.warn || baseWarn;
  1830. var staticStyle = getAndRemoveAttr(el, 'style');
  1831. if (staticStyle) {
  1832. /* istanbul ignore if */
  1833. if (process.env.NODE_ENV !== 'production') {
  1834. var res = parseText(staticStyle, options.delimiters);
  1835. if (res) {
  1836. warn(
  1837. "style=\"" + staticStyle + "\": " +
  1838. 'Interpolation inside attributes has been removed. ' +
  1839. 'Use v-bind or the colon shorthand instead. For example, ' +
  1840. 'instead of <div style="{{ val }}">, use <div :style="val">.'
  1841. );
  1842. }
  1843. }
  1844. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  1845. }
  1846. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  1847. if (styleBinding) {
  1848. el.styleBinding = styleBinding;
  1849. }
  1850. }
  1851. function genData$1 (el) {
  1852. var data = '';
  1853. if (el.staticStyle) {
  1854. data += "staticStyle:" + (el.staticStyle) + ",";
  1855. }
  1856. if (el.styleBinding) {
  1857. data += "style:(" + (el.styleBinding) + "),";
  1858. }
  1859. return data
  1860. }
  1861. var style = {
  1862. staticKeys: ['staticStyle'],
  1863. transformNode: transformNode$1,
  1864. genData: genData$1
  1865. }
  1866. /* */
  1867. /**
  1868. * Cross-platform code generation for component v-model
  1869. */
  1870. function genComponentModel (
  1871. el,
  1872. value,
  1873. modifiers
  1874. ) {
  1875. var ref = modifiers || {};
  1876. var number = ref.number;
  1877. var trim = ref.trim;
  1878. var baseValueExpression = '$$v';
  1879. var valueExpression = baseValueExpression;
  1880. if (trim) {
  1881. valueExpression =
  1882. "(typeof " + baseValueExpression + " === 'string'" +
  1883. "? " + baseValueExpression + ".trim()" +
  1884. ": " + baseValueExpression + ")";
  1885. }
  1886. if (number) {
  1887. valueExpression = "_n(" + valueExpression + ")";
  1888. }
  1889. var assignment = genAssignmentCode(value, valueExpression);
  1890. el.model = {
  1891. value: ("(" + value + ")"),
  1892. expression: ("\"" + value + "\""),
  1893. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  1894. };
  1895. }
  1896. /**
  1897. * Cross-platform codegen helper for generating v-model value assignment code.
  1898. */
  1899. function genAssignmentCode (
  1900. value,
  1901. assignment
  1902. ) {
  1903. var res = parseModel(value);
  1904. if (res.key === null) {
  1905. return (value + "=" + assignment)
  1906. } else {
  1907. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  1908. }
  1909. }
  1910. /**
  1911. * Parse a v-model expression into a base path and a final key segment.
  1912. * Handles both dot-path and possible square brackets.
  1913. *
  1914. * Possible cases:
  1915. *
  1916. * - test
  1917. * - test[key]
  1918. * - test[test1[key]]
  1919. * - test["a"][key]
  1920. * - xxx.test[a[a].test1[key]]
  1921. * - test.xxx.a["asa"][test1[key]]
  1922. *
  1923. */
  1924. var len;
  1925. var str;
  1926. var chr;
  1927. var index;
  1928. var expressionPos;
  1929. var expressionEndPos;
  1930. function parseModel (val) {
  1931. // Fix https://github.com/vuejs/vue/pull/7730
  1932. // allow v-model="obj.val " (trailing whitespace)
  1933. val = val.trim();
  1934. len = val.length;
  1935. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  1936. index = val.lastIndexOf('.');
  1937. if (index > -1) {
  1938. return {
  1939. exp: val.slice(0, index),
  1940. key: '"' + val.slice(index + 1) + '"'
  1941. }
  1942. } else {
  1943. return {
  1944. exp: val,
  1945. key: null
  1946. }
  1947. }
  1948. }
  1949. str = val;
  1950. index = expressionPos = expressionEndPos = 0;
  1951. while (!eof()) {
  1952. chr = next();
  1953. /* istanbul ignore if */
  1954. if (isStringStart(chr)) {
  1955. parseString(chr);
  1956. } else if (chr === 0x5B) {
  1957. parseBracket(chr);
  1958. }
  1959. }
  1960. return {
  1961. exp: val.slice(0, expressionPos),
  1962. key: val.slice(expressionPos + 1, expressionEndPos)
  1963. }
  1964. }
  1965. function next () {
  1966. return str.charCodeAt(++index)
  1967. }
  1968. function eof () {
  1969. return index >= len
  1970. }
  1971. function isStringStart (chr) {
  1972. return chr === 0x22 || chr === 0x27
  1973. }
  1974. function parseBracket (chr) {
  1975. var inBracket = 1;
  1976. expressionPos = index;
  1977. while (!eof()) {
  1978. chr = next();
  1979. if (isStringStart(chr)) {
  1980. parseString(chr);
  1981. continue
  1982. }
  1983. if (chr === 0x5B) { inBracket++; }
  1984. if (chr === 0x5D) { inBracket--; }
  1985. if (inBracket === 0) {
  1986. expressionEndPos = index;
  1987. break
  1988. }
  1989. }
  1990. }
  1991. function parseString (chr) {
  1992. var stringQuote = chr;
  1993. while (!eof()) {
  1994. chr = next();
  1995. if (chr === stringQuote) {
  1996. break
  1997. }
  1998. }
  1999. }
  2000. /* */
  2001. var onRE = /^@|^v-on:/;
  2002. var dirRE = /^v-|^@|^:/;
  2003. var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/;
  2004. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  2005. var stripParensRE = /^\(|\)$/g;
  2006. var argRE = /:(.*)$/;
  2007. var bindRE = /^:|^v-bind:/;
  2008. var modifierRE = /\.[^.]+/g;
  2009. var decodeHTMLCached = cached(he.decode);
  2010. // configurable state
  2011. var warn$1;
  2012. var delimiters;
  2013. var transforms;
  2014. var preTransforms;
  2015. var postTransforms;
  2016. var platformIsPreTag;
  2017. var platformMustUseProp;
  2018. var platformGetTagNamespace;
  2019. function createASTElement (
  2020. tag,
  2021. attrs,
  2022. parent
  2023. ) {
  2024. return {
  2025. type: 1,
  2026. tag: tag,
  2027. attrsList: attrs,
  2028. attrsMap: makeAttrsMap(attrs),
  2029. parent: parent,
  2030. children: []
  2031. }
  2032. }
  2033. /**
  2034. * Convert HTML string to AST.
  2035. */
  2036. function parse (
  2037. template,
  2038. options
  2039. ) {
  2040. warn$1 = options.warn || baseWarn;
  2041. platformIsPreTag = options.isPreTag || no;
  2042. platformMustUseProp = options.mustUseProp || no;
  2043. platformGetTagNamespace = options.getTagNamespace || no;
  2044. transforms = pluckModuleFunction(options.modules, 'transformNode');
  2045. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  2046. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  2047. delimiters = options.delimiters;
  2048. var stack = [];
  2049. var preserveWhitespace = options.preserveWhitespace !== false;
  2050. var root;
  2051. var currentParent;
  2052. var inVPre = false;
  2053. var inPre = false;
  2054. var warned = false;
  2055. function warnOnce (msg) {
  2056. if (!warned) {
  2057. warned = true;
  2058. warn$1(msg);
  2059. }
  2060. }
  2061. function closeElement (element) {
  2062. // check pre state
  2063. if (element.pre) {
  2064. inVPre = false;
  2065. }
  2066. if (platformIsPreTag(element.tag)) {
  2067. inPre = false;
  2068. }
  2069. // apply post-transforms
  2070. for (var i = 0; i < postTransforms.length; i++) {
  2071. postTransforms[i](element, options);
  2072. }
  2073. }
  2074. parseHTML(template, {
  2075. warn: warn$1,
  2076. expectHTML: options.expectHTML,
  2077. isUnaryTag: options.isUnaryTag,
  2078. canBeLeftOpenTag: options.canBeLeftOpenTag,
  2079. shouldDecodeNewlines: options.shouldDecodeNewlines,
  2080. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  2081. shouldKeepComment: options.comments,
  2082. start: function start (tag, attrs, unary) {
  2083. // check namespace.
  2084. // inherit parent ns if there is one
  2085. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  2086. // handle IE svg bug
  2087. /* istanbul ignore if */
  2088. if (isIE && ns === 'svg') {
  2089. attrs = guardIESVGBug(attrs);
  2090. }
  2091. var element = createASTElement(tag, attrs, currentParent);
  2092. if (ns) {
  2093. element.ns = ns;
  2094. }
  2095. if (isForbiddenTag(element) && !isServerRendering()) {
  2096. element.forbidden = true;
  2097. process.env.NODE_ENV !== 'production' && warn$1(
  2098. 'Templates should only be responsible for mapping the state to the ' +
  2099. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  2100. "<" + tag + ">" + ', as they will not be parsed.'
  2101. );
  2102. }
  2103. // apply pre-transforms
  2104. for (var i = 0; i < preTransforms.length; i++) {
  2105. element = preTransforms[i](element, options) || element;
  2106. }
  2107. if (!inVPre) {
  2108. processPre(element);
  2109. if (element.pre) {
  2110. inVPre = true;
  2111. }
  2112. }
  2113. if (platformIsPreTag(element.tag)) {
  2114. inPre = true;
  2115. }
  2116. if (inVPre) {
  2117. processRawAttrs(element);
  2118. } else if (!element.processed) {
  2119. // structural directives
  2120. processFor(element);
  2121. processIf(element);
  2122. processOnce(element);
  2123. // element-scope stuff
  2124. processElement(element, options);
  2125. }
  2126. function checkRootConstraints (el) {
  2127. if (process.env.NODE_ENV !== 'production') {
  2128. if (el.tag === 'slot' || el.tag === 'template') {
  2129. warnOnce(
  2130. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  2131. 'contain multiple nodes.'
  2132. );
  2133. }
  2134. if (el.attrsMap.hasOwnProperty('v-for')) {
  2135. warnOnce(
  2136. 'Cannot use v-for on stateful component root element because ' +
  2137. 'it renders multiple elements.'
  2138. );
  2139. }
  2140. }
  2141. }
  2142. // tree management
  2143. if (!root) {
  2144. root = element;
  2145. checkRootConstraints(root);
  2146. } else if (!stack.length) {
  2147. // allow root elements with v-if, v-else-if and v-else
  2148. if (root.if && (element.elseif || element.else)) {
  2149. checkRootConstraints(element);
  2150. addIfCondition(root, {
  2151. exp: element.elseif,
  2152. block: element
  2153. });
  2154. } else if (process.env.NODE_ENV !== 'production') {
  2155. warnOnce(
  2156. "Component template should contain exactly one root element. " +
  2157. "If you are using v-if on multiple elements, " +
  2158. "use v-else-if to chain them instead."
  2159. );
  2160. }
  2161. }
  2162. if (currentParent && !element.forbidden) {
  2163. if (element.elseif || element.else) {
  2164. processIfConditions(element, currentParent);
  2165. } else if (element.slotScope) { // scoped slot
  2166. currentParent.plain = false;
  2167. var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  2168. } else {
  2169. currentParent.children.push(element);
  2170. element.parent = currentParent;
  2171. }
  2172. }
  2173. if (!unary) {
  2174. currentParent = element;
  2175. stack.push(element);
  2176. } else {
  2177. closeElement(element);
  2178. }
  2179. },
  2180. end: function end () {
  2181. // remove trailing whitespace
  2182. var element = stack[stack.length - 1];
  2183. var lastNode = element.children[element.children.length - 1];
  2184. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  2185. element.children.pop();
  2186. }
  2187. // pop stack
  2188. stack.length -= 1;
  2189. currentParent = stack[stack.length - 1];
  2190. closeElement(element);
  2191. },
  2192. chars: function chars (text) {
  2193. if (!currentParent) {
  2194. if (process.env.NODE_ENV !== 'production') {
  2195. if (text === template) {
  2196. warnOnce(
  2197. 'Component template requires a root element, rather than just text.'
  2198. );
  2199. } else if ((text = text.trim())) {
  2200. warnOnce(
  2201. ("text \"" + text + "\" outside root element will be ignored.")
  2202. );
  2203. }
  2204. }
  2205. return
  2206. }
  2207. // IE textarea placeholder bug
  2208. /* istanbul ignore if */
  2209. if (isIE &&
  2210. currentParent.tag === 'textarea' &&
  2211. currentParent.attrsMap.placeholder === text
  2212. ) {
  2213. return
  2214. }
  2215. var children = currentParent.children;
  2216. text = inPre || text.trim()
  2217. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  2218. // only preserve whitespace if its not right after a starting tag
  2219. : preserveWhitespace && children.length ? ' ' : '';
  2220. if (text) {
  2221. var res;
  2222. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  2223. children.push({
  2224. type: 2,
  2225. expression: res.expression,
  2226. tokens: res.tokens,
  2227. text: text
  2228. });
  2229. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  2230. children.push({
  2231. type: 3,
  2232. text: text
  2233. });
  2234. }
  2235. }
  2236. },
  2237. comment: function comment (text) {
  2238. currentParent.children.push({
  2239. type: 3,
  2240. text: text,
  2241. isComment: true
  2242. });
  2243. }
  2244. });
  2245. return root
  2246. }
  2247. function processPre (el) {
  2248. if (getAndRemoveAttr(el, 'v-pre') != null) {
  2249. el.pre = true;
  2250. }
  2251. }
  2252. function processRawAttrs (el) {
  2253. var l = el.attrsList.length;
  2254. if (l) {
  2255. var attrs = el.attrs = new Array(l);
  2256. for (var i = 0; i < l; i++) {
  2257. attrs[i] = {
  2258. name: el.attrsList[i].name,
  2259. value: JSON.stringify(el.attrsList[i].value)
  2260. };
  2261. }
  2262. } else if (!el.pre) {
  2263. // non root node in pre blocks with no attributes
  2264. el.plain = true;
  2265. }
  2266. }
  2267. function processElement (element, options) {
  2268. processKey(element);
  2269. // determine whether this is a plain element after
  2270. // removing structural attributes
  2271. element.plain = !element.key && !element.attrsList.length;
  2272. processRef(element);
  2273. processSlot(element);
  2274. processComponent(element);
  2275. for (var i = 0; i < transforms.length; i++) {
  2276. element = transforms[i](element, options) || element;
  2277. }
  2278. processAttrs(element);
  2279. }
  2280. function processKey (el) {
  2281. var exp = getBindingAttr(el, 'key');
  2282. if (exp) {
  2283. if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
  2284. warn$1("<template> cannot be keyed. Place the key on real elements instead.");
  2285. }
  2286. el.key = exp;
  2287. }
  2288. }
  2289. function processRef (el) {
  2290. var ref = getBindingAttr(el, 'ref');
  2291. if (ref) {
  2292. el.ref = ref;
  2293. el.refInFor = checkInFor(el);
  2294. }
  2295. }
  2296. function processFor (el) {
  2297. var exp;
  2298. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  2299. var res = parseFor(exp);
  2300. if (res) {
  2301. extend(el, res);
  2302. } else if (process.env.NODE_ENV !== 'production') {
  2303. warn$1(
  2304. ("Invalid v-for expression: " + exp)
  2305. );
  2306. }
  2307. }
  2308. }
  2309. function parseFor (exp) {
  2310. var inMatch = exp.match(forAliasRE);
  2311. if (!inMatch) { return }
  2312. var res = {};
  2313. res.for = inMatch[2].trim();
  2314. var alias = inMatch[1].trim().replace(stripParensRE, '');
  2315. var iteratorMatch = alias.match(forIteratorRE);
  2316. if (iteratorMatch) {
  2317. res.alias = alias.replace(forIteratorRE, '');
  2318. res.iterator1 = iteratorMatch[1].trim();
  2319. if (iteratorMatch[2]) {
  2320. res.iterator2 = iteratorMatch[2].trim();
  2321. }
  2322. } else {
  2323. res.alias = alias;
  2324. }
  2325. return res
  2326. }
  2327. function processIf (el) {
  2328. var exp = getAndRemoveAttr(el, 'v-if');
  2329. if (exp) {
  2330. el.if = exp;
  2331. addIfCondition(el, {
  2332. exp: exp,
  2333. block: el
  2334. });
  2335. } else {
  2336. if (getAndRemoveAttr(el, 'v-else') != null) {
  2337. el.else = true;
  2338. }
  2339. var elseif = getAndRemoveAttr(el, 'v-else-if');
  2340. if (elseif) {
  2341. el.elseif = elseif;
  2342. }
  2343. }
  2344. }
  2345. function processIfConditions (el, parent) {
  2346. var prev = findPrevElement(parent.children);
  2347. if (prev && prev.if) {
  2348. addIfCondition(prev, {
  2349. exp: el.elseif,
  2350. block: el
  2351. });
  2352. } else if (process.env.NODE_ENV !== 'production') {
  2353. warn$1(
  2354. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  2355. "used on element <" + (el.tag) + "> without corresponding v-if."
  2356. );
  2357. }
  2358. }
  2359. function findPrevElement (children) {
  2360. var i = children.length;
  2361. while (i--) {
  2362. if (children[i].type === 1) {
  2363. return children[i]
  2364. } else {
  2365. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  2366. warn$1(
  2367. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  2368. "will be ignored."
  2369. );
  2370. }
  2371. children.pop();
  2372. }
  2373. }
  2374. }
  2375. function addIfCondition (el, condition) {
  2376. if (!el.ifConditions) {
  2377. el.ifConditions = [];
  2378. }
  2379. el.ifConditions.push(condition);
  2380. }
  2381. function processOnce (el) {
  2382. var once$$1 = getAndRemoveAttr(el, 'v-once');
  2383. if (once$$1 != null) {
  2384. el.once = true;
  2385. }
  2386. }
  2387. function processSlot (el) {
  2388. if (el.tag === 'slot') {
  2389. el.slotName = getBindingAttr(el, 'name');
  2390. if (process.env.NODE_ENV !== 'production' && el.key) {
  2391. warn$1(
  2392. "`key` does not work on <slot> because slots are abstract outlets " +
  2393. "and can possibly expand into multiple elements. " +
  2394. "Use the key on a wrapping element instead."
  2395. );
  2396. }
  2397. } else {
  2398. var slotScope;
  2399. if (el.tag === 'template') {
  2400. slotScope = getAndRemoveAttr(el, 'scope');
  2401. /* istanbul ignore if */
  2402. if (process.env.NODE_ENV !== 'production' && slotScope) {
  2403. warn$1(
  2404. "the \"scope\" attribute for scoped slots have been deprecated and " +
  2405. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  2406. "can also be used on plain elements in addition to <template> to " +
  2407. "denote scoped slots.",
  2408. true
  2409. );
  2410. }
  2411. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  2412. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  2413. /* istanbul ignore if */
  2414. if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
  2415. warn$1(
  2416. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  2417. "(v-for takes higher priority). Use a wrapper <template> for the " +
  2418. "scoped slot to make it clearer.",
  2419. true
  2420. );
  2421. }
  2422. el.slotScope = slotScope;
  2423. }
  2424. var slotTarget = getBindingAttr(el, 'slot');
  2425. if (slotTarget) {
  2426. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  2427. // preserve slot as an attribute for native shadow DOM compat
  2428. // only for non-scoped slots.
  2429. if (el.tag !== 'template' && !el.slotScope) {
  2430. addAttr(el, 'slot', slotTarget);
  2431. }
  2432. }
  2433. }
  2434. }
  2435. function processComponent (el) {
  2436. var binding;
  2437. if ((binding = getBindingAttr(el, 'is'))) {
  2438. el.component = binding;
  2439. }
  2440. if (getAndRemoveAttr(el, 'inline-template') != null) {
  2441. el.inlineTemplate = true;
  2442. }
  2443. }
  2444. function processAttrs (el) {
  2445. var list = el.attrsList;
  2446. var i, l, name, rawName, value, modifiers, isProp;
  2447. for (i = 0, l = list.length; i < l; i++) {
  2448. name = rawName = list[i].name;
  2449. value = list[i].value;
  2450. if (dirRE.test(name)) {
  2451. // mark element as dynamic
  2452. el.hasBindings = true;
  2453. // modifiers
  2454. modifiers = parseModifiers(name);
  2455. if (modifiers) {
  2456. name = name.replace(modifierRE, '');
  2457. }
  2458. if (bindRE.test(name)) { // v-bind
  2459. name = name.replace(bindRE, '');
  2460. value = parseFilters(value);
  2461. isProp = false;
  2462. if (modifiers) {
  2463. if (modifiers.prop) {
  2464. isProp = true;
  2465. name = camelize(name);
  2466. if (name === 'innerHtml') { name = 'innerHTML'; }
  2467. }
  2468. if (modifiers.camel) {
  2469. name = camelize(name);
  2470. }
  2471. if (modifiers.sync) {
  2472. addHandler(
  2473. el,
  2474. ("update:" + (camelize(name))),
  2475. genAssignmentCode(value, "$event")
  2476. );
  2477. }
  2478. }
  2479. if (isProp || (
  2480. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  2481. )) {
  2482. addProp(el, name, value);
  2483. } else {
  2484. addAttr(el, name, value);
  2485. }
  2486. } else if (onRE.test(name)) { // v-on
  2487. name = name.replace(onRE, '');
  2488. addHandler(el, name, value, modifiers, false, warn$1);
  2489. } else { // normal directives
  2490. name = name.replace(dirRE, '');
  2491. // parse arg
  2492. var argMatch = name.match(argRE);
  2493. var arg = argMatch && argMatch[1];
  2494. if (arg) {
  2495. name = name.slice(0, -(arg.length + 1));
  2496. }
  2497. addDirective(el, name, rawName, value, arg, modifiers);
  2498. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  2499. checkForAliasModel(el, value);
  2500. }
  2501. }
  2502. } else {
  2503. // literal attribute
  2504. if (process.env.NODE_ENV !== 'production') {
  2505. var res = parseText(value, delimiters);
  2506. if (res) {
  2507. warn$1(
  2508. name + "=\"" + value + "\": " +
  2509. 'Interpolation inside attributes has been removed. ' +
  2510. 'Use v-bind or the colon shorthand instead. For example, ' +
  2511. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  2512. );
  2513. }
  2514. }
  2515. addAttr(el, name, JSON.stringify(value));
  2516. // #6887 firefox doesn't update muted state if set via attribute
  2517. // even immediately after element creation
  2518. if (!el.component &&
  2519. name === 'muted' &&
  2520. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  2521. addProp(el, name, 'true');
  2522. }
  2523. }
  2524. }
  2525. }
  2526. function checkInFor (el) {
  2527. var parent = el;
  2528. while (parent) {
  2529. if (parent.for !== undefined) {
  2530. return true
  2531. }
  2532. parent = parent.parent;
  2533. }
  2534. return false
  2535. }
  2536. function parseModifiers (name) {
  2537. var match = name.match(modifierRE);
  2538. if (match) {
  2539. var ret = {};
  2540. match.forEach(function (m) { ret[m.slice(1)] = true; });
  2541. return ret
  2542. }
  2543. }
  2544. function makeAttrsMap (attrs) {
  2545. var map = {};
  2546. for (var i = 0, l = attrs.length; i < l; i++) {
  2547. if (
  2548. process.env.NODE_ENV !== 'production' &&
  2549. map[attrs[i].name] && !isIE && !isEdge
  2550. ) {
  2551. warn$1('duplicate attribute: ' + attrs[i].name);
  2552. }
  2553. map[attrs[i].name] = attrs[i].value;
  2554. }
  2555. return map
  2556. }
  2557. // for script (e.g. type="x/template") or style, do not decode content
  2558. function isTextTag (el) {
  2559. return el.tag === 'script' || el.tag === 'style'
  2560. }
  2561. function isForbiddenTag (el) {
  2562. return (
  2563. el.tag === 'style' ||
  2564. (el.tag === 'script' && (
  2565. !el.attrsMap.type ||
  2566. el.attrsMap.type === 'text/javascript'
  2567. ))
  2568. )
  2569. }
  2570. var ieNSBug = /^xmlns:NS\d+/;
  2571. var ieNSPrefix = /^NS\d+:/;
  2572. /* istanbul ignore next */
  2573. function guardIESVGBug (attrs) {
  2574. var res = [];
  2575. for (var i = 0; i < attrs.length; i++) {
  2576. var attr = attrs[i];
  2577. if (!ieNSBug.test(attr.name)) {
  2578. attr.name = attr.name.replace(ieNSPrefix, '');
  2579. res.push(attr);
  2580. }
  2581. }
  2582. return res
  2583. }
  2584. function checkForAliasModel (el, value) {
  2585. var _el = el;
  2586. while (_el) {
  2587. if (_el.for && _el.alias === value) {
  2588. warn$1(
  2589. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  2590. "You are binding v-model directly to a v-for iteration alias. " +
  2591. "This will not be able to modify the v-for source array because " +
  2592. "writing to the alias is like modifying a function local variable. " +
  2593. "Consider using an array of objects and use v-model on an object property instead."
  2594. );
  2595. }
  2596. _el = _el.parent;
  2597. }
  2598. }
  2599. /* */
  2600. /**
  2601. * Expand input[v-model] with dyanmic type bindings into v-if-else chains
  2602. * Turn this:
  2603. * <input v-model="data[type]" :type="type">
  2604. * into this:
  2605. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  2606. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  2607. * <input v-else :type="type" v-model="data[type]">
  2608. */
  2609. function preTransformNode (el, options) {
  2610. if (el.tag === 'input') {
  2611. var map = el.attrsMap;
  2612. if (!map['v-model']) {
  2613. return
  2614. }
  2615. var typeBinding;
  2616. if (map[':type'] || map['v-bind:type']) {
  2617. typeBinding = getBindingAttr(el, 'type');
  2618. }
  2619. if (!map.type && !typeBinding && map['v-bind']) {
  2620. typeBinding = "(" + (map['v-bind']) + ").type";
  2621. }
  2622. if (typeBinding) {
  2623. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  2624. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  2625. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  2626. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  2627. // 1. checkbox
  2628. var branch0 = cloneASTElement(el);
  2629. // process for on the main node
  2630. processFor(branch0);
  2631. addRawAttr(branch0, 'type', 'checkbox');
  2632. processElement(branch0, options);
  2633. branch0.processed = true; // prevent it from double-processed
  2634. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  2635. addIfCondition(branch0, {
  2636. exp: branch0.if,
  2637. block: branch0
  2638. });
  2639. // 2. add radio else-if condition
  2640. var branch1 = cloneASTElement(el);
  2641. getAndRemoveAttr(branch1, 'v-for', true);
  2642. addRawAttr(branch1, 'type', 'radio');
  2643. processElement(branch1, options);
  2644. addIfCondition(branch0, {
  2645. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  2646. block: branch1
  2647. });
  2648. // 3. other
  2649. var branch2 = cloneASTElement(el);
  2650. getAndRemoveAttr(branch2, 'v-for', true);
  2651. addRawAttr(branch2, ':type', typeBinding);
  2652. processElement(branch2, options);
  2653. addIfCondition(branch0, {
  2654. exp: ifCondition,
  2655. block: branch2
  2656. });
  2657. if (hasElse) {
  2658. branch0.else = true;
  2659. } else if (elseIfCondition) {
  2660. branch0.elseif = elseIfCondition;
  2661. }
  2662. return branch0
  2663. }
  2664. }
  2665. }
  2666. function cloneASTElement (el) {
  2667. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  2668. }
  2669. var model = {
  2670. preTransformNode: preTransformNode
  2671. }
  2672. var modules = [
  2673. klass,
  2674. style,
  2675. model
  2676. ]
  2677. /* */
  2678. var warn$2;
  2679. // in some cases, the event used has to be determined at runtime
  2680. // so we used some reserved tokens during compile.
  2681. var RANGE_TOKEN = '__r';
  2682. function model$1 (
  2683. el,
  2684. dir,
  2685. _warn
  2686. ) {
  2687. warn$2 = _warn;
  2688. var value = dir.value;
  2689. var modifiers = dir.modifiers;
  2690. var tag = el.tag;
  2691. var type = el.attrsMap.type;
  2692. if (process.env.NODE_ENV !== 'production') {
  2693. // inputs with type="file" are read only and setting the input's
  2694. // value will throw an error.
  2695. if (tag === 'input' && type === 'file') {
  2696. warn$2(
  2697. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  2698. "File inputs are read only. Use a v-on:change listener instead."
  2699. );
  2700. }
  2701. }
  2702. if (el.component) {
  2703. genComponentModel(el, value, modifiers);
  2704. // component v-model doesn't need extra runtime
  2705. return false
  2706. } else if (tag === 'select') {
  2707. genSelect(el, value, modifiers);
  2708. } else if (tag === 'input' && type === 'checkbox') {
  2709. genCheckboxModel(el, value, modifiers);
  2710. } else if (tag === 'input' && type === 'radio') {
  2711. genRadioModel(el, value, modifiers);
  2712. } else if (tag === 'input' || tag === 'textarea') {
  2713. genDefaultModel(el, value, modifiers);
  2714. } else if (!config.isReservedTag(tag)) {
  2715. genComponentModel(el, value, modifiers);
  2716. // component v-model doesn't need extra runtime
  2717. return false
  2718. } else if (process.env.NODE_ENV !== 'production') {
  2719. warn$2(
  2720. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  2721. "v-model is not supported on this element type. " +
  2722. 'If you are working with contenteditable, it\'s recommended to ' +
  2723. 'wrap a library dedicated for that purpose inside a custom component.'
  2724. );
  2725. }
  2726. // ensure runtime directive metadata
  2727. return true
  2728. }
  2729. function genCheckboxModel (
  2730. el,
  2731. value,
  2732. modifiers
  2733. ) {
  2734. var number = modifiers && modifiers.number;
  2735. var valueBinding = getBindingAttr(el, 'value') || 'null';
  2736. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  2737. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  2738. addProp(el, 'checked',
  2739. "Array.isArray(" + value + ")" +
  2740. "?_i(" + value + "," + valueBinding + ")>-1" + (
  2741. trueValueBinding === 'true'
  2742. ? (":(" + value + ")")
  2743. : (":_q(" + value + "," + trueValueBinding + ")")
  2744. )
  2745. );
  2746. addHandler(el, 'change',
  2747. "var $$a=" + value + "," +
  2748. '$$el=$event.target,' +
  2749. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  2750. 'if(Array.isArray($$a)){' +
  2751. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  2752. '$$i=_i($$a,$$v);' +
  2753. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  2754. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  2755. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  2756. null, true
  2757. );
  2758. }
  2759. function genRadioModel (
  2760. el,
  2761. value,
  2762. modifiers
  2763. ) {
  2764. var number = modifiers && modifiers.number;
  2765. var valueBinding = getBindingAttr(el, 'value') || 'null';
  2766. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  2767. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  2768. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  2769. }
  2770. function genSelect (
  2771. el,
  2772. value,
  2773. modifiers
  2774. ) {
  2775. var number = modifiers && modifiers.number;
  2776. var selectedVal = "Array.prototype.filter" +
  2777. ".call($event.target.options,function(o){return o.selected})" +
  2778. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  2779. "return " + (number ? '_n(val)' : 'val') + "})";
  2780. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  2781. var code = "var $$selectedVal = " + selectedVal + ";";
  2782. code = code + " " + (genAssignmentCode(value, assignment));
  2783. addHandler(el, 'change', code, null, true);
  2784. }
  2785. function genDefaultModel (
  2786. el,
  2787. value,
  2788. modifiers
  2789. ) {
  2790. var type = el.attrsMap.type;
  2791. // warn if v-bind:value conflicts with v-model
  2792. // except for inputs with v-bind:type
  2793. if (process.env.NODE_ENV !== 'production') {
  2794. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  2795. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  2796. if (value$1 && !typeBinding) {
  2797. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  2798. warn$2(
  2799. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  2800. 'because the latter already expands to a value binding internally'
  2801. );
  2802. }
  2803. }
  2804. var ref = modifiers || {};
  2805. var lazy = ref.lazy;
  2806. var number = ref.number;
  2807. var trim = ref.trim;
  2808. var needCompositionGuard = !lazy && type !== 'range';
  2809. var event = lazy
  2810. ? 'change'
  2811. : type === 'range'
  2812. ? RANGE_TOKEN
  2813. : 'input';
  2814. var valueExpression = '$event.target.value';
  2815. if (trim) {
  2816. valueExpression = "$event.target.value.trim()";
  2817. }
  2818. if (number) {
  2819. valueExpression = "_n(" + valueExpression + ")";
  2820. }
  2821. var code = genAssignmentCode(value, valueExpression);
  2822. if (needCompositionGuard) {
  2823. code = "if($event.target.composing)return;" + code;
  2824. }
  2825. addProp(el, 'value', ("(" + value + ")"));
  2826. addHandler(el, event, code, null, true);
  2827. if (trim || number) {
  2828. addHandler(el, 'blur', '$forceUpdate()');
  2829. }
  2830. }
  2831. /* */
  2832. function text (el, dir) {
  2833. if (dir.value) {
  2834. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
  2835. }
  2836. }
  2837. /* */
  2838. function html (el, dir) {
  2839. if (dir.value) {
  2840. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
  2841. }
  2842. }
  2843. var directives = {
  2844. model: model$1,
  2845. text: text,
  2846. html: html
  2847. }
  2848. /* */
  2849. var baseOptions = {
  2850. expectHTML: true,
  2851. modules: modules,
  2852. directives: directives,
  2853. isPreTag: isPreTag,
  2854. isUnaryTag: isUnaryTag,
  2855. mustUseProp: mustUseProp,
  2856. canBeLeftOpenTag: canBeLeftOpenTag,
  2857. isReservedTag: isReservedTag,
  2858. getTagNamespace: getTagNamespace,
  2859. staticKeys: genStaticKeys(modules)
  2860. };
  2861. /* */
  2862. var isStaticKey;
  2863. var isPlatformReservedTag;
  2864. var genStaticKeysCached = cached(genStaticKeys$1);
  2865. /**
  2866. * Goal of the optimizer: walk the generated template AST tree
  2867. * and detect sub-trees that are purely static, i.e. parts of
  2868. * the DOM that never needs to change.
  2869. *
  2870. * Once we detect these sub-trees, we can:
  2871. *
  2872. * 1. Hoist them into constants, so that we no longer need to
  2873. * create fresh nodes for them on each re-render;
  2874. * 2. Completely skip them in the patching process.
  2875. */
  2876. function optimize (root, options) {
  2877. if (!root) { return }
  2878. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  2879. isPlatformReservedTag = options.isReservedTag || no;
  2880. // first pass: mark all non-static nodes.
  2881. markStatic(root);
  2882. // second pass: mark static roots.
  2883. markStaticRoots(root, false);
  2884. }
  2885. function genStaticKeys$1 (keys) {
  2886. return makeMap(
  2887. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  2888. (keys ? ',' + keys : '')
  2889. )
  2890. }
  2891. function markStatic (node) {
  2892. node.static = isStatic(node);
  2893. if (node.type === 1) {
  2894. // do not make component slot content static. this avoids
  2895. // 1. components not able to mutate slot nodes
  2896. // 2. static slot content fails for hot-reloading
  2897. if (
  2898. !isPlatformReservedTag(node.tag) &&
  2899. node.tag !== 'slot' &&
  2900. node.attrsMap['inline-template'] == null
  2901. ) {
  2902. return
  2903. }
  2904. for (var i = 0, l = node.children.length; i < l; i++) {
  2905. var child = node.children[i];
  2906. markStatic(child);
  2907. if (!child.static) {
  2908. node.static = false;
  2909. }
  2910. }
  2911. if (node.ifConditions) {
  2912. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  2913. var block = node.ifConditions[i$1].block;
  2914. markStatic(block);
  2915. if (!block.static) {
  2916. node.static = false;
  2917. }
  2918. }
  2919. }
  2920. }
  2921. }
  2922. function markStaticRoots (node, isInFor) {
  2923. if (node.type === 1) {
  2924. if (node.static || node.once) {
  2925. node.staticInFor = isInFor;
  2926. }
  2927. // For a node to qualify as a static root, it should have children that
  2928. // are not just static text. Otherwise the cost of hoisting out will
  2929. // outweigh the benefits and it's better off to just always render it fresh.
  2930. if (node.static && node.children.length && !(
  2931. node.children.length === 1 &&
  2932. node.children[0].type === 3
  2933. )) {
  2934. node.staticRoot = true;
  2935. return
  2936. } else {
  2937. node.staticRoot = false;
  2938. }
  2939. if (node.children) {
  2940. for (var i = 0, l = node.children.length; i < l; i++) {
  2941. markStaticRoots(node.children[i], isInFor || !!node.for);
  2942. }
  2943. }
  2944. if (node.ifConditions) {
  2945. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  2946. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  2947. }
  2948. }
  2949. }
  2950. }
  2951. function isStatic (node) {
  2952. if (node.type === 2) { // expression
  2953. return false
  2954. }
  2955. if (node.type === 3) { // text
  2956. return true
  2957. }
  2958. return !!(node.pre || (
  2959. !node.hasBindings && // no dynamic bindings
  2960. !node.if && !node.for && // not v-if or v-for or v-else
  2961. !isBuiltInTag(node.tag) && // not a built-in
  2962. isPlatformReservedTag(node.tag) && // not a component
  2963. !isDirectChildOfTemplateFor(node) &&
  2964. Object.keys(node).every(isStaticKey)
  2965. ))
  2966. }
  2967. function isDirectChildOfTemplateFor (node) {
  2968. while (node.parent) {
  2969. node = node.parent;
  2970. if (node.tag !== 'template') {
  2971. return false
  2972. }
  2973. if (node.for) {
  2974. return true
  2975. }
  2976. }
  2977. return false
  2978. }
  2979. /* */
  2980. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  2981. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  2982. // KeyboardEvent.keyCode aliases
  2983. var keyCodes = {
  2984. esc: 27,
  2985. tab: 9,
  2986. enter: 13,
  2987. space: 32,
  2988. up: 38,
  2989. left: 37,
  2990. right: 39,
  2991. down: 40,
  2992. 'delete': [8, 46]
  2993. };
  2994. // KeyboardEvent.key aliases
  2995. var keyNames = {
  2996. esc: 'Escape',
  2997. tab: 'Tab',
  2998. enter: 'Enter',
  2999. space: ' ',
  3000. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  3001. up: ['Up', 'ArrowUp'],
  3002. left: ['Left', 'ArrowLeft'],
  3003. right: ['Right', 'ArrowRight'],
  3004. down: ['Down', 'ArrowDown'],
  3005. 'delete': ['Backspace', 'Delete']
  3006. };
  3007. // #4868: modifiers that prevent the execution of the listener
  3008. // need to explicitly return null so that we can determine whether to remove
  3009. // the listener for .once
  3010. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  3011. var modifierCode = {
  3012. stop: '$event.stopPropagation();',
  3013. prevent: '$event.preventDefault();',
  3014. self: genGuard("$event.target !== $event.currentTarget"),
  3015. ctrl: genGuard("!$event.ctrlKey"),
  3016. shift: genGuard("!$event.shiftKey"),
  3017. alt: genGuard("!$event.altKey"),
  3018. meta: genGuard("!$event.metaKey"),
  3019. left: genGuard("'button' in $event && $event.button !== 0"),
  3020. middle: genGuard("'button' in $event && $event.button !== 1"),
  3021. right: genGuard("'button' in $event && $event.button !== 2")
  3022. };
  3023. function genHandlers (
  3024. events,
  3025. isNative,
  3026. warn
  3027. ) {
  3028. var res = isNative ? 'nativeOn:{' : 'on:{';
  3029. for (var name in events) {
  3030. res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
  3031. }
  3032. return res.slice(0, -1) + '}'
  3033. }
  3034. function genHandler (
  3035. name,
  3036. handler
  3037. ) {
  3038. if (!handler) {
  3039. return 'function(){}'
  3040. }
  3041. if (Array.isArray(handler)) {
  3042. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  3043. }
  3044. var isMethodPath = simplePathRE.test(handler.value);
  3045. var isFunctionExpression = fnExpRE.test(handler.value);
  3046. if (!handler.modifiers) {
  3047. if (isMethodPath || isFunctionExpression) {
  3048. return handler.value
  3049. }
  3050. /* istanbul ignore if */
  3051. return ("function($event){" + (handler.value) + "}") // inline statement
  3052. } else {
  3053. var code = '';
  3054. var genModifierCode = '';
  3055. var keys = [];
  3056. for (var key in handler.modifiers) {
  3057. if (modifierCode[key]) {
  3058. genModifierCode += modifierCode[key];
  3059. // left/right
  3060. if (keyCodes[key]) {
  3061. keys.push(key);
  3062. }
  3063. } else if (key === 'exact') {
  3064. var modifiers = (handler.modifiers);
  3065. genModifierCode += genGuard(
  3066. ['ctrl', 'shift', 'alt', 'meta']
  3067. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  3068. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  3069. .join('||')
  3070. );
  3071. } else {
  3072. keys.push(key);
  3073. }
  3074. }
  3075. if (keys.length) {
  3076. code += genKeyFilter(keys);
  3077. }
  3078. // Make sure modifiers like prevent and stop get executed after key filtering
  3079. if (genModifierCode) {
  3080. code += genModifierCode;
  3081. }
  3082. var handlerCode = isMethodPath
  3083. ? ("return " + (handler.value) + "($event)")
  3084. : isFunctionExpression
  3085. ? ("return (" + (handler.value) + ")($event)")
  3086. : handler.value;
  3087. /* istanbul ignore if */
  3088. return ("function($event){" + code + handlerCode + "}")
  3089. }
  3090. }
  3091. function genKeyFilter (keys) {
  3092. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  3093. }
  3094. function genFilterCode (key) {
  3095. var keyVal = parseInt(key, 10);
  3096. if (keyVal) {
  3097. return ("$event.keyCode!==" + keyVal)
  3098. }
  3099. var keyCode = keyCodes[key];
  3100. var keyName = keyNames[key];
  3101. return (
  3102. "_k($event.keyCode," +
  3103. (JSON.stringify(key)) + "," +
  3104. (JSON.stringify(keyCode)) + "," +
  3105. "$event.key," +
  3106. "" + (JSON.stringify(keyName)) +
  3107. ")"
  3108. )
  3109. }
  3110. /* */
  3111. function on (el, dir) {
  3112. if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
  3113. warn("v-on without argument does not support modifiers.");
  3114. }
  3115. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  3116. }
  3117. /* */
  3118. function bind$1 (el, dir) {
  3119. el.wrapData = function (code) {
  3120. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  3121. };
  3122. }
  3123. /* */
  3124. var baseDirectives = {
  3125. on: on,
  3126. bind: bind$1,
  3127. cloak: noop
  3128. }
  3129. /* */
  3130. var CodegenState = function CodegenState (options) {
  3131. this.options = options;
  3132. this.warn = options.warn || baseWarn;
  3133. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  3134. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  3135. this.directives = extend(extend({}, baseDirectives), options.directives);
  3136. var isReservedTag = options.isReservedTag || no;
  3137. this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
  3138. this.onceId = 0;
  3139. this.staticRenderFns = [];
  3140. };
  3141. function generate (
  3142. ast,
  3143. options
  3144. ) {
  3145. var state = new CodegenState(options);
  3146. var code = ast ? genElement(ast, state) : '_c("div")';
  3147. return {
  3148. render: ("with(this){return " + code + "}"),
  3149. staticRenderFns: state.staticRenderFns
  3150. }
  3151. }
  3152. function genElement (el, state) {
  3153. if (el.staticRoot && !el.staticProcessed) {
  3154. return genStatic(el, state)
  3155. } else if (el.once && !el.onceProcessed) {
  3156. return genOnce(el, state)
  3157. } else if (el.for && !el.forProcessed) {
  3158. return genFor(el, state)
  3159. } else if (el.if && !el.ifProcessed) {
  3160. return genIf(el, state)
  3161. } else if (el.tag === 'template' && !el.slotTarget) {
  3162. return genChildren(el, state) || 'void 0'
  3163. } else if (el.tag === 'slot') {
  3164. return genSlot(el, state)
  3165. } else {
  3166. // component or element
  3167. var code;
  3168. if (el.component) {
  3169. code = genComponent(el.component, el, state);
  3170. } else {
  3171. var data = el.plain ? undefined : genData$2(el, state);
  3172. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  3173. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  3174. }
  3175. // module transforms
  3176. for (var i = 0; i < state.transforms.length; i++) {
  3177. code = state.transforms[i](el, code);
  3178. }
  3179. return code
  3180. }
  3181. }
  3182. // hoist static sub-trees out
  3183. function genStatic (el, state) {
  3184. el.staticProcessed = true;
  3185. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  3186. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  3187. }
  3188. // v-once
  3189. function genOnce (el, state) {
  3190. el.onceProcessed = true;
  3191. if (el.if && !el.ifProcessed) {
  3192. return genIf(el, state)
  3193. } else if (el.staticInFor) {
  3194. var key = '';
  3195. var parent = el.parent;
  3196. while (parent) {
  3197. if (parent.for) {
  3198. key = parent.key;
  3199. break
  3200. }
  3201. parent = parent.parent;
  3202. }
  3203. if (!key) {
  3204. process.env.NODE_ENV !== 'production' && state.warn(
  3205. "v-once can only be used inside v-for that is keyed. "
  3206. );
  3207. return genElement(el, state)
  3208. }
  3209. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  3210. } else {
  3211. return genStatic(el, state)
  3212. }
  3213. }
  3214. function genIf (
  3215. el,
  3216. state,
  3217. altGen,
  3218. altEmpty
  3219. ) {
  3220. el.ifProcessed = true; // avoid recursion
  3221. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  3222. }
  3223. function genIfConditions (
  3224. conditions,
  3225. state,
  3226. altGen,
  3227. altEmpty
  3228. ) {
  3229. if (!conditions.length) {
  3230. return altEmpty || '_e()'
  3231. }
  3232. var condition = conditions.shift();
  3233. if (condition.exp) {
  3234. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  3235. } else {
  3236. return ("" + (genTernaryExp(condition.block)))
  3237. }
  3238. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  3239. function genTernaryExp (el) {
  3240. return altGen
  3241. ? altGen(el, state)
  3242. : el.once
  3243. ? genOnce(el, state)
  3244. : genElement(el, state)
  3245. }
  3246. }
  3247. function genFor (
  3248. el,
  3249. state,
  3250. altGen,
  3251. altHelper
  3252. ) {
  3253. var exp = el.for;
  3254. var alias = el.alias;
  3255. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  3256. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  3257. if (process.env.NODE_ENV !== 'production' &&
  3258. state.maybeComponent(el) &&
  3259. el.tag !== 'slot' &&
  3260. el.tag !== 'template' &&
  3261. !el.key
  3262. ) {
  3263. state.warn(
  3264. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  3265. "v-for should have explicit keys. " +
  3266. "See https://vuejs.org/guide/list.html#key for more info.",
  3267. true /* tip */
  3268. );
  3269. }
  3270. el.forProcessed = true; // avoid recursion
  3271. return (altHelper || '_l') + "((" + exp + ")," +
  3272. "function(" + alias + iterator1 + iterator2 + "){" +
  3273. "return " + ((altGen || genElement)(el, state)) +
  3274. '})'
  3275. }
  3276. function genData$2 (el, state) {
  3277. var data = '{';
  3278. // directives first.
  3279. // directives may mutate the el's other properties before they are generated.
  3280. var dirs = genDirectives(el, state);
  3281. if (dirs) { data += dirs + ','; }
  3282. // key
  3283. if (el.key) {
  3284. data += "key:" + (el.key) + ",";
  3285. }
  3286. // ref
  3287. if (el.ref) {
  3288. data += "ref:" + (el.ref) + ",";
  3289. }
  3290. if (el.refInFor) {
  3291. data += "refInFor:true,";
  3292. }
  3293. // pre
  3294. if (el.pre) {
  3295. data += "pre:true,";
  3296. }
  3297. // record original tag name for components using "is" attribute
  3298. if (el.component) {
  3299. data += "tag:\"" + (el.tag) + "\",";
  3300. }
  3301. // module data generation functions
  3302. for (var i = 0; i < state.dataGenFns.length; i++) {
  3303. data += state.dataGenFns[i](el);
  3304. }
  3305. // attributes
  3306. if (el.attrs) {
  3307. data += "attrs:{" + (genProps(el.attrs)) + "},";
  3308. }
  3309. // DOM props
  3310. if (el.props) {
  3311. data += "domProps:{" + (genProps(el.props)) + "},";
  3312. }
  3313. // event handlers
  3314. if (el.events) {
  3315. data += (genHandlers(el.events, false, state.warn)) + ",";
  3316. }
  3317. if (el.nativeEvents) {
  3318. data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
  3319. }
  3320. // slot target
  3321. // only for non-scoped slots
  3322. if (el.slotTarget && !el.slotScope) {
  3323. data += "slot:" + (el.slotTarget) + ",";
  3324. }
  3325. // scoped slots
  3326. if (el.scopedSlots) {
  3327. data += (genScopedSlots(el.scopedSlots, state)) + ",";
  3328. }
  3329. // component v-model
  3330. if (el.model) {
  3331. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  3332. }
  3333. // inline-template
  3334. if (el.inlineTemplate) {
  3335. var inlineTemplate = genInlineTemplate(el, state);
  3336. if (inlineTemplate) {
  3337. data += inlineTemplate + ",";
  3338. }
  3339. }
  3340. data = data.replace(/,$/, '') + '}';
  3341. // v-bind data wrap
  3342. if (el.wrapData) {
  3343. data = el.wrapData(data);
  3344. }
  3345. // v-on data wrap
  3346. if (el.wrapListeners) {
  3347. data = el.wrapListeners(data);
  3348. }
  3349. return data
  3350. }
  3351. function genDirectives (el, state) {
  3352. var dirs = el.directives;
  3353. if (!dirs) { return }
  3354. var res = 'directives:[';
  3355. var hasRuntime = false;
  3356. var i, l, dir, needRuntime;
  3357. for (i = 0, l = dirs.length; i < l; i++) {
  3358. dir = dirs[i];
  3359. needRuntime = true;
  3360. var gen = state.directives[dir.name];
  3361. if (gen) {
  3362. // compile-time directive that manipulates AST.
  3363. // returns true if it also needs a runtime counterpart.
  3364. needRuntime = !!gen(el, dir, state.warn);
  3365. }
  3366. if (needRuntime) {
  3367. hasRuntime = true;
  3368. 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))) : '') + "},";
  3369. }
  3370. }
  3371. if (hasRuntime) {
  3372. return res.slice(0, -1) + ']'
  3373. }
  3374. }
  3375. function genInlineTemplate (el, state) {
  3376. var ast = el.children[0];
  3377. if (process.env.NODE_ENV !== 'production' && (
  3378. el.children.length !== 1 || ast.type !== 1
  3379. )) {
  3380. state.warn('Inline-template components must have exactly one child element.');
  3381. }
  3382. if (ast.type === 1) {
  3383. var inlineRenderFns = generate(ast, state.options);
  3384. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  3385. }
  3386. }
  3387. function genScopedSlots (
  3388. slots,
  3389. state
  3390. ) {
  3391. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
  3392. return genScopedSlot(key, slots[key], state)
  3393. }).join(',')) + "])")
  3394. }
  3395. function genScopedSlot (
  3396. key,
  3397. el,
  3398. state
  3399. ) {
  3400. if (el.for && !el.forProcessed) {
  3401. return genForScopedSlot(key, el, state)
  3402. }
  3403. var fn = "function(" + (String(el.slotScope)) + "){" +
  3404. "return " + (el.tag === 'template'
  3405. ? el.if
  3406. ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined")
  3407. : genChildren(el, state) || 'undefined'
  3408. : genElement(el, state)) + "}";
  3409. return ("{key:" + key + ",fn:" + fn + "}")
  3410. }
  3411. function genForScopedSlot (
  3412. key,
  3413. el,
  3414. state
  3415. ) {
  3416. var exp = el.for;
  3417. var alias = el.alias;
  3418. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  3419. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  3420. el.forProcessed = true; // avoid recursion
  3421. return "_l((" + exp + ")," +
  3422. "function(" + alias + iterator1 + iterator2 + "){" +
  3423. "return " + (genScopedSlot(key, el, state)) +
  3424. '})'
  3425. }
  3426. function genChildren (
  3427. el,
  3428. state,
  3429. checkSkip,
  3430. altGenElement,
  3431. altGenNode
  3432. ) {
  3433. var children = el.children;
  3434. if (children.length) {
  3435. var el$1 = children[0];
  3436. // optimize single v-for
  3437. if (children.length === 1 &&
  3438. el$1.for &&
  3439. el$1.tag !== 'template' &&
  3440. el$1.tag !== 'slot'
  3441. ) {
  3442. return (altGenElement || genElement)(el$1, state)
  3443. }
  3444. var normalizationType = checkSkip
  3445. ? getNormalizationType(children, state.maybeComponent)
  3446. : 0;
  3447. var gen = altGenNode || genNode;
  3448. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
  3449. }
  3450. }
  3451. // determine the normalization needed for the children array.
  3452. // 0: no normalization needed
  3453. // 1: simple normalization needed (possible 1-level deep nested array)
  3454. // 2: full normalization needed
  3455. function getNormalizationType (
  3456. children,
  3457. maybeComponent
  3458. ) {
  3459. var res = 0;
  3460. for (var i = 0; i < children.length; i++) {
  3461. var el = children[i];
  3462. if (el.type !== 1) {
  3463. continue
  3464. }
  3465. if (needsNormalization(el) ||
  3466. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  3467. res = 2;
  3468. break
  3469. }
  3470. if (maybeComponent(el) ||
  3471. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  3472. res = 1;
  3473. }
  3474. }
  3475. return res
  3476. }
  3477. function needsNormalization (el) {
  3478. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  3479. }
  3480. function genNode (node, state) {
  3481. if (node.type === 1) {
  3482. return genElement(node, state)
  3483. } if (node.type === 3 && node.isComment) {
  3484. return genComment(node)
  3485. } else {
  3486. return genText(node)
  3487. }
  3488. }
  3489. function genText (text) {
  3490. return ("_v(" + (text.type === 2
  3491. ? text.expression // no need for () because already wrapped in _s()
  3492. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  3493. }
  3494. function genComment (comment) {
  3495. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  3496. }
  3497. function genSlot (el, state) {
  3498. var slotName = el.slotName || '"default"';
  3499. var children = genChildren(el, state);
  3500. var res = "_t(" + slotName + (children ? ("," + children) : '');
  3501. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  3502. var bind$$1 = el.attrsMap['v-bind'];
  3503. if ((attrs || bind$$1) && !children) {
  3504. res += ",null";
  3505. }
  3506. if (attrs) {
  3507. res += "," + attrs;
  3508. }
  3509. if (bind$$1) {
  3510. res += (attrs ? '' : ',null') + "," + bind$$1;
  3511. }
  3512. return res + ')'
  3513. }
  3514. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  3515. function genComponent (
  3516. componentName,
  3517. el,
  3518. state
  3519. ) {
  3520. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  3521. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  3522. }
  3523. function genProps (props) {
  3524. var res = '';
  3525. for (var i = 0; i < props.length; i++) {
  3526. var prop = props[i];
  3527. /* istanbul ignore if */
  3528. {
  3529. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  3530. }
  3531. }
  3532. return res.slice(0, -1)
  3533. }
  3534. // #3895, #4268
  3535. function transformSpecialNewlines (text) {
  3536. return text
  3537. .replace(/\u2028/g, '\\u2028')
  3538. .replace(/\u2029/g, '\\u2029')
  3539. }
  3540. /* */
  3541. // these keywords should not appear inside expressions, but operators like
  3542. // typeof, instanceof and in are allowed
  3543. var prohibitedKeywordRE = new RegExp('\\b' + (
  3544. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  3545. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  3546. 'extends,finally,continue,debugger,function,arguments'
  3547. ).split(',').join('\\b|\\b') + '\\b');
  3548. // these unary operators should not be used as property/method names
  3549. var unaryOperatorsRE = new RegExp('\\b' + (
  3550. 'delete,typeof,void'
  3551. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  3552. // strip strings in expressions
  3553. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  3554. // detect problematic expressions in a template
  3555. function detectErrors (ast) {
  3556. var errors = [];
  3557. if (ast) {
  3558. checkNode(ast, errors);
  3559. }
  3560. return errors
  3561. }
  3562. function checkNode (node, errors) {
  3563. if (node.type === 1) {
  3564. for (var name in node.attrsMap) {
  3565. if (dirRE.test(name)) {
  3566. var value = node.attrsMap[name];
  3567. if (value) {
  3568. if (name === 'v-for') {
  3569. checkFor(node, ("v-for=\"" + value + "\""), errors);
  3570. } else if (onRE.test(name)) {
  3571. checkEvent(value, (name + "=\"" + value + "\""), errors);
  3572. } else {
  3573. checkExpression(value, (name + "=\"" + value + "\""), errors);
  3574. }
  3575. }
  3576. }
  3577. }
  3578. if (node.children) {
  3579. for (var i = 0; i < node.children.length; i++) {
  3580. checkNode(node.children[i], errors);
  3581. }
  3582. }
  3583. } else if (node.type === 2) {
  3584. checkExpression(node.expression, node.text, errors);
  3585. }
  3586. }
  3587. function checkEvent (exp, text, errors) {
  3588. var stipped = exp.replace(stripStringRE, '');
  3589. var keywordMatch = stipped.match(unaryOperatorsRE);
  3590. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  3591. errors.push(
  3592. "avoid using JavaScript unary operator as property name: " +
  3593. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  3594. );
  3595. }
  3596. checkExpression(exp, text, errors);
  3597. }
  3598. function checkFor (node, text, errors) {
  3599. checkExpression(node.for || '', text, errors);
  3600. checkIdentifier(node.alias, 'v-for alias', text, errors);
  3601. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  3602. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  3603. }
  3604. function checkIdentifier (
  3605. ident,
  3606. type,
  3607. text,
  3608. errors
  3609. ) {
  3610. if (typeof ident === 'string') {
  3611. try {
  3612. new Function(("var " + ident + "=_"));
  3613. } catch (e) {
  3614. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  3615. }
  3616. }
  3617. }
  3618. function checkExpression (exp, text, errors) {
  3619. try {
  3620. new Function(("return " + exp));
  3621. } catch (e) {
  3622. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  3623. if (keywordMatch) {
  3624. errors.push(
  3625. "avoid using JavaScript keyword as property name: " +
  3626. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim())
  3627. );
  3628. } else {
  3629. errors.push(
  3630. "invalid expression: " + (e.message) + " in\n\n" +
  3631. " " + exp + "\n\n" +
  3632. " Raw expression: " + (text.trim()) + "\n"
  3633. );
  3634. }
  3635. }
  3636. }
  3637. /* */
  3638. function createFunction (code, errors) {
  3639. try {
  3640. return new Function(code)
  3641. } catch (err) {
  3642. errors.push({ err: err, code: code });
  3643. return noop
  3644. }
  3645. }
  3646. function createCompileToFunctionFn (compile) {
  3647. var cache = Object.create(null);
  3648. return function compileToFunctions (
  3649. template,
  3650. options,
  3651. vm
  3652. ) {
  3653. options = extend({}, options);
  3654. var warn$$1 = options.warn || warn;
  3655. delete options.warn;
  3656. /* istanbul ignore if */
  3657. if (process.env.NODE_ENV !== 'production') {
  3658. // detect possible CSP restriction
  3659. try {
  3660. new Function('return 1');
  3661. } catch (e) {
  3662. if (e.toString().match(/unsafe-eval|CSP/)) {
  3663. warn$$1(
  3664. 'It seems you are using the standalone build of Vue.js in an ' +
  3665. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  3666. 'The template compiler cannot work in this environment. Consider ' +
  3667. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  3668. 'templates into render functions.'
  3669. );
  3670. }
  3671. }
  3672. }
  3673. // check cache
  3674. var key = options.delimiters
  3675. ? String(options.delimiters) + template
  3676. : template;
  3677. if (cache[key]) {
  3678. return cache[key]
  3679. }
  3680. // compile
  3681. var compiled = compile(template, options);
  3682. // check compilation errors/tips
  3683. if (process.env.NODE_ENV !== 'production') {
  3684. if (compiled.errors && compiled.errors.length) {
  3685. warn$$1(
  3686. "Error compiling template:\n\n" + template + "\n\n" +
  3687. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  3688. vm
  3689. );
  3690. }
  3691. if (compiled.tips && compiled.tips.length) {
  3692. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  3693. }
  3694. }
  3695. // turn code into functions
  3696. var res = {};
  3697. var fnGenErrors = [];
  3698. res.render = createFunction(compiled.render, fnGenErrors);
  3699. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  3700. return createFunction(code, fnGenErrors)
  3701. });
  3702. // check function generation errors.
  3703. // this should only happen if there is a bug in the compiler itself.
  3704. // mostly for codegen development use
  3705. /* istanbul ignore if */
  3706. if (process.env.NODE_ENV !== 'production') {
  3707. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  3708. warn$$1(
  3709. "Failed to generate render function:\n\n" +
  3710. fnGenErrors.map(function (ref) {
  3711. var err = ref.err;
  3712. var code = ref.code;
  3713. return ((err.toString()) + " in\n\n" + code + "\n");
  3714. }).join('\n'),
  3715. vm
  3716. );
  3717. }
  3718. }
  3719. return (cache[key] = res)
  3720. }
  3721. }
  3722. /* */
  3723. function createCompilerCreator (baseCompile) {
  3724. return function createCompiler (baseOptions) {
  3725. function compile (
  3726. template,
  3727. options
  3728. ) {
  3729. var finalOptions = Object.create(baseOptions);
  3730. var errors = [];
  3731. var tips = [];
  3732. finalOptions.warn = function (msg, tip) {
  3733. (tip ? tips : errors).push(msg);
  3734. };
  3735. if (options) {
  3736. // merge custom modules
  3737. if (options.modules) {
  3738. finalOptions.modules =
  3739. (baseOptions.modules || []).concat(options.modules);
  3740. }
  3741. // merge custom directives
  3742. if (options.directives) {
  3743. finalOptions.directives = extend(
  3744. Object.create(baseOptions.directives || null),
  3745. options.directives
  3746. );
  3747. }
  3748. // copy other options
  3749. for (var key in options) {
  3750. if (key !== 'modules' && key !== 'directives') {
  3751. finalOptions[key] = options[key];
  3752. }
  3753. }
  3754. }
  3755. var compiled = baseCompile(template, finalOptions);
  3756. if (process.env.NODE_ENV !== 'production') {
  3757. errors.push.apply(errors, detectErrors(compiled.ast));
  3758. }
  3759. compiled.errors = errors;
  3760. compiled.tips = tips;
  3761. return compiled
  3762. }
  3763. return {
  3764. compile: compile,
  3765. compileToFunctions: createCompileToFunctionFn(compile)
  3766. }
  3767. }
  3768. }
  3769. /* */
  3770. // `createCompilerCreator` allows creating compilers that use alternative
  3771. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  3772. // Here we just export a default compiler using the default parts.
  3773. var createCompiler = createCompilerCreator(function baseCompile (
  3774. template,
  3775. options
  3776. ) {
  3777. var ast = parse(template.trim(), options);
  3778. if (options.optimize !== false) {
  3779. optimize(ast, options);
  3780. }
  3781. var code = generate(ast, options);
  3782. return {
  3783. ast: ast,
  3784. render: code.render,
  3785. staticRenderFns: code.staticRenderFns
  3786. }
  3787. });
  3788. /* */
  3789. var ref = createCompiler(baseOptions);
  3790. var compile = ref.compile;
  3791. var compileToFunctions = ref.compileToFunctions;
  3792. /* */
  3793. var isAttr = makeMap(
  3794. 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
  3795. 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
  3796. 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' +
  3797. 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' +
  3798. 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' +
  3799. 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
  3800. 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
  3801. 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
  3802. 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
  3803. 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
  3804. 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
  3805. 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
  3806. 'target,title,type,usemap,value,width,wrap'
  3807. );
  3808. /* istanbul ignore next */
  3809. var isRenderableAttr = function (name) {
  3810. return (
  3811. isAttr(name) ||
  3812. name.indexOf('data-') === 0 ||
  3813. name.indexOf('aria-') === 0
  3814. )
  3815. };
  3816. var propsToAttrMap = {
  3817. acceptCharset: 'accept-charset',
  3818. className: 'class',
  3819. htmlFor: 'for',
  3820. httpEquiv: 'http-equiv'
  3821. };
  3822. var ESC = {
  3823. '<': '&lt;',
  3824. '>': '&gt;',
  3825. '"': '&quot;',
  3826. '&': '&amp;'
  3827. };
  3828. function escape (s) {
  3829. return s.replace(/[<>"&]/g, escapeChar)
  3830. }
  3831. function escapeChar (a) {
  3832. return ESC[a] || a
  3833. }
  3834. /* */
  3835. var plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
  3836. // let the model AST transform translate v-model into appropriate
  3837. // props bindings
  3838. function applyModelTransform (el, state) {
  3839. if (el.directives) {
  3840. for (var i = 0; i < el.directives.length; i++) {
  3841. var dir = el.directives[i];
  3842. if (dir.name === 'model') {
  3843. state.directives.model(el, dir, state.warn);
  3844. // remove value for textarea as its converted to text
  3845. if (el.tag === 'textarea' && el.props) {
  3846. el.props = el.props.filter(function (p) { return p.name !== 'value'; });
  3847. }
  3848. break
  3849. }
  3850. }
  3851. }
  3852. }
  3853. function genAttrSegments (
  3854. attrs
  3855. ) {
  3856. return attrs.map(function (ref) {
  3857. var name = ref.name;
  3858. var value = ref.value;
  3859. return genAttrSegment(name, value);
  3860. })
  3861. }
  3862. function genDOMPropSegments (
  3863. props,
  3864. attrs
  3865. ) {
  3866. var segments = [];
  3867. props.forEach(function (ref) {
  3868. var name = ref.name;
  3869. var value = ref.value;
  3870. name = propsToAttrMap[name] || name.toLowerCase();
  3871. if (isRenderableAttr(name) &&
  3872. !(attrs && attrs.some(function (a) { return a.name === name; }))
  3873. ) {
  3874. segments.push(genAttrSegment(name, value));
  3875. }
  3876. });
  3877. return segments
  3878. }
  3879. function genAttrSegment (name, value) {
  3880. if (plainStringRE.test(value)) {
  3881. // force double quote
  3882. value = value.replace(/^'|'$/g, '"');
  3883. // force enumerated attr to "true"
  3884. if (isEnumeratedAttr(name) && value !== "\"false\"") {
  3885. value = "\"true\"";
  3886. }
  3887. return {
  3888. type: RAW,
  3889. value: isBooleanAttr(name)
  3890. ? (" " + name + "=\"" + name + "\"")
  3891. : value === '""'
  3892. ? (" " + name)
  3893. : (" " + name + "=\"" + (JSON.parse(value)) + "\"")
  3894. }
  3895. } else {
  3896. return {
  3897. type: EXPRESSION,
  3898. value: ("_ssrAttr(" + (JSON.stringify(name)) + "," + value + ")")
  3899. }
  3900. }
  3901. }
  3902. function genClassSegments (
  3903. staticClass,
  3904. classBinding
  3905. ) {
  3906. if (staticClass && !classBinding) {
  3907. return [{ type: RAW, value: (" class=" + staticClass) }]
  3908. } else {
  3909. return [{
  3910. type: EXPRESSION,
  3911. value: ("_ssrClass(" + (staticClass || 'null') + "," + (classBinding || 'null') + ")")
  3912. }]
  3913. }
  3914. }
  3915. function genStyleSegments (
  3916. staticStyle,
  3917. parsedStaticStyle,
  3918. styleBinding,
  3919. vShowExpression
  3920. ) {
  3921. if (staticStyle && !styleBinding && !vShowExpression) {
  3922. return [{ type: RAW, value: (" style=" + (JSON.stringify(staticStyle))) }]
  3923. } else {
  3924. return [{
  3925. type: EXPRESSION,
  3926. value: ("_ssrStyle(" + (parsedStaticStyle || 'null') + "," + (styleBinding || 'null') + ", " + (vShowExpression
  3927. ? ("{ display: (" + vShowExpression + ") ? '' : 'none' }")
  3928. : 'null') + ")")
  3929. }]
  3930. }
  3931. }
  3932. /* */
  3933. /**
  3934. * In SSR, the vdom tree is generated only once and never patched, so
  3935. * we can optimize most element / trees into plain string render functions.
  3936. * The SSR optimizer walks the AST tree to detect optimizable elements and trees.
  3937. *
  3938. * The criteria for SSR optimizability is quite a bit looser than static tree
  3939. * detection (which is designed for client re-render). In SSR we bail only for
  3940. * components/slots/custom directives.
  3941. */
  3942. // optimizability constants
  3943. var optimizability = {
  3944. FALSE: 0, // whole sub tree un-optimizable
  3945. FULL: 1, // whole sub tree optimizable
  3946. SELF: 2, // self optimizable but has some un-optimizable children
  3947. CHILDREN: 3, // self un-optimizable but have fully optimizable children
  3948. PARTIAL: 4 // self un-optimizable with some un-optimizable children
  3949. };
  3950. var isPlatformReservedTag$1;
  3951. function optimize$1 (root, options) {
  3952. if (!root) { return }
  3953. isPlatformReservedTag$1 = options.isReservedTag || no;
  3954. walk(root, true);
  3955. }
  3956. function walk (node, isRoot) {
  3957. if (isUnOptimizableTree(node)) {
  3958. node.ssrOptimizability = optimizability.FALSE;
  3959. return
  3960. }
  3961. // root node or nodes with custom directives should always be a VNode
  3962. var selfUnoptimizable = isRoot || hasCustomDirective(node);
  3963. var check = function (child) {
  3964. if (child.ssrOptimizability !== optimizability.FULL) {
  3965. node.ssrOptimizability = selfUnoptimizable
  3966. ? optimizability.PARTIAL
  3967. : optimizability.SELF;
  3968. }
  3969. };
  3970. if (selfUnoptimizable) {
  3971. node.ssrOptimizability = optimizability.CHILDREN;
  3972. }
  3973. if (node.type === 1) {
  3974. for (var i = 0, l = node.children.length; i < l; i++) {
  3975. var child = node.children[i];
  3976. walk(child);
  3977. check(child);
  3978. }
  3979. if (node.ifConditions) {
  3980. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  3981. var block = node.ifConditions[i$1].block;
  3982. walk(block, isRoot);
  3983. check(block);
  3984. }
  3985. }
  3986. if (node.ssrOptimizability == null ||
  3987. (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))
  3988. ) {
  3989. node.ssrOptimizability = optimizability.FULL;
  3990. } else {
  3991. node.children = optimizeSiblings(node);
  3992. }
  3993. } else {
  3994. node.ssrOptimizability = optimizability.FULL;
  3995. }
  3996. }
  3997. function optimizeSiblings (el) {
  3998. var children = el.children;
  3999. var optimizedChildren = [];
  4000. var currentOptimizableGroup = [];
  4001. var pushGroup = function () {
  4002. if (currentOptimizableGroup.length) {
  4003. optimizedChildren.push({
  4004. type: 1,
  4005. parent: el,
  4006. tag: 'template',
  4007. attrsList: [],
  4008. attrsMap: {},
  4009. children: currentOptimizableGroup,
  4010. ssrOptimizability: optimizability.FULL
  4011. });
  4012. }
  4013. currentOptimizableGroup = [];
  4014. };
  4015. for (var i = 0; i < children.length; i++) {
  4016. var c = children[i];
  4017. if (c.ssrOptimizability === optimizability.FULL) {
  4018. currentOptimizableGroup.push(c);
  4019. } else {
  4020. // wrap fully-optimizable adjacent siblings inside a template tag
  4021. // so that they can be optimized into a single ssrNode by codegen
  4022. pushGroup();
  4023. optimizedChildren.push(c);
  4024. }
  4025. }
  4026. pushGroup();
  4027. return optimizedChildren
  4028. }
  4029. function isUnOptimizableTree (node) {
  4030. if (node.type === 2 || node.type === 3) { // text or expression
  4031. return false
  4032. }
  4033. return (
  4034. isBuiltInTag(node.tag) || // built-in (slot, component)
  4035. !isPlatformReservedTag$1(node.tag) || // custom component
  4036. !!node.component || // "is" component
  4037. isSelectWithModel(node) // <select v-model> requires runtime inspection
  4038. )
  4039. }
  4040. var isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
  4041. function hasCustomDirective (node) {
  4042. return (
  4043. node.type === 1 &&
  4044. node.directives &&
  4045. node.directives.some(function (d) { return !isBuiltInDir(d.name); })
  4046. )
  4047. }
  4048. // <select v-model> cannot be optimized because it requires a runtime check
  4049. // to determine proper selected option
  4050. function isSelectWithModel (node) {
  4051. return (
  4052. node.type === 1 &&
  4053. node.tag === 'select' &&
  4054. node.directives != null &&
  4055. node.directives.some(function (d) { return d.name === 'model'; })
  4056. )
  4057. }
  4058. /* */
  4059. // The SSR codegen is essentially extending the default codegen to handle
  4060. // SSR-optimizable nodes and turn them into string render fns. In cases where
  4061. // a node is not optimizable it simply falls back to the default codegen.
  4062. // segment types
  4063. var RAW = 0;
  4064. var INTERPOLATION = 1;
  4065. var EXPRESSION = 2;
  4066. function generate$1 (
  4067. ast,
  4068. options
  4069. ) {
  4070. var state = new CodegenState(options);
  4071. var code = ast ? genSSRElement(ast, state) : '_c("div")';
  4072. return {
  4073. render: ("with(this){return " + code + "}"),
  4074. staticRenderFns: state.staticRenderFns
  4075. }
  4076. }
  4077. function genSSRElement (el, state) {
  4078. if (el.for && !el.forProcessed) {
  4079. return genFor(el, state, genSSRElement)
  4080. } else if (el.if && !el.ifProcessed) {
  4081. return genIf(el, state, genSSRElement)
  4082. } else if (el.tag === 'template' && !el.slotTarget) {
  4083. return el.ssrOptimizability === optimizability.FULL
  4084. ? genChildrenAsStringNode(el, state)
  4085. : genSSRChildren(el, state) || 'void 0'
  4086. }
  4087. switch (el.ssrOptimizability) {
  4088. case optimizability.FULL:
  4089. // stringify whole tree
  4090. return genStringElement(el, state)
  4091. case optimizability.SELF:
  4092. // stringify self and check children
  4093. return genStringElementWithChildren(el, state)
  4094. case optimizability.CHILDREN:
  4095. // generate self as VNode and stringify children
  4096. return genNormalElement(el, state, true)
  4097. case optimizability.PARTIAL:
  4098. // generate self as VNode and check children
  4099. return genNormalElement(el, state, false)
  4100. default:
  4101. // bail whole tree
  4102. return genElement(el, state)
  4103. }
  4104. }
  4105. function genNormalElement (el, state, stringifyChildren) {
  4106. var data = el.plain ? undefined : genData$2(el, state);
  4107. var children = stringifyChildren
  4108. ? ("[" + (genChildrenAsStringNode(el, state)) + "]")
  4109. : genSSRChildren(el, state, true);
  4110. return ("_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")")
  4111. }
  4112. function genSSRChildren (el, state, checkSkip) {
  4113. return genChildren(el, state, checkSkip, genSSRElement, genSSRNode)
  4114. }
  4115. function genSSRNode (el, state) {
  4116. return el.type === 1
  4117. ? genSSRElement(el, state)
  4118. : genText(el)
  4119. }
  4120. function genChildrenAsStringNode (el, state) {
  4121. return el.children.length
  4122. ? ("_ssrNode(" + (flattenSegments(childrenToSegments(el, state))) + ")")
  4123. : ''
  4124. }
  4125. function genStringElement (el, state) {
  4126. return ("_ssrNode(" + (elementToString(el, state)) + ")")
  4127. }
  4128. function genStringElementWithChildren (el, state) {
  4129. var children = genSSRChildren(el, state, true);
  4130. return ("_ssrNode(" + (flattenSegments(elementToOpenTagSegments(el, state))) + ",\"</" + (el.tag) + ">\"" + (children ? ("," + children) : '') + ")")
  4131. }
  4132. function elementToString (el, state) {
  4133. return ("(" + (flattenSegments(elementToSegments(el, state))) + ")")
  4134. }
  4135. function elementToSegments (el, state) {
  4136. // v-for / v-if
  4137. if (el.for && !el.forProcessed) {
  4138. el.forProcessed = true;
  4139. return [{
  4140. type: EXPRESSION,
  4141. value: genFor(el, state, elementToString, '_ssrList')
  4142. }]
  4143. } else if (el.if && !el.ifProcessed) {
  4144. el.ifProcessed = true;
  4145. return [{
  4146. type: EXPRESSION,
  4147. value: genIf(el, state, elementToString, '"<!---->"')
  4148. }]
  4149. } else if (el.tag === 'template') {
  4150. return childrenToSegments(el, state)
  4151. }
  4152. var openSegments = elementToOpenTagSegments(el, state);
  4153. var childrenSegments = childrenToSegments(el, state);
  4154. var ref = state.options;
  4155. var isUnaryTag = ref.isUnaryTag;
  4156. var close = (isUnaryTag && isUnaryTag(el.tag))
  4157. ? []
  4158. : [{ type: RAW, value: ("</" + (el.tag) + ">") }];
  4159. return openSegments.concat(childrenSegments, close)
  4160. }
  4161. function elementToOpenTagSegments (el, state) {
  4162. applyModelTransform(el, state);
  4163. var binding;
  4164. var segments = [{ type: RAW, value: ("<" + (el.tag)) }];
  4165. // attrs
  4166. if (el.attrs) {
  4167. segments.push.apply(segments, genAttrSegments(el.attrs));
  4168. }
  4169. // domProps
  4170. if (el.props) {
  4171. segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
  4172. }
  4173. // v-bind="object"
  4174. if ((binding = el.attrsMap['v-bind'])) {
  4175. segments.push({ type: EXPRESSION, value: ("_ssrAttrs(" + binding + ")") });
  4176. }
  4177. // v-bind.prop="object"
  4178. if ((binding = el.attrsMap['v-bind.prop'])) {
  4179. segments.push({ type: EXPRESSION, value: ("_ssrDOMProps(" + binding + ")") });
  4180. }
  4181. // class
  4182. if (el.staticClass || el.classBinding) {
  4183. segments.push.apply(
  4184. segments,
  4185. genClassSegments(el.staticClass, el.classBinding)
  4186. );
  4187. }
  4188. // style & v-show
  4189. if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
  4190. segments.push.apply(
  4191. segments,
  4192. genStyleSegments(
  4193. el.attrsMap.style,
  4194. el.staticStyle,
  4195. el.styleBinding,
  4196. el.attrsMap['v-show']
  4197. )
  4198. );
  4199. }
  4200. // _scopedId
  4201. if (state.options.scopeId) {
  4202. segments.push({ type: RAW, value: (" " + (state.options.scopeId)) });
  4203. }
  4204. segments.push({ type: RAW, value: ">" });
  4205. return segments
  4206. }
  4207. function childrenToSegments (el, state) {
  4208. var binding;
  4209. if ((binding = el.attrsMap['v-html'])) {
  4210. return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
  4211. }
  4212. if ((binding = el.attrsMap['v-text'])) {
  4213. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  4214. }
  4215. if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
  4216. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  4217. }
  4218. return el.children
  4219. ? nodesToSegments(el.children, state)
  4220. : []
  4221. }
  4222. function nodesToSegments (
  4223. children,
  4224. state
  4225. ) {
  4226. var segments = [];
  4227. for (var i = 0; i < children.length; i++) {
  4228. var c = children[i];
  4229. if (c.type === 1) {
  4230. segments.push.apply(segments, elementToSegments(c, state));
  4231. } else if (c.type === 2) {
  4232. segments.push({ type: INTERPOLATION, value: c.expression });
  4233. } else if (c.type === 3) {
  4234. segments.push({ type: RAW, value: escape(c.text) });
  4235. }
  4236. }
  4237. return segments
  4238. }
  4239. function flattenSegments (segments) {
  4240. var mergedSegments = [];
  4241. var textBuffer = '';
  4242. var pushBuffer = function () {
  4243. if (textBuffer) {
  4244. mergedSegments.push(JSON.stringify(textBuffer));
  4245. textBuffer = '';
  4246. }
  4247. };
  4248. for (var i = 0; i < segments.length; i++) {
  4249. var s = segments[i];
  4250. if (s.type === RAW) {
  4251. textBuffer += s.value;
  4252. } else if (s.type === INTERPOLATION) {
  4253. pushBuffer();
  4254. mergedSegments.push(("_ssrEscape(" + (s.value) + ")"));
  4255. } else if (s.type === EXPRESSION) {
  4256. pushBuffer();
  4257. mergedSegments.push(("(" + (s.value) + ")"));
  4258. }
  4259. }
  4260. pushBuffer();
  4261. return mergedSegments.join('+')
  4262. }
  4263. /* */
  4264. var createCompiler$1 = createCompilerCreator(function baseCompile (
  4265. template,
  4266. options
  4267. ) {
  4268. var ast = parse(template.trim(), options);
  4269. optimize$1(ast, options);
  4270. var code = generate$1(ast, options);
  4271. return {
  4272. ast: ast,
  4273. render: code.render,
  4274. staticRenderFns: code.staticRenderFns
  4275. }
  4276. });
  4277. /* */
  4278. var ref$1 = createCompiler$1(baseOptions);
  4279. var compile$1 = ref$1.compile;
  4280. var compileToFunctions$1 = ref$1.compileToFunctions;
  4281. /* */
  4282. exports.parseComponent = parseComponent;
  4283. exports.compile = compile;
  4284. exports.compileToFunctions = compileToFunctions;
  4285. exports.ssrCompile = compile$1;
  4286. exports.ssrCompileToFunctions = compileToFunctions$1;