build.js 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712
  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 he = _interopDefault(require('he'));
  5. /* */
  6. // these helpers produces better vm code in JS engines due to their
  7. // explicitness and function inlining
  8. /**
  9. * Check if value is primitive
  10. */
  11. /**
  12. * Quick object check - this is primarily used to tell
  13. * Objects from primitive values when we know the value
  14. * is a JSON-compliant type.
  15. */
  16. function isObject (obj) {
  17. return obj !== null && typeof obj === 'object'
  18. }
  19. var _toString = Object.prototype.toString;
  20. /**
  21. * Strict object type check. Only returns true
  22. * for plain JavaScript objects.
  23. */
  24. function isPlainObject (obj) {
  25. return _toString.call(obj) === '[object Object]'
  26. }
  27. /**
  28. * Check if val is a valid array index.
  29. */
  30. function isValidArrayIndex (val) {
  31. var n = parseFloat(val);
  32. return n >= 0 && Math.floor(n) === n && isFinite(val)
  33. }
  34. /**
  35. * Convert a value to a string that is actually rendered.
  36. */
  37. /**
  38. * Convert a input value to a number for persistence.
  39. * If the conversion fails, return original string.
  40. */
  41. /**
  42. * Make a map and return a function for checking if a key
  43. * is in that map.
  44. */
  45. function makeMap (
  46. str,
  47. expectsLowerCase
  48. ) {
  49. var map = Object.create(null);
  50. var list = str.split(',');
  51. for (var i = 0; i < list.length; i++) {
  52. map[list[i]] = true;
  53. }
  54. return expectsLowerCase
  55. ? function (val) { return map[val.toLowerCase()]; }
  56. : function (val) { return map[val]; }
  57. }
  58. /**
  59. * Check if a tag is a built-in tag.
  60. */
  61. var isBuiltInTag = makeMap('slot,component', true);
  62. /**
  63. * Check if a attribute is a reserved attribute.
  64. */
  65. var isReservedAttribute = makeMap('key,ref,slot,is');
  66. /**
  67. * Remove an item from an array
  68. */
  69. function remove (arr, item) {
  70. if (arr.length) {
  71. var index = arr.indexOf(item);
  72. if (index > -1) {
  73. return arr.splice(index, 1)
  74. }
  75. }
  76. }
  77. /**
  78. * Check whether the object has the property.
  79. */
  80. var hasOwnProperty = Object.prototype.hasOwnProperty;
  81. function hasOwn (obj, key) {
  82. return hasOwnProperty.call(obj, key)
  83. }
  84. /**
  85. * Create a cached version of a pure function.
  86. */
  87. function cached (fn) {
  88. var cache = Object.create(null);
  89. return (function cachedFn (str) {
  90. var hit = cache[str];
  91. return hit || (cache[str] = fn(str))
  92. })
  93. }
  94. /**
  95. * Camelize a hyphen-delimited string.
  96. */
  97. var camelizeRE = /-(\w)/g;
  98. var camelize = cached(function (str) {
  99. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  100. });
  101. /**
  102. * Capitalize a string.
  103. */
  104. /**
  105. * Simple bind, faster than native
  106. */
  107. /**
  108. * Convert an Array-like object to a real Array.
  109. */
  110. /**
  111. * Mix properties into target object.
  112. */
  113. function extend (to, _from) {
  114. for (var key in _from) {
  115. to[key] = _from[key];
  116. }
  117. return to
  118. }
  119. /**
  120. * Merge an Array of Objects into a single Object.
  121. */
  122. /**
  123. * Perform no operation.
  124. * Stubbing args to make Flow happy without leaving useless transpiled code
  125. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
  126. */
  127. function noop (a, b, c) {}
  128. /**
  129. * Always return false.
  130. */
  131. var no = function (a, b, c) { return false; };
  132. /**
  133. * Return same value
  134. */
  135. var identity = function (_) { return _; };
  136. /**
  137. * Generate a static keys string from compiler modules.
  138. */
  139. function genStaticKeys (modules) {
  140. return modules.reduce(function (keys, m) {
  141. return keys.concat(m.staticKeys || [])
  142. }, []).join(',')
  143. }
  144. /**
  145. * Check if two values are loosely equal - that is,
  146. * if they are plain objects, do they have the same shape?
  147. */
  148. /**
  149. * Ensure a function is called only once.
  150. */
  151. /* */
  152. var isUnaryTag = makeMap(
  153. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  154. 'link,meta,param,source,track,wbr'
  155. );
  156. // Elements that you can, intentionally, leave open
  157. // (and which close themselves)
  158. var canBeLeftOpenTag = makeMap(
  159. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  160. );
  161. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  162. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  163. var isNonPhrasingTag = makeMap(
  164. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  165. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  166. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  167. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  168. 'title,tr,track'
  169. );
  170. /**
  171. * Not type-checking this file because it's mostly vendor code.
  172. */
  173. /*!
  174. * HTML Parser By John Resig (ejohn.org)
  175. * Modified by Juriy "kangax" Zaytsev
  176. * Original code by Erik Arvidsson, Mozilla Public License
  177. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  178. */
  179. // Regular Expressions for parsing tags and attributes
  180. var singleAttrIdentifier = /([^\s"'<>/=]+)/;
  181. var singleAttrAssign = /(?:=)/;
  182. var singleAttrValues = [
  183. // attr value double quotes
  184. /"([^"]*)"+/.source,
  185. // attr value, single quotes
  186. /'([^']*)'+/.source,
  187. // attr value, no quotes
  188. /([^\s"'=<>`]+)/.source
  189. ];
  190. var attribute = new RegExp(
  191. '^\\s*' + singleAttrIdentifier.source +
  192. '(?:\\s*(' + singleAttrAssign.source + ')' +
  193. '\\s*(?:' + singleAttrValues.join('|') + '))?'
  194. );
  195. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  196. // but for Vue templates we can enforce a simple charset
  197. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  198. var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
  199. var startTagOpen = new RegExp('^<' + qnameCapture);
  200. var startTagClose = /^\s*(\/?)>/;
  201. var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
  202. var doctype = /^<!DOCTYPE [^>]+>/i;
  203. var comment = /^<!--/;
  204. var conditionalComment = /^<!\[/;
  205. var IS_REGEX_CAPTURING_BROKEN = false;
  206. 'x'.replace(/x(.)?/g, function (m, g) {
  207. IS_REGEX_CAPTURING_BROKEN = g === '';
  208. });
  209. // Special Elements (can contain anything)
  210. var isPlainTextElement = makeMap('script,style,textarea', true);
  211. var reCache = {};
  212. var decodingMap = {
  213. '&lt;': '<',
  214. '&gt;': '>',
  215. '&quot;': '"',
  216. '&amp;': '&',
  217. '&#10;': '\n'
  218. };
  219. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  220. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
  221. // #5992
  222. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  223. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  224. function decodeAttr (value, shouldDecodeNewlines) {
  225. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  226. return value.replace(re, function (match) { return decodingMap[match]; })
  227. }
  228. function parseHTML (html, options) {
  229. var stack = [];
  230. var expectHTML = options.expectHTML;
  231. var isUnaryTag$$1 = options.isUnaryTag || no;
  232. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  233. var index = 0;
  234. var last, lastTag;
  235. while (html) {
  236. last = html;
  237. // Make sure we're not in a plaintext content element like script/style
  238. if (!lastTag || !isPlainTextElement(lastTag)) {
  239. var textEnd = html.indexOf('<');
  240. if (textEnd === 0) {
  241. // Comment:
  242. if (comment.test(html)) {
  243. var commentEnd = html.indexOf('-->');
  244. if (commentEnd >= 0) {
  245. if (options.shouldKeepComment) {
  246. options.comment(html.substring(4, commentEnd));
  247. }
  248. advance(commentEnd + 3);
  249. continue
  250. }
  251. }
  252. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  253. if (conditionalComment.test(html)) {
  254. var conditionalEnd = html.indexOf(']>');
  255. if (conditionalEnd >= 0) {
  256. advance(conditionalEnd + 2);
  257. continue
  258. }
  259. }
  260. // Doctype:
  261. var doctypeMatch = html.match(doctype);
  262. if (doctypeMatch) {
  263. advance(doctypeMatch[0].length);
  264. continue
  265. }
  266. // End tag:
  267. var endTagMatch = html.match(endTag);
  268. if (endTagMatch) {
  269. var curIndex = index;
  270. advance(endTagMatch[0].length);
  271. parseEndTag(endTagMatch[1], curIndex, index);
  272. continue
  273. }
  274. // Start tag:
  275. var startTagMatch = parseStartTag();
  276. if (startTagMatch) {
  277. handleStartTag(startTagMatch);
  278. if (shouldIgnoreFirstNewline(lastTag, html)) {
  279. advance(1);
  280. }
  281. continue
  282. }
  283. }
  284. var text = (void 0), rest = (void 0), next = (void 0);
  285. if (textEnd >= 0) {
  286. rest = html.slice(textEnd);
  287. while (
  288. !endTag.test(rest) &&
  289. !startTagOpen.test(rest) &&
  290. !comment.test(rest) &&
  291. !conditionalComment.test(rest)
  292. ) {
  293. // < in plain text, be forgiving and treat it as text
  294. next = rest.indexOf('<', 1);
  295. if (next < 0) { break }
  296. textEnd += next;
  297. rest = html.slice(textEnd);
  298. }
  299. text = html.substring(0, textEnd);
  300. advance(textEnd);
  301. }
  302. if (textEnd < 0) {
  303. text = html;
  304. html = '';
  305. }
  306. if (options.chars && text) {
  307. options.chars(text);
  308. }
  309. } else {
  310. var endTagLength = 0;
  311. var stackedTag = lastTag.toLowerCase();
  312. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  313. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  314. endTagLength = endTag.length;
  315. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  316. text = text
  317. .replace(/<!--([\s\S]*?)-->/g, '$1')
  318. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  319. }
  320. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  321. text = text.slice(1);
  322. }
  323. if (options.chars) {
  324. options.chars(text);
  325. }
  326. return ''
  327. });
  328. index += html.length - rest$1.length;
  329. html = rest$1;
  330. parseEndTag(stackedTag, index - endTagLength, index);
  331. }
  332. if (html === last) {
  333. options.chars && options.chars(html);
  334. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  335. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  336. }
  337. break
  338. }
  339. }
  340. // Clean up any remaining tags
  341. parseEndTag();
  342. function advance (n) {
  343. index += n;
  344. html = html.substring(n);
  345. }
  346. function parseStartTag () {
  347. var start = html.match(startTagOpen);
  348. if (start) {
  349. var match = {
  350. tagName: start[1],
  351. attrs: [],
  352. start: index
  353. };
  354. advance(start[0].length);
  355. var end, attr;
  356. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  357. advance(attr[0].length);
  358. match.attrs.push(attr);
  359. }
  360. if (end) {
  361. match.unarySlash = end[1];
  362. advance(end[0].length);
  363. match.end = index;
  364. return match
  365. }
  366. }
  367. }
  368. function handleStartTag (match) {
  369. var tagName = match.tagName;
  370. var unarySlash = match.unarySlash;
  371. if (expectHTML) {
  372. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  373. parseEndTag(lastTag);
  374. }
  375. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  376. parseEndTag(tagName);
  377. }
  378. }
  379. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  380. var l = match.attrs.length;
  381. var attrs = new Array(l);
  382. for (var i = 0; i < l; i++) {
  383. var args = match.attrs[i];
  384. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  385. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  386. if (args[3] === '') { delete args[3]; }
  387. if (args[4] === '') { delete args[4]; }
  388. if (args[5] === '') { delete args[5]; }
  389. }
  390. var value = args[3] || args[4] || args[5] || '';
  391. attrs[i] = {
  392. name: args[1],
  393. value: decodeAttr(
  394. value,
  395. options.shouldDecodeNewlines
  396. )
  397. };
  398. }
  399. if (!unary) {
  400. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  401. lastTag = tagName;
  402. }
  403. if (options.start) {
  404. options.start(tagName, attrs, unary, match.start, match.end);
  405. }
  406. }
  407. function parseEndTag (tagName, start, end) {
  408. var pos, lowerCasedTagName;
  409. if (start == null) { start = index; }
  410. if (end == null) { end = index; }
  411. if (tagName) {
  412. lowerCasedTagName = tagName.toLowerCase();
  413. }
  414. // Find the closest opened tag of the same type
  415. if (tagName) {
  416. for (pos = stack.length - 1; pos >= 0; pos--) {
  417. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  418. break
  419. }
  420. }
  421. } else {
  422. // If no tag name is provided, clean shop
  423. pos = 0;
  424. }
  425. if (pos >= 0) {
  426. // Close all the open elements, up the stack
  427. for (var i = stack.length - 1; i >= pos; i--) {
  428. if (process.env.NODE_ENV !== 'production' &&
  429. (i > pos || !tagName) &&
  430. options.warn
  431. ) {
  432. options.warn(
  433. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  434. );
  435. }
  436. if (options.end) {
  437. options.end(stack[i].tag, start, end);
  438. }
  439. }
  440. // Remove the open elements from the stack
  441. stack.length = pos;
  442. lastTag = pos && stack[pos - 1].tag;
  443. } else if (lowerCasedTagName === 'br') {
  444. if (options.start) {
  445. options.start(tagName, [], true, start, end);
  446. }
  447. } else if (lowerCasedTagName === 'p') {
  448. if (options.start) {
  449. options.start(tagName, [], false, start, end);
  450. }
  451. if (options.end) {
  452. options.end(tagName, start, end);
  453. }
  454. }
  455. }
  456. }
  457. /* */
  458. var validDivisionCharRE = /[\w).+\-_$\]]/;
  459. function parseFilters (exp) {
  460. var inSingle = false;
  461. var inDouble = false;
  462. var inTemplateString = false;
  463. var inRegex = false;
  464. var curly = 0;
  465. var square = 0;
  466. var paren = 0;
  467. var lastFilterIndex = 0;
  468. var c, prev, i, expression, filters;
  469. for (i = 0; i < exp.length; i++) {
  470. prev = c;
  471. c = exp.charCodeAt(i);
  472. if (inSingle) {
  473. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  474. } else if (inDouble) {
  475. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  476. } else if (inTemplateString) {
  477. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  478. } else if (inRegex) {
  479. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  480. } else if (
  481. c === 0x7C && // pipe
  482. exp.charCodeAt(i + 1) !== 0x7C &&
  483. exp.charCodeAt(i - 1) !== 0x7C &&
  484. !curly && !square && !paren
  485. ) {
  486. if (expression === undefined) {
  487. // first filter, end of expression
  488. lastFilterIndex = i + 1;
  489. expression = exp.slice(0, i).trim();
  490. } else {
  491. pushFilter();
  492. }
  493. } else {
  494. switch (c) {
  495. case 0x22: inDouble = true; break // "
  496. case 0x27: inSingle = true; break // '
  497. case 0x60: inTemplateString = true; break // `
  498. case 0x28: paren++; break // (
  499. case 0x29: paren--; break // )
  500. case 0x5B: square++; break // [
  501. case 0x5D: square--; break // ]
  502. case 0x7B: curly++; break // {
  503. case 0x7D: curly--; break // }
  504. }
  505. if (c === 0x2f) { // /
  506. var j = i - 1;
  507. var p = (void 0);
  508. // find first non-whitespace prev char
  509. for (; j >= 0; j--) {
  510. p = exp.charAt(j);
  511. if (p !== ' ') { break }
  512. }
  513. if (!p || !validDivisionCharRE.test(p)) {
  514. inRegex = true;
  515. }
  516. }
  517. }
  518. }
  519. if (expression === undefined) {
  520. expression = exp.slice(0, i).trim();
  521. } else if (lastFilterIndex !== 0) {
  522. pushFilter();
  523. }
  524. function pushFilter () {
  525. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  526. lastFilterIndex = i + 1;
  527. }
  528. if (filters) {
  529. for (i = 0; i < filters.length; i++) {
  530. expression = wrapFilter(expression, filters[i]);
  531. }
  532. }
  533. return expression
  534. }
  535. function wrapFilter (exp, filter) {
  536. var i = filter.indexOf('(');
  537. if (i < 0) {
  538. // _f: resolveFilter
  539. return ("_f(\"" + filter + "\")(" + exp + ")")
  540. } else {
  541. var name = filter.slice(0, i);
  542. var args = filter.slice(i + 1);
  543. return ("_f(\"" + name + "\")(" + exp + "," + args)
  544. }
  545. }
  546. /* */
  547. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  548. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  549. var buildRegex = cached(function (delimiters) {
  550. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  551. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  552. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  553. });
  554. function parseText (
  555. text,
  556. delimiters
  557. ) {
  558. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  559. if (!tagRE.test(text)) {
  560. return
  561. }
  562. var tokens = [];
  563. var lastIndex = tagRE.lastIndex = 0;
  564. var match, index;
  565. while ((match = tagRE.exec(text))) {
  566. index = match.index;
  567. // push text token
  568. if (index > lastIndex) {
  569. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  570. }
  571. // tag token
  572. var exp = parseFilters(match[1].trim());
  573. tokens.push(("_s(" + exp + ")"));
  574. lastIndex = index + match[0].length;
  575. }
  576. if (lastIndex < text.length) {
  577. tokens.push(JSON.stringify(text.slice(lastIndex)));
  578. }
  579. return tokens.join('+')
  580. }
  581. /* */
  582. /**
  583. * Cross-platform code generation for component v-model
  584. */
  585. function genComponentModel (
  586. el,
  587. value,
  588. modifiers
  589. ) {
  590. var ref = modifiers || {};
  591. var number = ref.number;
  592. var trim = ref.trim;
  593. var baseValueExpression = '$$v';
  594. var valueExpression = baseValueExpression;
  595. if (trim) {
  596. valueExpression =
  597. "(typeof " + baseValueExpression + " === 'string'" +
  598. "? " + baseValueExpression + ".trim()" +
  599. ": " + baseValueExpression + ")";
  600. }
  601. if (number) {
  602. valueExpression = "_n(" + valueExpression + ")";
  603. }
  604. var assignment = genAssignmentCode(value, valueExpression);
  605. el.model = {
  606. value: ("(" + value + ")"),
  607. expression: ("\"" + value + "\""),
  608. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  609. };
  610. }
  611. /**
  612. * Cross-platform codegen helper for generating v-model value assignment code.
  613. */
  614. function genAssignmentCode (
  615. value,
  616. assignment
  617. ) {
  618. var modelRs = parseModel(value);
  619. if (modelRs.idx === null) {
  620. return (value + "=" + assignment)
  621. } else {
  622. return ("$set(" + (modelRs.exp) + ", " + (modelRs.idx) + ", " + assignment + ")")
  623. }
  624. }
  625. /**
  626. * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
  627. *
  628. * for loop possible cases:
  629. *
  630. * - test
  631. * - test[idx]
  632. * - test[test1[idx]]
  633. * - test["a"][idx]
  634. * - xxx.test[a[a].test1[idx]]
  635. * - test.xxx.a["asa"][test1[idx]]
  636. *
  637. */
  638. var len;
  639. var str;
  640. var chr;
  641. var index;
  642. var expressionPos;
  643. var expressionEndPos;
  644. function parseModel (val) {
  645. str = val;
  646. len = str.length;
  647. index = expressionPos = expressionEndPos = 0;
  648. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  649. return {
  650. exp: val,
  651. idx: null
  652. }
  653. }
  654. while (!eof()) {
  655. chr = next();
  656. /* istanbul ignore if */
  657. if (isStringStart(chr)) {
  658. parseString(chr);
  659. } else if (chr === 0x5B) {
  660. parseBracket(chr);
  661. }
  662. }
  663. return {
  664. exp: val.substring(0, expressionPos),
  665. idx: val.substring(expressionPos + 1, expressionEndPos)
  666. }
  667. }
  668. function next () {
  669. return str.charCodeAt(++index)
  670. }
  671. function eof () {
  672. return index >= len
  673. }
  674. function isStringStart (chr) {
  675. return chr === 0x22 || chr === 0x27
  676. }
  677. function parseBracket (chr) {
  678. var inBracket = 1;
  679. expressionPos = index;
  680. while (!eof()) {
  681. chr = next();
  682. if (isStringStart(chr)) {
  683. parseString(chr);
  684. continue
  685. }
  686. if (chr === 0x5B) { inBracket++; }
  687. if (chr === 0x5D) { inBracket--; }
  688. if (inBracket === 0) {
  689. expressionEndPos = index;
  690. break
  691. }
  692. }
  693. }
  694. function parseString (chr) {
  695. var stringQuote = chr;
  696. while (!eof()) {
  697. chr = next();
  698. if (chr === stringQuote) {
  699. break
  700. }
  701. }
  702. }
  703. var ASSET_TYPES = [
  704. 'component',
  705. 'directive',
  706. 'filter'
  707. ];
  708. var LIFECYCLE_HOOKS = [
  709. 'beforeCreate',
  710. 'created',
  711. 'beforeMount',
  712. 'mounted',
  713. 'beforeUpdate',
  714. 'updated',
  715. 'beforeDestroy',
  716. 'destroyed',
  717. 'activated',
  718. 'deactivated'
  719. ];
  720. /* */
  721. var config = ({
  722. /**
  723. * Option merge strategies (used in core/util/options)
  724. */
  725. optionMergeStrategies: Object.create(null),
  726. /**
  727. * Whether to suppress warnings.
  728. */
  729. silent: false,
  730. /**
  731. * Show production mode tip message on boot?
  732. */
  733. productionTip: process.env.NODE_ENV !== 'production',
  734. /**
  735. * Whether to enable devtools
  736. */
  737. devtools: process.env.NODE_ENV !== 'production',
  738. /**
  739. * Whether to record perf
  740. */
  741. performance: false,
  742. /**
  743. * Error handler for watcher errors
  744. */
  745. errorHandler: null,
  746. /**
  747. * Warn handler for watcher warns
  748. */
  749. warnHandler: null,
  750. /**
  751. * Ignore certain custom elements
  752. */
  753. ignoredElements: [],
  754. /**
  755. * Custom user key aliases for v-on
  756. */
  757. keyCodes: Object.create(null),
  758. /**
  759. * Check if a tag is reserved so that it cannot be registered as a
  760. * component. This is platform-dependent and may be overwritten.
  761. */
  762. isReservedTag: no,
  763. /**
  764. * Check if an attribute is reserved so that it cannot be used as a component
  765. * prop. This is platform-dependent and may be overwritten.
  766. */
  767. isReservedAttr: no,
  768. /**
  769. * Check if a tag is an unknown element.
  770. * Platform-dependent.
  771. */
  772. isUnknownElement: no,
  773. /**
  774. * Get the namespace of an element
  775. */
  776. getTagNamespace: noop,
  777. /**
  778. * Parse the real tag name for the specific platform.
  779. */
  780. parsePlatformTagName: identity,
  781. /**
  782. * Check if an attribute must be bound using property, e.g. value
  783. * Platform-dependent.
  784. */
  785. mustUseProp: no,
  786. /**
  787. * Exposed for legacy reasons
  788. */
  789. _lifecycleHooks: LIFECYCLE_HOOKS
  790. });
  791. /* */
  792. var warn$1 = noop;
  793. var tip = noop;
  794. var formatComponentName = (null); // work around flow check
  795. if (process.env.NODE_ENV !== 'production') {
  796. var hasConsole = typeof console !== 'undefined';
  797. var classifyRE = /(?:^|[-_])(\w)/g;
  798. var classify = function (str) { return str
  799. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  800. .replace(/[-_]/g, ''); };
  801. warn$1 = function (msg, vm) {
  802. var trace = vm ? generateComponentTrace(vm) : '';
  803. if (config.warnHandler) {
  804. config.warnHandler.call(null, msg, vm, trace);
  805. } else if (hasConsole && (!config.silent)) {
  806. console.error(("[Vue warn]: " + msg + trace));
  807. }
  808. };
  809. tip = function (msg, vm) {
  810. if (hasConsole && (!config.silent)) {
  811. console.warn("[Vue tip]: " + msg + (
  812. vm ? generateComponentTrace(vm) : ''
  813. ));
  814. }
  815. };
  816. formatComponentName = function (vm, includeFile) {
  817. if (vm.$root === vm) {
  818. return '<Root>'
  819. }
  820. var name = typeof vm === 'string'
  821. ? vm
  822. : typeof vm === 'function' && vm.options
  823. ? vm.options.name
  824. : vm._isVue
  825. ? vm.$options.name || vm.$options._componentTag
  826. : vm.name;
  827. var file = vm._isVue && vm.$options.__file;
  828. if (!name && file) {
  829. var match = file.match(/([^/\\]+)\.vue$/);
  830. name = match && match[1];
  831. }
  832. return (
  833. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  834. (file && includeFile !== false ? (" at " + file) : '')
  835. )
  836. };
  837. var repeat = function (str, n) {
  838. var res = '';
  839. while (n) {
  840. if (n % 2 === 1) { res += str; }
  841. if (n > 1) { str += str; }
  842. n >>= 1;
  843. }
  844. return res
  845. };
  846. var generateComponentTrace = function (vm) {
  847. if (vm._isVue && vm.$parent) {
  848. var tree = [];
  849. var currentRecursiveSequence = 0;
  850. while (vm) {
  851. if (tree.length > 0) {
  852. var last = tree[tree.length - 1];
  853. if (last.constructor === vm.constructor) {
  854. currentRecursiveSequence++;
  855. vm = vm.$parent;
  856. continue
  857. } else if (currentRecursiveSequence > 0) {
  858. tree[tree.length - 1] = [last, currentRecursiveSequence];
  859. currentRecursiveSequence = 0;
  860. }
  861. }
  862. tree.push(vm);
  863. vm = vm.$parent;
  864. }
  865. return '\n\nfound in\n\n' + tree
  866. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  867. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  868. : formatComponentName(vm))); })
  869. .join('\n')
  870. } else {
  871. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  872. }
  873. };
  874. }
  875. /* */
  876. function handleError (err, vm, info) {
  877. if (config.errorHandler) {
  878. config.errorHandler.call(null, err, vm, info);
  879. } else {
  880. if (process.env.NODE_ENV !== 'production') {
  881. warn$1(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  882. }
  883. /* istanbul ignore else */
  884. if (inBrowser && typeof console !== 'undefined') {
  885. console.error(err);
  886. } else {
  887. throw err
  888. }
  889. }
  890. }
  891. /* */
  892. /* globals MutationObserver */
  893. // can we use __proto__?
  894. var hasProto = '__proto__' in {};
  895. // Browser environment sniffing
  896. var inBrowser = typeof window !== 'undefined';
  897. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  898. var isIE = UA && /msie|trident/.test(UA);
  899. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  900. var isEdge = UA && UA.indexOf('edge/') > 0;
  901. var isAndroid = UA && UA.indexOf('android') > 0;
  902. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  903. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  904. // Firefix has a "watch" function on Object.prototype...
  905. var nativeWatch = ({}).watch;
  906. var supportsPassive = false;
  907. if (inBrowser) {
  908. try {
  909. var opts = {};
  910. Object.defineProperty(opts, 'passive', ({
  911. get: function get () {
  912. /* istanbul ignore next */
  913. supportsPassive = true;
  914. }
  915. })); // https://github.com/facebook/flow/issues/285
  916. window.addEventListener('test-passive', null, opts);
  917. } catch (e) {}
  918. }
  919. // this needs to be lazy-evaled because vue may be required before
  920. // vue-server-renderer can set VUE_ENV
  921. var _isServer;
  922. var isServerRendering = function () {
  923. if (_isServer === undefined) {
  924. /* istanbul ignore if */
  925. if (!inBrowser && typeof global !== 'undefined') {
  926. // detect presence of vue-server-renderer and avoid
  927. // Webpack shimming the process
  928. _isServer = global['process'].env.VUE_ENV === 'server';
  929. } else {
  930. _isServer = false;
  931. }
  932. }
  933. return _isServer
  934. };
  935. // detect devtools
  936. /* istanbul ignore next */
  937. function isNative (Ctor) {
  938. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  939. }
  940. var hasSymbol =
  941. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  942. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  943. /**
  944. * Defer a task to execute it asynchronously.
  945. */
  946. var nextTick = (function () {
  947. var callbacks = [];
  948. var pending = false;
  949. var timerFunc;
  950. function nextTickHandler () {
  951. pending = false;
  952. var copies = callbacks.slice(0);
  953. callbacks.length = 0;
  954. for (var i = 0; i < copies.length; i++) {
  955. copies[i]();
  956. }
  957. }
  958. // the nextTick behavior leverages the microtask queue, which can be accessed
  959. // via either native Promise.then or MutationObserver.
  960. // MutationObserver has wider support, however it is seriously bugged in
  961. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  962. // completely stops working after triggering a few times... so, if native
  963. // Promise is available, we will use it:
  964. /* istanbul ignore if */
  965. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  966. var p = Promise.resolve();
  967. var logError = function (err) { console.error(err); };
  968. timerFunc = function () {
  969. p.then(nextTickHandler).catch(logError);
  970. // in problematic UIWebViews, Promise.then doesn't completely break, but
  971. // it can get stuck in a weird state where callbacks are pushed into the
  972. // microtask queue but the queue isn't being flushed, until the browser
  973. // needs to do some other work, e.g. handle a timer. Therefore we can
  974. // "force" the microtask queue to be flushed by adding an empty timer.
  975. if (isIOS) { setTimeout(noop); }
  976. };
  977. } else if (typeof MutationObserver !== 'undefined' && (
  978. isNative(MutationObserver) ||
  979. // PhantomJS and iOS 7.x
  980. MutationObserver.toString() === '[object MutationObserverConstructor]'
  981. )) {
  982. // use MutationObserver where native Promise is not available,
  983. // e.g. PhantomJS IE11, iOS7, Android 4.4
  984. var counter = 1;
  985. var observer = new MutationObserver(nextTickHandler);
  986. var textNode = document.createTextNode(String(counter));
  987. observer.observe(textNode, {
  988. characterData: true
  989. });
  990. timerFunc = function () {
  991. counter = (counter + 1) % 2;
  992. textNode.data = String(counter);
  993. };
  994. } else {
  995. // fallback to setTimeout
  996. /* istanbul ignore next */
  997. timerFunc = function () {
  998. setTimeout(nextTickHandler, 0);
  999. };
  1000. }
  1001. return function queueNextTick (cb, ctx) {
  1002. var _resolve;
  1003. callbacks.push(function () {
  1004. if (cb) {
  1005. try {
  1006. cb.call(ctx);
  1007. } catch (e) {
  1008. handleError(e, ctx, 'nextTick');
  1009. }
  1010. } else if (_resolve) {
  1011. _resolve(ctx);
  1012. }
  1013. });
  1014. if (!pending) {
  1015. pending = true;
  1016. timerFunc();
  1017. }
  1018. if (!cb && typeof Promise !== 'undefined') {
  1019. return new Promise(function (resolve, reject) {
  1020. _resolve = resolve;
  1021. })
  1022. }
  1023. }
  1024. })();
  1025. var _Set;
  1026. /* istanbul ignore if */
  1027. if (typeof Set !== 'undefined' && isNative(Set)) {
  1028. // use native Set when available.
  1029. _Set = Set;
  1030. } else {
  1031. // a non-standard Set polyfill that only works with primitive keys.
  1032. _Set = (function () {
  1033. function Set () {
  1034. this.set = Object.create(null);
  1035. }
  1036. Set.prototype.has = function has (key) {
  1037. return this.set[key] === true
  1038. };
  1039. Set.prototype.add = function add (key) {
  1040. this.set[key] = true;
  1041. };
  1042. Set.prototype.clear = function clear () {
  1043. this.set = Object.create(null);
  1044. };
  1045. return Set;
  1046. }());
  1047. }
  1048. /* */
  1049. function baseWarn (msg) {
  1050. console.error(("[Vue compiler]: " + msg));
  1051. }
  1052. function pluckModuleFunction (
  1053. modules,
  1054. key
  1055. ) {
  1056. return modules
  1057. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  1058. : []
  1059. }
  1060. function addProp (el, name, value) {
  1061. (el.props || (el.props = [])).push({ name: name, value: value });
  1062. }
  1063. function addAttr (el, name, value) {
  1064. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  1065. }
  1066. function addDirective (
  1067. el,
  1068. name,
  1069. rawName,
  1070. value,
  1071. arg,
  1072. modifiers
  1073. ) {
  1074. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  1075. }
  1076. function addHandler (
  1077. el,
  1078. name,
  1079. value,
  1080. modifiers,
  1081. important,
  1082. warn
  1083. ) {
  1084. // warn prevent and passive modifier
  1085. /* istanbul ignore if */
  1086. if (
  1087. process.env.NODE_ENV !== 'production' && warn &&
  1088. modifiers && modifiers.prevent && modifiers.passive
  1089. ) {
  1090. warn(
  1091. 'passive and prevent can\'t be used together. ' +
  1092. 'Passive handler can\'t prevent default event.'
  1093. );
  1094. }
  1095. // check capture modifier
  1096. if (modifiers && modifiers.capture) {
  1097. delete modifiers.capture;
  1098. name = '!' + name; // mark the event as captured
  1099. }
  1100. if (modifiers && modifiers.once) {
  1101. delete modifiers.once;
  1102. name = '~' + name; // mark the event as once
  1103. }
  1104. /* istanbul ignore if */
  1105. if (modifiers && modifiers.passive) {
  1106. delete modifiers.passive;
  1107. name = '&' + name; // mark the event as passive
  1108. }
  1109. var events;
  1110. if (modifiers && modifiers.native) {
  1111. delete modifiers.native;
  1112. events = el.nativeEvents || (el.nativeEvents = {});
  1113. } else {
  1114. events = el.events || (el.events = {});
  1115. }
  1116. var newHandler = { value: value, modifiers: modifiers };
  1117. var handlers = events[name];
  1118. /* istanbul ignore if */
  1119. if (Array.isArray(handlers)) {
  1120. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  1121. } else if (handlers) {
  1122. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  1123. } else {
  1124. events[name] = newHandler;
  1125. }
  1126. }
  1127. function getBindingAttr (
  1128. el,
  1129. name,
  1130. getStatic
  1131. ) {
  1132. var dynamicValue =
  1133. getAndRemoveAttr(el, ':' + name) ||
  1134. getAndRemoveAttr(el, 'v-bind:' + name);
  1135. if (dynamicValue != null) {
  1136. return parseFilters(dynamicValue)
  1137. } else if (getStatic !== false) {
  1138. var staticValue = getAndRemoveAttr(el, name);
  1139. if (staticValue != null) {
  1140. return JSON.stringify(staticValue)
  1141. }
  1142. }
  1143. }
  1144. function getAndRemoveAttr (el, name) {
  1145. var val;
  1146. if ((val = el.attrsMap[name]) != null) {
  1147. var list = el.attrsList;
  1148. for (var i = 0, l = list.length; i < l; i++) {
  1149. if (list[i].name === name) {
  1150. list.splice(i, 1);
  1151. break
  1152. }
  1153. }
  1154. }
  1155. return val
  1156. }
  1157. /* */
  1158. var onRE = /^@|^v-on:/;
  1159. var dirRE = /^v-|^@|^:/;
  1160. var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
  1161. var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
  1162. var argRE = /:(.*)$/;
  1163. var bindRE = /^:|^v-bind:/;
  1164. var modifierRE = /\.[^.]+/g;
  1165. var decodeHTMLCached = cached(he.decode);
  1166. // configurable state
  1167. var warn;
  1168. var delimiters;
  1169. var transforms;
  1170. var preTransforms;
  1171. var postTransforms;
  1172. var platformIsPreTag;
  1173. var platformMustUseProp;
  1174. var platformGetTagNamespace;
  1175. /**
  1176. * Convert HTML string to AST.
  1177. */
  1178. function parse (
  1179. template,
  1180. options
  1181. ) {
  1182. warn = options.warn || baseWarn;
  1183. platformIsPreTag = options.isPreTag || no;
  1184. platformMustUseProp = options.mustUseProp || no;
  1185. platformGetTagNamespace = options.getTagNamespace || no;
  1186. transforms = pluckModuleFunction(options.modules, 'transformNode');
  1187. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  1188. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  1189. delimiters = options.delimiters;
  1190. var stack = [];
  1191. var preserveWhitespace = options.preserveWhitespace !== false;
  1192. var root;
  1193. var currentParent;
  1194. var inVPre = false;
  1195. var inPre = false;
  1196. var warned = false;
  1197. function warnOnce (msg) {
  1198. if (!warned) {
  1199. warned = true;
  1200. warn(msg);
  1201. }
  1202. }
  1203. function endPre (element) {
  1204. // check pre state
  1205. if (element.pre) {
  1206. inVPre = false;
  1207. }
  1208. if (platformIsPreTag(element.tag)) {
  1209. inPre = false;
  1210. }
  1211. }
  1212. parseHTML(template, {
  1213. warn: warn,
  1214. expectHTML: options.expectHTML,
  1215. isUnaryTag: options.isUnaryTag,
  1216. canBeLeftOpenTag: options.canBeLeftOpenTag,
  1217. shouldDecodeNewlines: options.shouldDecodeNewlines,
  1218. shouldKeepComment: options.comments,
  1219. start: function start (tag, attrs, unary) {
  1220. // check namespace.
  1221. // inherit parent ns if there is one
  1222. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  1223. // handle IE svg bug
  1224. /* istanbul ignore if */
  1225. if (isIE && ns === 'svg') {
  1226. attrs = guardIESVGBug(attrs);
  1227. }
  1228. var element = {
  1229. type: 1,
  1230. tag: tag,
  1231. attrsList: attrs,
  1232. attrsMap: makeAttrsMap(attrs),
  1233. parent: currentParent,
  1234. children: []
  1235. };
  1236. if (ns) {
  1237. element.ns = ns;
  1238. }
  1239. if (isForbiddenTag(element) && !isServerRendering()) {
  1240. element.forbidden = true;
  1241. process.env.NODE_ENV !== 'production' && warn(
  1242. 'Templates should only be responsible for mapping the state to the ' +
  1243. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  1244. "<" + tag + ">" + ', as they will not be parsed.'
  1245. );
  1246. }
  1247. // apply pre-transforms
  1248. for (var i = 0; i < preTransforms.length; i++) {
  1249. preTransforms[i](element, options);
  1250. }
  1251. if (!inVPre) {
  1252. processPre(element);
  1253. if (element.pre) {
  1254. inVPre = true;
  1255. }
  1256. }
  1257. if (platformIsPreTag(element.tag)) {
  1258. inPre = true;
  1259. }
  1260. if (inVPre) {
  1261. processRawAttrs(element);
  1262. } else {
  1263. processFor(element);
  1264. processIf(element);
  1265. processOnce(element);
  1266. processKey(element);
  1267. // determine whether this is a plain element after
  1268. // removing structural attributes
  1269. element.plain = !element.key && !attrs.length;
  1270. processRef(element);
  1271. processSlot(element);
  1272. processComponent(element);
  1273. for (var i$1 = 0; i$1 < transforms.length; i$1++) {
  1274. transforms[i$1](element, options);
  1275. }
  1276. processAttrs(element);
  1277. }
  1278. function checkRootConstraints (el) {
  1279. if (process.env.NODE_ENV !== 'production') {
  1280. if (el.tag === 'slot' || el.tag === 'template') {
  1281. warnOnce(
  1282. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  1283. 'contain multiple nodes.'
  1284. );
  1285. }
  1286. if (el.attrsMap.hasOwnProperty('v-for')) {
  1287. warnOnce(
  1288. 'Cannot use v-for on stateful component root element because ' +
  1289. 'it renders multiple elements.'
  1290. );
  1291. }
  1292. }
  1293. }
  1294. // tree management
  1295. if (!root) {
  1296. root = element;
  1297. checkRootConstraints(root);
  1298. } else if (!stack.length) {
  1299. // allow root elements with v-if, v-else-if and v-else
  1300. if (root.if && (element.elseif || element.else)) {
  1301. checkRootConstraints(element);
  1302. addIfCondition(root, {
  1303. exp: element.elseif,
  1304. block: element
  1305. });
  1306. } else if (process.env.NODE_ENV !== 'production') {
  1307. warnOnce(
  1308. "Component template should contain exactly one root element. " +
  1309. "If you are using v-if on multiple elements, " +
  1310. "use v-else-if to chain them instead."
  1311. );
  1312. }
  1313. }
  1314. if (currentParent && !element.forbidden) {
  1315. if (element.elseif || element.else) {
  1316. processIfConditions(element, currentParent);
  1317. } else if (element.slotScope) { // scoped slot
  1318. currentParent.plain = false;
  1319. var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  1320. } else {
  1321. currentParent.children.push(element);
  1322. element.parent = currentParent;
  1323. }
  1324. }
  1325. if (!unary) {
  1326. currentParent = element;
  1327. stack.push(element);
  1328. } else {
  1329. endPre(element);
  1330. }
  1331. // apply post-transforms
  1332. for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
  1333. postTransforms[i$2](element, options);
  1334. }
  1335. },
  1336. end: function end () {
  1337. // remove trailing whitespace
  1338. var element = stack[stack.length - 1];
  1339. var lastNode = element.children[element.children.length - 1];
  1340. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  1341. element.children.pop();
  1342. }
  1343. // pop stack
  1344. stack.length -= 1;
  1345. currentParent = stack[stack.length - 1];
  1346. endPre(element);
  1347. },
  1348. chars: function chars (text) {
  1349. if (!currentParent) {
  1350. if (process.env.NODE_ENV !== 'production') {
  1351. if (text === template) {
  1352. warnOnce(
  1353. 'Component template requires a root element, rather than just text.'
  1354. );
  1355. } else if ((text = text.trim())) {
  1356. warnOnce(
  1357. ("text \"" + text + "\" outside root element will be ignored.")
  1358. );
  1359. }
  1360. }
  1361. return
  1362. }
  1363. // IE textarea placeholder bug
  1364. /* istanbul ignore if */
  1365. if (isIE &&
  1366. currentParent.tag === 'textarea' &&
  1367. currentParent.attrsMap.placeholder === text
  1368. ) {
  1369. return
  1370. }
  1371. var children = currentParent.children;
  1372. text = inPre || text.trim()
  1373. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  1374. // only preserve whitespace if its not right after a starting tag
  1375. : preserveWhitespace && children.length ? ' ' : '';
  1376. if (text) {
  1377. var expression;
  1378. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  1379. children.push({
  1380. type: 2,
  1381. expression: expression,
  1382. text: text
  1383. });
  1384. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  1385. children.push({
  1386. type: 3,
  1387. text: text
  1388. });
  1389. }
  1390. }
  1391. },
  1392. comment: function comment (text) {
  1393. currentParent.children.push({
  1394. type: 3,
  1395. text: text,
  1396. isComment: true
  1397. });
  1398. }
  1399. });
  1400. return root
  1401. }
  1402. function processPre (el) {
  1403. if (getAndRemoveAttr(el, 'v-pre') != null) {
  1404. el.pre = true;
  1405. }
  1406. }
  1407. function processRawAttrs (el) {
  1408. var l = el.attrsList.length;
  1409. if (l) {
  1410. var attrs = el.attrs = new Array(l);
  1411. for (var i = 0; i < l; i++) {
  1412. attrs[i] = {
  1413. name: el.attrsList[i].name,
  1414. value: JSON.stringify(el.attrsList[i].value)
  1415. };
  1416. }
  1417. } else if (!el.pre) {
  1418. // non root node in pre blocks with no attributes
  1419. el.plain = true;
  1420. }
  1421. }
  1422. function processKey (el) {
  1423. var exp = getBindingAttr(el, 'key');
  1424. if (exp) {
  1425. if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
  1426. warn("<template> cannot be keyed. Place the key on real elements instead.");
  1427. }
  1428. el.key = exp;
  1429. }
  1430. }
  1431. function processRef (el) {
  1432. var ref = getBindingAttr(el, 'ref');
  1433. if (ref) {
  1434. el.ref = ref;
  1435. el.refInFor = checkInFor(el);
  1436. }
  1437. }
  1438. function processFor (el) {
  1439. var exp;
  1440. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  1441. var inMatch = exp.match(forAliasRE);
  1442. if (!inMatch) {
  1443. process.env.NODE_ENV !== 'production' && warn(
  1444. ("Invalid v-for expression: " + exp)
  1445. );
  1446. return
  1447. }
  1448. el.for = inMatch[2].trim();
  1449. var alias = inMatch[1].trim();
  1450. var iteratorMatch = alias.match(forIteratorRE);
  1451. if (iteratorMatch) {
  1452. el.alias = iteratorMatch[1].trim();
  1453. el.iterator1 = iteratorMatch[2].trim();
  1454. if (iteratorMatch[3]) {
  1455. el.iterator2 = iteratorMatch[3].trim();
  1456. }
  1457. } else {
  1458. el.alias = alias;
  1459. }
  1460. }
  1461. }
  1462. function processIf (el) {
  1463. var exp = getAndRemoveAttr(el, 'v-if');
  1464. if (exp) {
  1465. el.if = exp;
  1466. addIfCondition(el, {
  1467. exp: exp,
  1468. block: el
  1469. });
  1470. } else {
  1471. if (getAndRemoveAttr(el, 'v-else') != null) {
  1472. el.else = true;
  1473. }
  1474. var elseif = getAndRemoveAttr(el, 'v-else-if');
  1475. if (elseif) {
  1476. el.elseif = elseif;
  1477. }
  1478. }
  1479. }
  1480. function processIfConditions (el, parent) {
  1481. var prev = findPrevElement(parent.children);
  1482. if (prev && prev.if) {
  1483. addIfCondition(prev, {
  1484. exp: el.elseif,
  1485. block: el
  1486. });
  1487. } else if (process.env.NODE_ENV !== 'production') {
  1488. warn(
  1489. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  1490. "used on element <" + (el.tag) + "> without corresponding v-if."
  1491. );
  1492. }
  1493. }
  1494. function findPrevElement (children) {
  1495. var i = children.length;
  1496. while (i--) {
  1497. if (children[i].type === 1) {
  1498. return children[i]
  1499. } else {
  1500. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  1501. warn(
  1502. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  1503. "will be ignored."
  1504. );
  1505. }
  1506. children.pop();
  1507. }
  1508. }
  1509. }
  1510. function addIfCondition (el, condition) {
  1511. if (!el.ifConditions) {
  1512. el.ifConditions = [];
  1513. }
  1514. el.ifConditions.push(condition);
  1515. }
  1516. function processOnce (el) {
  1517. var once$$1 = getAndRemoveAttr(el, 'v-once');
  1518. if (once$$1 != null) {
  1519. el.once = true;
  1520. }
  1521. }
  1522. function processSlot (el) {
  1523. if (el.tag === 'slot') {
  1524. el.slotName = getBindingAttr(el, 'name');
  1525. if (process.env.NODE_ENV !== 'production' && el.key) {
  1526. warn(
  1527. "`key` does not work on <slot> because slots are abstract outlets " +
  1528. "and can possibly expand into multiple elements. " +
  1529. "Use the key on a wrapping element instead."
  1530. );
  1531. }
  1532. } else {
  1533. var slotTarget = getBindingAttr(el, 'slot');
  1534. if (slotTarget) {
  1535. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  1536. }
  1537. if (el.tag === 'template') {
  1538. el.slotScope = getAndRemoveAttr(el, 'scope');
  1539. }
  1540. }
  1541. }
  1542. function processComponent (el) {
  1543. var binding;
  1544. if ((binding = getBindingAttr(el, 'is'))) {
  1545. el.component = binding;
  1546. }
  1547. if (getAndRemoveAttr(el, 'inline-template') != null) {
  1548. el.inlineTemplate = true;
  1549. }
  1550. }
  1551. function processAttrs (el) {
  1552. var list = el.attrsList;
  1553. var i, l, name, rawName, value, modifiers, isProp;
  1554. for (i = 0, l = list.length; i < l; i++) {
  1555. name = rawName = list[i].name;
  1556. value = list[i].value;
  1557. if (dirRE.test(name)) {
  1558. // mark element as dynamic
  1559. el.hasBindings = true;
  1560. // modifiers
  1561. modifiers = parseModifiers(name);
  1562. if (modifiers) {
  1563. name = name.replace(modifierRE, '');
  1564. }
  1565. if (bindRE.test(name)) { // v-bind
  1566. name = name.replace(bindRE, '');
  1567. value = parseFilters(value);
  1568. isProp = false;
  1569. if (modifiers) {
  1570. if (modifiers.prop) {
  1571. isProp = true;
  1572. name = camelize(name);
  1573. if (name === 'innerHtml') { name = 'innerHTML'; }
  1574. }
  1575. if (modifiers.camel) {
  1576. name = camelize(name);
  1577. }
  1578. if (modifiers.sync) {
  1579. addHandler(
  1580. el,
  1581. ("update:" + (camelize(name))),
  1582. genAssignmentCode(value, "$event")
  1583. );
  1584. }
  1585. }
  1586. if (isProp || (
  1587. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  1588. )) {
  1589. addProp(el, name, value);
  1590. } else {
  1591. addAttr(el, name, value);
  1592. }
  1593. } else if (onRE.test(name)) { // v-on
  1594. name = name.replace(onRE, '');
  1595. addHandler(el, name, value, modifiers, false, warn);
  1596. } else { // normal directives
  1597. name = name.replace(dirRE, '');
  1598. // parse arg
  1599. var argMatch = name.match(argRE);
  1600. var arg = argMatch && argMatch[1];
  1601. if (arg) {
  1602. name = name.slice(0, -(arg.length + 1));
  1603. }
  1604. addDirective(el, name, rawName, value, arg, modifiers);
  1605. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  1606. checkForAliasModel(el, value);
  1607. }
  1608. }
  1609. } else {
  1610. // literal attribute
  1611. if (process.env.NODE_ENV !== 'production') {
  1612. var expression = parseText(value, delimiters);
  1613. if (expression) {
  1614. warn(
  1615. name + "=\"" + value + "\": " +
  1616. 'Interpolation inside attributes has been removed. ' +
  1617. 'Use v-bind or the colon shorthand instead. For example, ' +
  1618. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  1619. );
  1620. }
  1621. }
  1622. addAttr(el, name, JSON.stringify(value));
  1623. }
  1624. }
  1625. }
  1626. function checkInFor (el) {
  1627. var parent = el;
  1628. while (parent) {
  1629. if (parent.for !== undefined) {
  1630. return true
  1631. }
  1632. parent = parent.parent;
  1633. }
  1634. return false
  1635. }
  1636. function parseModifiers (name) {
  1637. var match = name.match(modifierRE);
  1638. if (match) {
  1639. var ret = {};
  1640. match.forEach(function (m) { ret[m.slice(1)] = true; });
  1641. return ret
  1642. }
  1643. }
  1644. function makeAttrsMap (attrs) {
  1645. var map = {};
  1646. for (var i = 0, l = attrs.length; i < l; i++) {
  1647. if (
  1648. process.env.NODE_ENV !== 'production' &&
  1649. map[attrs[i].name] && !isIE && !isEdge
  1650. ) {
  1651. warn('duplicate attribute: ' + attrs[i].name);
  1652. }
  1653. map[attrs[i].name] = attrs[i].value;
  1654. }
  1655. return map
  1656. }
  1657. // for script (e.g. type="x/template") or style, do not decode content
  1658. function isTextTag (el) {
  1659. return el.tag === 'script' || el.tag === 'style'
  1660. }
  1661. function isForbiddenTag (el) {
  1662. return (
  1663. el.tag === 'style' ||
  1664. (el.tag === 'script' && (
  1665. !el.attrsMap.type ||
  1666. el.attrsMap.type === 'text/javascript'
  1667. ))
  1668. )
  1669. }
  1670. var ieNSBug = /^xmlns:NS\d+/;
  1671. var ieNSPrefix = /^NS\d+:/;
  1672. /* istanbul ignore next */
  1673. function guardIESVGBug (attrs) {
  1674. var res = [];
  1675. for (var i = 0; i < attrs.length; i++) {
  1676. var attr = attrs[i];
  1677. if (!ieNSBug.test(attr.name)) {
  1678. attr.name = attr.name.replace(ieNSPrefix, '');
  1679. res.push(attr);
  1680. }
  1681. }
  1682. return res
  1683. }
  1684. function checkForAliasModel (el, value) {
  1685. var _el = el;
  1686. while (_el) {
  1687. if (_el.for && _el.alias === value) {
  1688. warn(
  1689. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  1690. "You are binding v-model directly to a v-for iteration alias. " +
  1691. "This will not be able to modify the v-for source array because " +
  1692. "writing to the alias is like modifying a function local variable. " +
  1693. "Consider using an array of objects and use v-model on an object property instead."
  1694. );
  1695. }
  1696. _el = _el.parent;
  1697. }
  1698. }
  1699. /* */
  1700. var isStaticKey;
  1701. var isPlatformReservedTag;
  1702. var genStaticKeysCached = cached(genStaticKeys$1);
  1703. /**
  1704. * Goal of the optimizer: walk the generated template AST tree
  1705. * and detect sub-trees that are purely static, i.e. parts of
  1706. * the DOM that never needs to change.
  1707. *
  1708. * Once we detect these sub-trees, we can:
  1709. *
  1710. * 1. Hoist them into constants, so that we no longer need to
  1711. * create fresh nodes for them on each re-render;
  1712. * 2. Completely skip them in the patching process.
  1713. */
  1714. function optimize (root, options) {
  1715. if (!root) { return }
  1716. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  1717. isPlatformReservedTag = options.isReservedTag || no;
  1718. // first pass: mark all non-static nodes.
  1719. markStatic(root);
  1720. // second pass: mark static roots.
  1721. markStaticRoots(root, false);
  1722. }
  1723. function genStaticKeys$1 (keys) {
  1724. return makeMap(
  1725. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  1726. (keys ? ',' + keys : '')
  1727. )
  1728. }
  1729. function markStatic (node) {
  1730. node.static = isStatic(node);
  1731. if (node.type === 1) {
  1732. // do not make component slot content static. this avoids
  1733. // 1. components not able to mutate slot nodes
  1734. // 2. static slot content fails for hot-reloading
  1735. if (
  1736. !isPlatformReservedTag(node.tag) &&
  1737. node.tag !== 'slot' &&
  1738. node.attrsMap['inline-template'] == null
  1739. ) {
  1740. return
  1741. }
  1742. for (var i = 0, l = node.children.length; i < l; i++) {
  1743. var child = node.children[i];
  1744. markStatic(child);
  1745. if (!child.static) {
  1746. node.static = false;
  1747. }
  1748. }
  1749. if (node.ifConditions) {
  1750. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  1751. var block = node.ifConditions[i$1].block;
  1752. markStatic(block);
  1753. if (!block.static) {
  1754. node.static = false;
  1755. }
  1756. }
  1757. }
  1758. }
  1759. }
  1760. function markStaticRoots (node, isInFor) {
  1761. if (node.type === 1) {
  1762. if (node.static || node.once) {
  1763. node.staticInFor = isInFor;
  1764. }
  1765. // For a node to qualify as a static root, it should have children that
  1766. // are not just static text. Otherwise the cost of hoisting out will
  1767. // outweigh the benefits and it's better off to just always render it fresh.
  1768. if (node.static && node.children.length && !(
  1769. node.children.length === 1 &&
  1770. node.children[0].type === 3
  1771. )) {
  1772. node.staticRoot = true;
  1773. return
  1774. } else {
  1775. node.staticRoot = false;
  1776. }
  1777. if (node.children) {
  1778. for (var i = 0, l = node.children.length; i < l; i++) {
  1779. markStaticRoots(node.children[i], isInFor || !!node.for);
  1780. }
  1781. }
  1782. if (node.ifConditions) {
  1783. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  1784. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  1785. }
  1786. }
  1787. }
  1788. }
  1789. function isStatic (node) {
  1790. if (node.type === 2) { // expression
  1791. return false
  1792. }
  1793. if (node.type === 3) { // text
  1794. return true
  1795. }
  1796. return !!(node.pre || (
  1797. !node.hasBindings && // no dynamic bindings
  1798. !node.if && !node.for && // not v-if or v-for or v-else
  1799. !isBuiltInTag(node.tag) && // not a built-in
  1800. isPlatformReservedTag(node.tag) && // not a component
  1801. !isDirectChildOfTemplateFor(node) &&
  1802. Object.keys(node).every(isStaticKey)
  1803. ))
  1804. }
  1805. function isDirectChildOfTemplateFor (node) {
  1806. while (node.parent) {
  1807. node = node.parent;
  1808. if (node.tag !== 'template') {
  1809. return false
  1810. }
  1811. if (node.for) {
  1812. return true
  1813. }
  1814. }
  1815. return false
  1816. }
  1817. /* */
  1818. var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  1819. var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
  1820. // keyCode aliases
  1821. var keyCodes = {
  1822. esc: 27,
  1823. tab: 9,
  1824. enter: 13,
  1825. space: 32,
  1826. up: 38,
  1827. left: 37,
  1828. right: 39,
  1829. down: 40,
  1830. 'delete': [8, 46]
  1831. };
  1832. // #4868: modifiers that prevent the execution of the listener
  1833. // need to explicitly return null so that we can determine whether to remove
  1834. // the listener for .once
  1835. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  1836. var modifierCode = {
  1837. stop: '$event.stopPropagation();',
  1838. prevent: '$event.preventDefault();',
  1839. self: genGuard("$event.target !== $event.currentTarget"),
  1840. ctrl: genGuard("!$event.ctrlKey"),
  1841. shift: genGuard("!$event.shiftKey"),
  1842. alt: genGuard("!$event.altKey"),
  1843. meta: genGuard("!$event.metaKey"),
  1844. left: genGuard("'button' in $event && $event.button !== 0"),
  1845. middle: genGuard("'button' in $event && $event.button !== 1"),
  1846. right: genGuard("'button' in $event && $event.button !== 2")
  1847. };
  1848. function genHandlers (
  1849. events,
  1850. isNative,
  1851. warn
  1852. ) {
  1853. var res = isNative ? 'nativeOn:{' : 'on:{';
  1854. for (var name in events) {
  1855. var handler = events[name];
  1856. // #5330: warn click.right, since right clicks do not actually fire click events.
  1857. if (process.env.NODE_ENV !== 'production' &&
  1858. name === 'click' &&
  1859. handler && handler.modifiers && handler.modifiers.right
  1860. ) {
  1861. warn(
  1862. "Use \"contextmenu\" instead of \"click.right\" since right clicks " +
  1863. "do not actually fire \"click\" events."
  1864. );
  1865. }
  1866. res += "\"" + name + "\":" + (genHandler(name, handler)) + ",";
  1867. }
  1868. return res.slice(0, -1) + '}'
  1869. }
  1870. function genHandler (
  1871. name,
  1872. handler
  1873. ) {
  1874. if (!handler) {
  1875. return 'function(){}'
  1876. }
  1877. if (Array.isArray(handler)) {
  1878. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  1879. }
  1880. var isMethodPath = simplePathRE.test(handler.value);
  1881. var isFunctionExpression = fnExpRE.test(handler.value);
  1882. if (!handler.modifiers) {
  1883. return isMethodPath || isFunctionExpression
  1884. ? handler.value
  1885. : ("function($event){" + (handler.value) + "}") // inline statement
  1886. } else {
  1887. var code = '';
  1888. var genModifierCode = '';
  1889. var keys = [];
  1890. for (var key in handler.modifiers) {
  1891. if (modifierCode[key]) {
  1892. genModifierCode += modifierCode[key];
  1893. // left/right
  1894. if (keyCodes[key]) {
  1895. keys.push(key);
  1896. }
  1897. } else {
  1898. keys.push(key);
  1899. }
  1900. }
  1901. if (keys.length) {
  1902. code += genKeyFilter(keys);
  1903. }
  1904. // Make sure modifiers like prevent and stop get executed after key filtering
  1905. if (genModifierCode) {
  1906. code += genModifierCode;
  1907. }
  1908. var handlerCode = isMethodPath
  1909. ? handler.value + '($event)'
  1910. : isFunctionExpression
  1911. ? ("(" + (handler.value) + ")($event)")
  1912. : handler.value;
  1913. return ("function($event){" + code + handlerCode + "}")
  1914. }
  1915. }
  1916. function genKeyFilter (keys) {
  1917. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  1918. }
  1919. function genFilterCode (key) {
  1920. var keyVal = parseInt(key, 10);
  1921. if (keyVal) {
  1922. return ("$event.keyCode!==" + keyVal)
  1923. }
  1924. var alias = keyCodes[key];
  1925. return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
  1926. }
  1927. /* */
  1928. var emptyObject = Object.freeze({});
  1929. /**
  1930. * Check if a string starts with $ or _
  1931. */
  1932. /**
  1933. * Define a property.
  1934. */
  1935. function def (obj, key, val, enumerable) {
  1936. Object.defineProperty(obj, key, {
  1937. value: val,
  1938. enumerable: !!enumerable,
  1939. writable: true,
  1940. configurable: true
  1941. });
  1942. }
  1943. /* */
  1944. var uid = 0;
  1945. /**
  1946. * A dep is an observable that can have multiple
  1947. * directives subscribing to it.
  1948. */
  1949. var Dep = function Dep () {
  1950. this.id = uid++;
  1951. this.subs = [];
  1952. };
  1953. Dep.prototype.addSub = function addSub (sub) {
  1954. this.subs.push(sub);
  1955. };
  1956. Dep.prototype.removeSub = function removeSub (sub) {
  1957. remove(this.subs, sub);
  1958. };
  1959. Dep.prototype.depend = function depend () {
  1960. if (Dep.target) {
  1961. Dep.target.addDep(this);
  1962. }
  1963. };
  1964. Dep.prototype.notify = function notify () {
  1965. // stabilize the subscriber list first
  1966. var subs = this.subs.slice();
  1967. for (var i = 0, l = subs.length; i < l; i++) {
  1968. subs[i].update();
  1969. }
  1970. };
  1971. // the current target watcher being evaluated.
  1972. // this is globally unique because there could be only one
  1973. // watcher being evaluated at any time.
  1974. Dep.target = null;
  1975. /*
  1976. * not type checking this file because flow doesn't play well with
  1977. * dynamically accessing methods on Array prototype
  1978. */
  1979. var arrayProto = Array.prototype;
  1980. var arrayMethods = Object.create(arrayProto);[
  1981. 'push',
  1982. 'pop',
  1983. 'shift',
  1984. 'unshift',
  1985. 'splice',
  1986. 'sort',
  1987. 'reverse'
  1988. ]
  1989. .forEach(function (method) {
  1990. // cache original method
  1991. var original = arrayProto[method];
  1992. def(arrayMethods, method, function mutator () {
  1993. var args = [], len = arguments.length;
  1994. while ( len-- ) args[ len ] = arguments[ len ];
  1995. var result = original.apply(this, args);
  1996. var ob = this.__ob__;
  1997. var inserted;
  1998. switch (method) {
  1999. case 'push':
  2000. case 'unshift':
  2001. inserted = args;
  2002. break
  2003. case 'splice':
  2004. inserted = args.slice(2);
  2005. break
  2006. }
  2007. if (inserted) { ob.observeArray(inserted); }
  2008. // notify change
  2009. ob.dep.notify();
  2010. return result
  2011. });
  2012. });
  2013. /* */
  2014. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  2015. /**
  2016. * By default, when a reactive property is set, the new value is
  2017. * also converted to become reactive. However when passing down props,
  2018. * we don't want to force conversion because the value may be a nested value
  2019. * under a frozen data structure. Converting it would defeat the optimization.
  2020. */
  2021. var observerState = {
  2022. shouldConvert: true
  2023. };
  2024. /**
  2025. * Observer class that are attached to each observed
  2026. * object. Once attached, the observer converts target
  2027. * object's property keys into getter/setters that
  2028. * collect dependencies and dispatches updates.
  2029. */
  2030. var Observer = function Observer (value) {
  2031. this.value = value;
  2032. this.dep = new Dep();
  2033. this.vmCount = 0;
  2034. def(value, '__ob__', this);
  2035. if (Array.isArray(value)) {
  2036. var augment = hasProto
  2037. ? protoAugment
  2038. : copyAugment;
  2039. augment(value, arrayMethods, arrayKeys);
  2040. this.observeArray(value);
  2041. } else {
  2042. this.walk(value);
  2043. }
  2044. };
  2045. /**
  2046. * Walk through each property and convert them into
  2047. * getter/setters. This method should only be called when
  2048. * value type is Object.
  2049. */
  2050. Observer.prototype.walk = function walk (obj) {
  2051. var keys = Object.keys(obj);
  2052. for (var i = 0; i < keys.length; i++) {
  2053. defineReactive$$1(obj, keys[i], obj[keys[i]]);
  2054. }
  2055. };
  2056. /**
  2057. * Observe a list of Array items.
  2058. */
  2059. Observer.prototype.observeArray = function observeArray (items) {
  2060. for (var i = 0, l = items.length; i < l; i++) {
  2061. observe(items[i]);
  2062. }
  2063. };
  2064. // helpers
  2065. /**
  2066. * Augment an target Object or Array by intercepting
  2067. * the prototype chain using __proto__
  2068. */
  2069. function protoAugment (target, src, keys) {
  2070. /* eslint-disable no-proto */
  2071. target.__proto__ = src;
  2072. /* eslint-enable no-proto */
  2073. }
  2074. /**
  2075. * Augment an target Object or Array by defining
  2076. * hidden properties.
  2077. */
  2078. /* istanbul ignore next */
  2079. function copyAugment (target, src, keys) {
  2080. for (var i = 0, l = keys.length; i < l; i++) {
  2081. var key = keys[i];
  2082. def(target, key, src[key]);
  2083. }
  2084. }
  2085. /**
  2086. * Attempt to create an observer instance for a value,
  2087. * returns the new observer if successfully observed,
  2088. * or the existing observer if the value already has one.
  2089. */
  2090. function observe (value, asRootData) {
  2091. if (!isObject(value)) {
  2092. return
  2093. }
  2094. var ob;
  2095. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  2096. ob = value.__ob__;
  2097. } else if (
  2098. observerState.shouldConvert &&
  2099. !isServerRendering() &&
  2100. (Array.isArray(value) || isPlainObject(value)) &&
  2101. Object.isExtensible(value) &&
  2102. !value._isVue
  2103. ) {
  2104. ob = new Observer(value);
  2105. }
  2106. if (asRootData && ob) {
  2107. ob.vmCount++;
  2108. }
  2109. return ob
  2110. }
  2111. /**
  2112. * Define a reactive property on an Object.
  2113. */
  2114. function defineReactive$$1 (
  2115. obj,
  2116. key,
  2117. val,
  2118. customSetter,
  2119. shallow
  2120. ) {
  2121. var dep = new Dep();
  2122. var property = Object.getOwnPropertyDescriptor(obj, key);
  2123. if (property && property.configurable === false) {
  2124. return
  2125. }
  2126. // cater for pre-defined getter/setters
  2127. var getter = property && property.get;
  2128. var setter = property && property.set;
  2129. var childOb = !shallow && observe(val);
  2130. Object.defineProperty(obj, key, {
  2131. enumerable: true,
  2132. configurable: true,
  2133. get: function reactiveGetter () {
  2134. var value = getter ? getter.call(obj) : val;
  2135. if (Dep.target) {
  2136. dep.depend();
  2137. if (childOb) {
  2138. childOb.dep.depend();
  2139. }
  2140. if (Array.isArray(value)) {
  2141. dependArray(value);
  2142. }
  2143. }
  2144. return value
  2145. },
  2146. set: function reactiveSetter (newVal) {
  2147. var value = getter ? getter.call(obj) : val;
  2148. /* eslint-disable no-self-compare */
  2149. if (newVal === value || (newVal !== newVal && value !== value)) {
  2150. return
  2151. }
  2152. /* eslint-enable no-self-compare */
  2153. if (process.env.NODE_ENV !== 'production' && customSetter) {
  2154. customSetter();
  2155. }
  2156. if (setter) {
  2157. setter.call(obj, newVal);
  2158. } else {
  2159. val = newVal;
  2160. }
  2161. childOb = !shallow && observe(newVal);
  2162. dep.notify();
  2163. }
  2164. });
  2165. }
  2166. /**
  2167. * Set a property on an object. Adds the new property and
  2168. * triggers change notification if the property doesn't
  2169. * already exist.
  2170. */
  2171. function set (target, key, val) {
  2172. if (Array.isArray(target) && isValidArrayIndex(key)) {
  2173. target.length = Math.max(target.length, key);
  2174. target.splice(key, 1, val);
  2175. return val
  2176. }
  2177. if (hasOwn(target, key)) {
  2178. target[key] = val;
  2179. return val
  2180. }
  2181. var ob = (target).__ob__;
  2182. if (target._isVue || (ob && ob.vmCount)) {
  2183. process.env.NODE_ENV !== 'production' && warn$1(
  2184. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  2185. 'at runtime - declare it upfront in the data option.'
  2186. );
  2187. return val
  2188. }
  2189. if (!ob) {
  2190. target[key] = val;
  2191. return val
  2192. }
  2193. defineReactive$$1(ob.value, key, val);
  2194. ob.dep.notify();
  2195. return val
  2196. }
  2197. /**
  2198. * Delete a property and trigger change if necessary.
  2199. */
  2200. /**
  2201. * Collect dependencies on array elements when the array is touched, since
  2202. * we cannot intercept array element access like property getters.
  2203. */
  2204. function dependArray (value) {
  2205. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  2206. e = value[i];
  2207. e && e.__ob__ && e.__ob__.dep.depend();
  2208. if (Array.isArray(e)) {
  2209. dependArray(e);
  2210. }
  2211. }
  2212. }
  2213. /* */
  2214. /**
  2215. * Option overwriting strategies are functions that handle
  2216. * how to merge a parent option value and a child option
  2217. * value into the final value.
  2218. */
  2219. var strats = config.optionMergeStrategies;
  2220. /**
  2221. * Options with restrictions
  2222. */
  2223. if (process.env.NODE_ENV !== 'production') {
  2224. strats.el = strats.propsData = function (parent, child, vm, key) {
  2225. if (!vm) {
  2226. warn$1(
  2227. "option \"" + key + "\" can only be used during instance " +
  2228. 'creation with the `new` keyword.'
  2229. );
  2230. }
  2231. return defaultStrat(parent, child)
  2232. };
  2233. }
  2234. /**
  2235. * Helper that recursively merges two data objects together.
  2236. */
  2237. function mergeData (to, from) {
  2238. if (!from) { return to }
  2239. var key, toVal, fromVal;
  2240. var keys = Object.keys(from);
  2241. for (var i = 0; i < keys.length; i++) {
  2242. key = keys[i];
  2243. toVal = to[key];
  2244. fromVal = from[key];
  2245. if (!hasOwn(to, key)) {
  2246. set(to, key, fromVal);
  2247. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  2248. mergeData(toVal, fromVal);
  2249. }
  2250. }
  2251. return to
  2252. }
  2253. /**
  2254. * Data
  2255. */
  2256. function mergeDataOrFn (
  2257. parentVal,
  2258. childVal,
  2259. vm
  2260. ) {
  2261. if (!vm) {
  2262. // in a Vue.extend merge, both should be functions
  2263. if (!childVal) {
  2264. return parentVal
  2265. }
  2266. if (!parentVal) {
  2267. return childVal
  2268. }
  2269. // when parentVal & childVal are both present,
  2270. // we need to return a function that returns the
  2271. // merged result of both functions... no need to
  2272. // check if parentVal is a function here because
  2273. // it has to be a function to pass previous merges.
  2274. return function mergedDataFn () {
  2275. return mergeData(
  2276. typeof childVal === 'function' ? childVal.call(this) : childVal,
  2277. typeof parentVal === 'function' ? parentVal.call(this) : parentVal
  2278. )
  2279. }
  2280. } else if (parentVal || childVal) {
  2281. return function mergedInstanceDataFn () {
  2282. // instance merge
  2283. var instanceData = typeof childVal === 'function'
  2284. ? childVal.call(vm)
  2285. : childVal;
  2286. var defaultData = typeof parentVal === 'function'
  2287. ? parentVal.call(vm)
  2288. : undefined;
  2289. if (instanceData) {
  2290. return mergeData(instanceData, defaultData)
  2291. } else {
  2292. return defaultData
  2293. }
  2294. }
  2295. }
  2296. }
  2297. strats.data = function (
  2298. parentVal,
  2299. childVal,
  2300. vm
  2301. ) {
  2302. if (!vm) {
  2303. if (childVal && typeof childVal !== 'function') {
  2304. process.env.NODE_ENV !== 'production' && warn$1(
  2305. 'The "data" option should be a function ' +
  2306. 'that returns a per-instance value in component ' +
  2307. 'definitions.',
  2308. vm
  2309. );
  2310. return parentVal
  2311. }
  2312. return mergeDataOrFn.call(this, parentVal, childVal)
  2313. }
  2314. return mergeDataOrFn(parentVal, childVal, vm)
  2315. };
  2316. /**
  2317. * Hooks and props are merged as arrays.
  2318. */
  2319. function mergeHook (
  2320. parentVal,
  2321. childVal
  2322. ) {
  2323. return childVal
  2324. ? parentVal
  2325. ? parentVal.concat(childVal)
  2326. : Array.isArray(childVal)
  2327. ? childVal
  2328. : [childVal]
  2329. : parentVal
  2330. }
  2331. LIFECYCLE_HOOKS.forEach(function (hook) {
  2332. strats[hook] = mergeHook;
  2333. });
  2334. /**
  2335. * Assets
  2336. *
  2337. * When a vm is present (instance creation), we need to do
  2338. * a three-way merge between constructor options, instance
  2339. * options and parent options.
  2340. */
  2341. function mergeAssets (parentVal, childVal) {
  2342. var res = Object.create(parentVal || null);
  2343. return childVal
  2344. ? extend(res, childVal)
  2345. : res
  2346. }
  2347. ASSET_TYPES.forEach(function (type) {
  2348. strats[type + 's'] = mergeAssets;
  2349. });
  2350. /**
  2351. * Watchers.
  2352. *
  2353. * Watchers hashes should not overwrite one
  2354. * another, so we merge them as arrays.
  2355. */
  2356. strats.watch = function (parentVal, childVal) {
  2357. // work around Firefox's Object.prototype.watch...
  2358. if (parentVal === nativeWatch) { parentVal = undefined; }
  2359. if (childVal === nativeWatch) { childVal = undefined; }
  2360. /* istanbul ignore if */
  2361. if (!childVal) { return Object.create(parentVal || null) }
  2362. if (!parentVal) { return childVal }
  2363. var ret = {};
  2364. extend(ret, parentVal);
  2365. for (var key in childVal) {
  2366. var parent = ret[key];
  2367. var child = childVal[key];
  2368. if (parent && !Array.isArray(parent)) {
  2369. parent = [parent];
  2370. }
  2371. ret[key] = parent
  2372. ? parent.concat(child)
  2373. : Array.isArray(child) ? child : [child];
  2374. }
  2375. return ret
  2376. };
  2377. /**
  2378. * Other object hashes.
  2379. */
  2380. strats.props =
  2381. strats.methods =
  2382. strats.inject =
  2383. strats.computed = function (parentVal, childVal) {
  2384. if (!parentVal) { return childVal }
  2385. var ret = Object.create(null);
  2386. extend(ret, parentVal);
  2387. if (childVal) { extend(ret, childVal); }
  2388. return ret
  2389. };
  2390. strats.provide = mergeDataOrFn;
  2391. /**
  2392. * Default strategy.
  2393. */
  2394. var defaultStrat = function (parentVal, childVal) {
  2395. return childVal === undefined
  2396. ? parentVal
  2397. : childVal
  2398. };
  2399. /**
  2400. * Merge two option objects into a new one.
  2401. * Core utility used in both instantiation and inheritance.
  2402. */
  2403. /**
  2404. * Resolve an asset.
  2405. * This function is used because child instances need access
  2406. * to assets defined in its ancestor chain.
  2407. */
  2408. /* */
  2409. /* */
  2410. /* */
  2411. function on (el, dir) {
  2412. if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
  2413. warn$1("v-on without argument does not support modifiers.");
  2414. }
  2415. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  2416. }
  2417. /* */
  2418. function bind$1 (el, dir) {
  2419. el.wrapData = function (code) {
  2420. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  2421. };
  2422. }
  2423. /* */
  2424. var baseDirectives = {
  2425. on: on,
  2426. bind: bind$1,
  2427. cloak: noop
  2428. };
  2429. /* */
  2430. var CodegenState = function CodegenState (options) {
  2431. this.options = options;
  2432. this.warn = options.warn || baseWarn;
  2433. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  2434. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  2435. this.directives = extend(extend({}, baseDirectives), options.directives);
  2436. var isReservedTag = options.isReservedTag || no;
  2437. this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
  2438. this.onceId = 0;
  2439. this.staticRenderFns = [];
  2440. };
  2441. function generate (
  2442. ast,
  2443. options
  2444. ) {
  2445. var state = new CodegenState(options);
  2446. var code = ast ? genElement(ast, state) : '_c("div")';
  2447. return {
  2448. render: ("with(this){return " + code + "}"),
  2449. staticRenderFns: state.staticRenderFns
  2450. }
  2451. }
  2452. function genElement (el, state) {
  2453. if (el.staticRoot && !el.staticProcessed) {
  2454. return genStatic(el, state)
  2455. } else if (el.once && !el.onceProcessed) {
  2456. return genOnce(el, state)
  2457. } else if (el.for && !el.forProcessed) {
  2458. return genFor(el, state)
  2459. } else if (el.if && !el.ifProcessed) {
  2460. return genIf(el, state)
  2461. } else if (el.tag === 'template' && !el.slotTarget) {
  2462. return genChildren(el, state) || 'void 0'
  2463. } else if (el.tag === 'slot') {
  2464. return genSlot(el, state)
  2465. } else {
  2466. // component or element
  2467. var code;
  2468. if (el.component) {
  2469. code = genComponent(el.component, el, state);
  2470. } else {
  2471. var data = el.plain ? undefined : genData(el, state);
  2472. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  2473. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  2474. }
  2475. // module transforms
  2476. for (var i = 0; i < state.transforms.length; i++) {
  2477. code = state.transforms[i](el, code);
  2478. }
  2479. return code
  2480. }
  2481. }
  2482. // hoist static sub-trees out
  2483. function genStatic (el, state) {
  2484. el.staticProcessed = true;
  2485. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  2486. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  2487. }
  2488. // v-once
  2489. function genOnce (el, state) {
  2490. el.onceProcessed = true;
  2491. if (el.if && !el.ifProcessed) {
  2492. return genIf(el, state)
  2493. } else if (el.staticInFor) {
  2494. var key = '';
  2495. var parent = el.parent;
  2496. while (parent) {
  2497. if (parent.for) {
  2498. key = parent.key;
  2499. break
  2500. }
  2501. parent = parent.parent;
  2502. }
  2503. if (!key) {
  2504. process.env.NODE_ENV !== 'production' && state.warn(
  2505. "v-once can only be used inside v-for that is keyed. "
  2506. );
  2507. return genElement(el, state)
  2508. }
  2509. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + (key ? ("," + key) : "") + ")")
  2510. } else {
  2511. return genStatic(el, state)
  2512. }
  2513. }
  2514. function genIf (
  2515. el,
  2516. state,
  2517. altGen,
  2518. altEmpty
  2519. ) {
  2520. el.ifProcessed = true; // avoid recursion
  2521. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  2522. }
  2523. function genIfConditions (
  2524. conditions,
  2525. state,
  2526. altGen,
  2527. altEmpty
  2528. ) {
  2529. if (!conditions.length) {
  2530. return altEmpty || '_e()'
  2531. }
  2532. var condition = conditions.shift();
  2533. if (condition.exp) {
  2534. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  2535. } else {
  2536. return ("" + (genTernaryExp(condition.block)))
  2537. }
  2538. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  2539. function genTernaryExp (el) {
  2540. return altGen
  2541. ? altGen(el, state)
  2542. : el.once
  2543. ? genOnce(el, state)
  2544. : genElement(el, state)
  2545. }
  2546. }
  2547. function genFor (
  2548. el,
  2549. state,
  2550. altGen,
  2551. altHelper
  2552. ) {
  2553. var exp = el.for;
  2554. var alias = el.alias;
  2555. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  2556. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  2557. if (process.env.NODE_ENV !== 'production' &&
  2558. state.maybeComponent(el) &&
  2559. el.tag !== 'slot' &&
  2560. el.tag !== 'template' &&
  2561. !el.key
  2562. ) {
  2563. state.warn(
  2564. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  2565. "v-for should have explicit keys. " +
  2566. "See https://vuejs.org/guide/list.html#key for more info.",
  2567. true /* tip */
  2568. );
  2569. }
  2570. el.forProcessed = true; // avoid recursion
  2571. return (altHelper || '_l') + "((" + exp + ")," +
  2572. "function(" + alias + iterator1 + iterator2 + "){" +
  2573. "return " + ((altGen || genElement)(el, state)) +
  2574. '})'
  2575. }
  2576. function genData (el, state) {
  2577. var data = '{';
  2578. // directives first.
  2579. // directives may mutate the el's other properties before they are generated.
  2580. var dirs = genDirectives(el, state);
  2581. if (dirs) { data += dirs + ','; }
  2582. // key
  2583. if (el.key) {
  2584. data += "key:" + (el.key) + ",";
  2585. }
  2586. // ref
  2587. if (el.ref) {
  2588. data += "ref:" + (el.ref) + ",";
  2589. }
  2590. if (el.refInFor) {
  2591. data += "refInFor:true,";
  2592. }
  2593. // pre
  2594. if (el.pre) {
  2595. data += "pre:true,";
  2596. }
  2597. // record original tag name for components using "is" attribute
  2598. if (el.component) {
  2599. data += "tag:\"" + (el.tag) + "\",";
  2600. }
  2601. // module data generation functions
  2602. for (var i = 0; i < state.dataGenFns.length; i++) {
  2603. data += state.dataGenFns[i](el);
  2604. }
  2605. // attributes
  2606. if (el.attrs) {
  2607. data += "attrs:{" + (genProps(el.attrs)) + "},";
  2608. }
  2609. // DOM props
  2610. if (el.props) {
  2611. data += "domProps:{" + (genProps(el.props)) + "},";
  2612. }
  2613. // event handlers
  2614. if (el.events) {
  2615. data += (genHandlers(el.events, false, state.warn)) + ",";
  2616. }
  2617. if (el.nativeEvents) {
  2618. data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
  2619. }
  2620. // slot target
  2621. if (el.slotTarget) {
  2622. data += "slot:" + (el.slotTarget) + ",";
  2623. }
  2624. // scoped slots
  2625. if (el.scopedSlots) {
  2626. data += (genScopedSlots(el.scopedSlots, state)) + ",";
  2627. }
  2628. // component v-model
  2629. if (el.model) {
  2630. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  2631. }
  2632. // inline-template
  2633. if (el.inlineTemplate) {
  2634. var inlineTemplate = genInlineTemplate(el, state);
  2635. if (inlineTemplate) {
  2636. data += inlineTemplate + ",";
  2637. }
  2638. }
  2639. data = data.replace(/,$/, '') + '}';
  2640. // v-bind data wrap
  2641. if (el.wrapData) {
  2642. data = el.wrapData(data);
  2643. }
  2644. // v-on data wrap
  2645. if (el.wrapListeners) {
  2646. data = el.wrapListeners(data);
  2647. }
  2648. return data
  2649. }
  2650. function genDirectives (el, state) {
  2651. var dirs = el.directives;
  2652. if (!dirs) { return }
  2653. var res = 'directives:[';
  2654. var hasRuntime = false;
  2655. var i, l, dir, needRuntime;
  2656. for (i = 0, l = dirs.length; i < l; i++) {
  2657. dir = dirs[i];
  2658. needRuntime = true;
  2659. var gen = state.directives[dir.name];
  2660. if (gen) {
  2661. // compile-time directive that manipulates AST.
  2662. // returns true if it also needs a runtime counterpart.
  2663. needRuntime = !!gen(el, dir, state.warn);
  2664. }
  2665. if (needRuntime) {
  2666. hasRuntime = true;
  2667. 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))) : '') + "},";
  2668. }
  2669. }
  2670. if (hasRuntime) {
  2671. return res.slice(0, -1) + ']'
  2672. }
  2673. }
  2674. function genInlineTemplate (el, state) {
  2675. var ast = el.children[0];
  2676. if (process.env.NODE_ENV !== 'production' && (
  2677. el.children.length > 1 || ast.type !== 1
  2678. )) {
  2679. state.warn('Inline-template components must have exactly one child element.');
  2680. }
  2681. if (ast.type === 1) {
  2682. var inlineRenderFns = generate(ast, state.options);
  2683. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  2684. }
  2685. }
  2686. function genScopedSlots (
  2687. slots,
  2688. state
  2689. ) {
  2690. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
  2691. return genScopedSlot(key, slots[key], state)
  2692. }).join(',')) + "])")
  2693. }
  2694. function genScopedSlot (
  2695. key,
  2696. el,
  2697. state
  2698. ) {
  2699. if (el.for && !el.forProcessed) {
  2700. return genForScopedSlot(key, el, state)
  2701. }
  2702. return "{key:" + key + ",fn:function(" + (String(el.attrsMap.scope)) + "){" +
  2703. "return " + (el.tag === 'template'
  2704. ? genChildren(el, state) || 'void 0'
  2705. : genElement(el, state)) + "}}"
  2706. }
  2707. function genForScopedSlot (
  2708. key,
  2709. el,
  2710. state
  2711. ) {
  2712. var exp = el.for;
  2713. var alias = el.alias;
  2714. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  2715. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  2716. el.forProcessed = true; // avoid recursion
  2717. return "_l((" + exp + ")," +
  2718. "function(" + alias + iterator1 + iterator2 + "){" +
  2719. "return " + (genScopedSlot(key, el, state)) +
  2720. '})'
  2721. }
  2722. function genChildren (
  2723. el,
  2724. state,
  2725. checkSkip,
  2726. altGenElement,
  2727. altGenNode
  2728. ) {
  2729. var children = el.children;
  2730. if (children.length) {
  2731. var el$1 = children[0];
  2732. // optimize single v-for
  2733. if (children.length === 1 &&
  2734. el$1.for &&
  2735. el$1.tag !== 'template' &&
  2736. el$1.tag !== 'slot'
  2737. ) {
  2738. return (altGenElement || genElement)(el$1, state)
  2739. }
  2740. var normalizationType = checkSkip
  2741. ? getNormalizationType(children, state.maybeComponent)
  2742. : 0;
  2743. var gen = altGenNode || genNode;
  2744. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
  2745. }
  2746. }
  2747. // determine the normalization needed for the children array.
  2748. // 0: no normalization needed
  2749. // 1: simple normalization needed (possible 1-level deep nested array)
  2750. // 2: full normalization needed
  2751. function getNormalizationType (
  2752. children,
  2753. maybeComponent
  2754. ) {
  2755. var res = 0;
  2756. for (var i = 0; i < children.length; i++) {
  2757. var el = children[i];
  2758. if (el.type !== 1) {
  2759. continue
  2760. }
  2761. if (needsNormalization(el) ||
  2762. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  2763. res = 2;
  2764. break
  2765. }
  2766. if (maybeComponent(el) ||
  2767. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  2768. res = 1;
  2769. }
  2770. }
  2771. return res
  2772. }
  2773. function needsNormalization (el) {
  2774. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  2775. }
  2776. function genNode (node, state) {
  2777. if (node.type === 1) {
  2778. return genElement(node, state)
  2779. } if (node.type === 3 && node.isComment) {
  2780. return genComment(node)
  2781. } else {
  2782. return genText(node)
  2783. }
  2784. }
  2785. function genText (text) {
  2786. return ("_v(" + (text.type === 2
  2787. ? text.expression // no need for () because already wrapped in _s()
  2788. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  2789. }
  2790. function genComment (comment) {
  2791. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  2792. }
  2793. function genSlot (el, state) {
  2794. var slotName = el.slotName || '"default"';
  2795. var children = genChildren(el, state);
  2796. var res = "_t(" + slotName + (children ? ("," + children) : '');
  2797. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  2798. var bind$$1 = el.attrsMap['v-bind'];
  2799. if ((attrs || bind$$1) && !children) {
  2800. res += ",null";
  2801. }
  2802. if (attrs) {
  2803. res += "," + attrs;
  2804. }
  2805. if (bind$$1) {
  2806. res += (attrs ? '' : ',null') + "," + bind$$1;
  2807. }
  2808. return res + ')'
  2809. }
  2810. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  2811. function genComponent (
  2812. componentName,
  2813. el,
  2814. state
  2815. ) {
  2816. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  2817. return ("_c(" + componentName + "," + (genData(el, state)) + (children ? ("," + children) : '') + ")")
  2818. }
  2819. function genProps (props) {
  2820. var res = '';
  2821. for (var i = 0; i < props.length; i++) {
  2822. var prop = props[i];
  2823. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  2824. }
  2825. return res.slice(0, -1)
  2826. }
  2827. // #3895, #4268
  2828. function transformSpecialNewlines (text) {
  2829. return text
  2830. .replace(/\u2028/g, '\\u2028')
  2831. .replace(/\u2029/g, '\\u2029')
  2832. }
  2833. /* */
  2834. // these keywords should not appear inside expressions, but operators like
  2835. // typeof, instanceof and in are allowed
  2836. var prohibitedKeywordRE = new RegExp('\\b' + (
  2837. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  2838. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  2839. 'extends,finally,continue,debugger,function,arguments'
  2840. ).split(',').join('\\b|\\b') + '\\b');
  2841. // these unary operators should not be used as property/method names
  2842. var unaryOperatorsRE = new RegExp('\\b' + (
  2843. 'delete,typeof,void'
  2844. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  2845. // check valid identifier for v-for
  2846. var identRE = /[A-Za-z_$][\w$]*/;
  2847. // strip strings in expressions
  2848. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  2849. // detect problematic expressions in a template
  2850. function detectErrors (ast) {
  2851. var errors = [];
  2852. if (ast) {
  2853. checkNode(ast, errors);
  2854. }
  2855. return errors
  2856. }
  2857. function checkNode (node, errors) {
  2858. if (node.type === 1) {
  2859. for (var name in node.attrsMap) {
  2860. if (dirRE.test(name)) {
  2861. var value = node.attrsMap[name];
  2862. if (value) {
  2863. if (name === 'v-for') {
  2864. checkFor(node, ("v-for=\"" + value + "\""), errors);
  2865. } else if (onRE.test(name)) {
  2866. checkEvent(value, (name + "=\"" + value + "\""), errors);
  2867. } else {
  2868. checkExpression(value, (name + "=\"" + value + "\""), errors);
  2869. }
  2870. }
  2871. }
  2872. }
  2873. if (node.children) {
  2874. for (var i = 0; i < node.children.length; i++) {
  2875. checkNode(node.children[i], errors);
  2876. }
  2877. }
  2878. } else if (node.type === 2) {
  2879. checkExpression(node.expression, node.text, errors);
  2880. }
  2881. }
  2882. function checkEvent (exp, text, errors) {
  2883. var stipped = exp.replace(stripStringRE, '');
  2884. var keywordMatch = stipped.match(unaryOperatorsRE);
  2885. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  2886. errors.push(
  2887. "avoid using JavaScript unary operator as property name: " +
  2888. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  2889. );
  2890. }
  2891. checkExpression(exp, text, errors);
  2892. }
  2893. function checkFor (node, text, errors) {
  2894. checkExpression(node.for || '', text, errors);
  2895. checkIdentifier(node.alias, 'v-for alias', text, errors);
  2896. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  2897. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  2898. }
  2899. function checkIdentifier (ident, type, text, errors) {
  2900. if (typeof ident === 'string' && !identRE.test(ident)) {
  2901. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  2902. }
  2903. }
  2904. function checkExpression (exp, text, errors) {
  2905. try {
  2906. new Function(("return " + exp));
  2907. } catch (e) {
  2908. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  2909. if (keywordMatch) {
  2910. errors.push(
  2911. "avoid using JavaScript keyword as property name: " +
  2912. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  2913. );
  2914. } else {
  2915. errors.push(("invalid expression: " + (text.trim())));
  2916. }
  2917. }
  2918. }
  2919. /* */
  2920. function createFunction (code, errors) {
  2921. try {
  2922. return new Function(code)
  2923. } catch (err) {
  2924. errors.push({ err: err, code: code });
  2925. return noop
  2926. }
  2927. }
  2928. function createCompileToFunctionFn (compile) {
  2929. var cache = Object.create(null);
  2930. return function compileToFunctions (
  2931. template,
  2932. options,
  2933. vm
  2934. ) {
  2935. options = options || {};
  2936. /* istanbul ignore if */
  2937. if (process.env.NODE_ENV !== 'production') {
  2938. // detect possible CSP restriction
  2939. try {
  2940. new Function('return 1');
  2941. } catch (e) {
  2942. if (e.toString().match(/unsafe-eval|CSP/)) {
  2943. warn$1(
  2944. 'It seems you are using the standalone build of Vue.js in an ' +
  2945. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  2946. 'The template compiler cannot work in this environment. Consider ' +
  2947. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  2948. 'templates into render functions.'
  2949. );
  2950. }
  2951. }
  2952. }
  2953. // check cache
  2954. var key = options.delimiters
  2955. ? String(options.delimiters) + template
  2956. : template;
  2957. if (cache[key]) {
  2958. return cache[key]
  2959. }
  2960. // compile
  2961. var compiled = compile(template, options);
  2962. // check compilation errors/tips
  2963. if (process.env.NODE_ENV !== 'production') {
  2964. if (compiled.errors && compiled.errors.length) {
  2965. warn$1(
  2966. "Error compiling template:\n\n" + template + "\n\n" +
  2967. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  2968. vm
  2969. );
  2970. }
  2971. if (compiled.tips && compiled.tips.length) {
  2972. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  2973. }
  2974. }
  2975. // turn code into functions
  2976. var res = {};
  2977. var fnGenErrors = [];
  2978. res.render = createFunction(compiled.render, fnGenErrors);
  2979. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  2980. return createFunction(code, fnGenErrors)
  2981. });
  2982. // check function generation errors.
  2983. // this should only happen if there is a bug in the compiler itself.
  2984. // mostly for codegen development use
  2985. /* istanbul ignore if */
  2986. if (process.env.NODE_ENV !== 'production') {
  2987. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  2988. warn$1(
  2989. "Failed to generate render function:\n\n" +
  2990. fnGenErrors.map(function (ref) {
  2991. var err = ref.err;
  2992. var code = ref.code;
  2993. return ((err.toString()) + " in\n\n" + code + "\n");
  2994. }).join('\n'),
  2995. vm
  2996. );
  2997. }
  2998. }
  2999. return (cache[key] = res)
  3000. }
  3001. }
  3002. /* */
  3003. function createCompilerCreator (baseCompile) {
  3004. return function createCompiler (baseOptions) {
  3005. function compile (
  3006. template,
  3007. options
  3008. ) {
  3009. var finalOptions = Object.create(baseOptions);
  3010. var errors = [];
  3011. var tips = [];
  3012. finalOptions.warn = function (msg, tip) {
  3013. (tip ? tips : errors).push(msg);
  3014. };
  3015. if (options) {
  3016. // merge custom modules
  3017. if (options.modules) {
  3018. finalOptions.modules =
  3019. (baseOptions.modules || []).concat(options.modules);
  3020. }
  3021. // merge custom directives
  3022. if (options.directives) {
  3023. finalOptions.directives = extend(
  3024. Object.create(baseOptions.directives),
  3025. options.directives
  3026. );
  3027. }
  3028. // copy other options
  3029. for (var key in options) {
  3030. if (key !== 'modules' && key !== 'directives') {
  3031. finalOptions[key] = options[key];
  3032. }
  3033. }
  3034. }
  3035. var compiled = baseCompile(template, finalOptions);
  3036. if (process.env.NODE_ENV !== 'production') {
  3037. errors.push.apply(errors, detectErrors(compiled.ast));
  3038. }
  3039. compiled.errors = errors;
  3040. compiled.tips = tips;
  3041. return compiled
  3042. }
  3043. return {
  3044. compile: compile,
  3045. compileToFunctions: createCompileToFunctionFn(compile)
  3046. }
  3047. }
  3048. }
  3049. /* */
  3050. // `createCompilerCreator` allows creating compilers that use alternative
  3051. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  3052. // Here we just export a default compiler using the default parts.
  3053. var createCompiler = createCompilerCreator(function baseCompile (
  3054. template,
  3055. options
  3056. ) {
  3057. var ast = parse(template.trim(), options);
  3058. optimize(ast, options);
  3059. var code = generate(ast, options);
  3060. return {
  3061. ast: ast,
  3062. render: code.render,
  3063. staticRenderFns: code.staticRenderFns
  3064. }
  3065. });
  3066. /* */
  3067. function transformNode (el, options) {
  3068. var warn = options.warn || baseWarn;
  3069. var staticClass = getAndRemoveAttr(el, 'class');
  3070. var ref = parseStaticClass(staticClass, options);
  3071. var dynamic = ref.dynamic;
  3072. var classResult = ref.classResult;
  3073. if (process.env.NODE_ENV !== 'production' && dynamic && staticClass) {
  3074. warn(
  3075. "class=\"" + staticClass + "\": " +
  3076. 'Interpolation inside attributes has been deprecated. ' +
  3077. 'Use v-bind or the colon shorthand instead.'
  3078. );
  3079. }
  3080. if (!dynamic && classResult) {
  3081. el.staticClass = classResult;
  3082. }
  3083. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  3084. if (classBinding) {
  3085. el.classBinding = classBinding;
  3086. } else if (dynamic) {
  3087. el.classBinding = classResult;
  3088. }
  3089. }
  3090. function genData$1 (el) {
  3091. var data = '';
  3092. if (el.staticClass) {
  3093. data += "staticClass:" + (el.staticClass) + ",";
  3094. }
  3095. if (el.classBinding) {
  3096. data += "class:" + (el.classBinding) + ",";
  3097. }
  3098. return data
  3099. }
  3100. function parseStaticClass (staticClass, options) {
  3101. // "a b c" -> ["a", "b", "c"] => staticClass: ["a", "b", "c"]
  3102. // "a {{x}} c" -> ["a", x, "c"] => classBinding: '["a", x, "c"]'
  3103. var dynamic = false;
  3104. var classResult = '';
  3105. if (staticClass) {
  3106. var classList = staticClass.trim().split(' ').map(function (name) {
  3107. var result = parseText(name, options.delimiters);
  3108. if (result) {
  3109. dynamic = true;
  3110. return result
  3111. }
  3112. return JSON.stringify(name)
  3113. });
  3114. if (classList.length) {
  3115. classResult = '[' + classList.join(',') + ']';
  3116. }
  3117. }
  3118. return { dynamic: dynamic, classResult: classResult }
  3119. }
  3120. var klass = {
  3121. staticKeys: ['staticClass'],
  3122. transformNode: transformNode,
  3123. genData: genData$1
  3124. };
  3125. /* */
  3126. var normalize = cached(camelize);
  3127. function transformNode$1 (el, options) {
  3128. var warn = options.warn || baseWarn;
  3129. var staticStyle = getAndRemoveAttr(el, 'style');
  3130. var ref = parseStaticStyle(staticStyle, options);
  3131. var dynamic = ref.dynamic;
  3132. var styleResult = ref.styleResult;
  3133. if (process.env.NODE_ENV !== 'production' && dynamic) {
  3134. warn(
  3135. "style=\"" + (String(staticStyle)) + "\": " +
  3136. 'Interpolation inside attributes has been deprecated. ' +
  3137. 'Use v-bind or the colon shorthand instead.'
  3138. );
  3139. }
  3140. if (!dynamic && styleResult) {
  3141. el.staticStyle = styleResult;
  3142. }
  3143. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  3144. if (styleBinding) {
  3145. el.styleBinding = styleBinding;
  3146. } else if (dynamic) {
  3147. el.styleBinding = styleResult;
  3148. }
  3149. }
  3150. function genData$2 (el) {
  3151. var data = '';
  3152. if (el.staticStyle) {
  3153. data += "staticStyle:" + (el.staticStyle) + ",";
  3154. }
  3155. if (el.styleBinding) {
  3156. data += "style:" + (el.styleBinding) + ",";
  3157. }
  3158. return data
  3159. }
  3160. function parseStaticStyle (staticStyle, options) {
  3161. // "width: 200px; height: 200px;" -> {width: 200, height: 200}
  3162. // "width: 200px; height: {{y}}" -> {width: 200, height: y}
  3163. var dynamic = false;
  3164. var styleResult = '';
  3165. if (staticStyle) {
  3166. var styleList = staticStyle.trim().split(';').map(function (style) {
  3167. var result = style.trim().split(':');
  3168. if (result.length !== 2) {
  3169. return
  3170. }
  3171. var key = normalize(result[0].trim());
  3172. var value = result[1].trim();
  3173. var dynamicValue = parseText(value, options.delimiters);
  3174. if (dynamicValue) {
  3175. dynamic = true;
  3176. return key + ':' + dynamicValue
  3177. }
  3178. return key + ':' + JSON.stringify(value)
  3179. }).filter(function (result) { return result; });
  3180. if (styleList.length) {
  3181. styleResult = '{' + styleList.join(',') + '}';
  3182. }
  3183. }
  3184. return { dynamic: dynamic, styleResult: styleResult }
  3185. }
  3186. var style = {
  3187. staticKeys: ['staticStyle'],
  3188. transformNode: transformNode$1,
  3189. genData: genData$2
  3190. };
  3191. /* */
  3192. var normalize$1 = cached(camelize);
  3193. function normalizeKeyName (str) {
  3194. if (str.match(/^v\-/)) {
  3195. return str.replace(/(v-[a-z\-]+\:)([a-z\-]+)$/i, function ($, directive, prop) {
  3196. return directive + normalize$1(prop)
  3197. })
  3198. }
  3199. return normalize$1(str)
  3200. }
  3201. function transformNode$2 (el, options) {
  3202. if (Array.isArray(el.attrsList)) {
  3203. el.attrsList.forEach(function (attr) {
  3204. if (attr.name && attr.name.match(/\-/)) {
  3205. var realName = normalizeKeyName(attr.name);
  3206. if (el.attrsMap) {
  3207. el.attrsMap[realName] = el.attrsMap[attr.name];
  3208. delete el.attrsMap[attr.name];
  3209. }
  3210. attr.name = realName;
  3211. }
  3212. });
  3213. }
  3214. }
  3215. var props = {
  3216. transformNode: transformNode$2
  3217. };
  3218. /* */
  3219. function preTransformNode (el, options) {
  3220. if (el.tag === 'cell' && !el.attrsList.some(function (item) { return item.name === 'append'; })) {
  3221. el.attrsMap.append = 'tree';
  3222. el.attrsList.push({ name: 'append', value: 'tree' });
  3223. }
  3224. if (el.attrsMap.append === 'tree') {
  3225. el.appendAsTree = true;
  3226. }
  3227. }
  3228. function genData$3 (el) {
  3229. return el.appendAsTree ? "appendAsTree:true," : ''
  3230. }
  3231. var append = {
  3232. staticKeys: ['appendAsTree'],
  3233. preTransformNode: preTransformNode,
  3234. genData: genData$3
  3235. };
  3236. var modules = [
  3237. klass,
  3238. style,
  3239. props,
  3240. append
  3241. ];
  3242. /* */
  3243. function model (
  3244. el,
  3245. dir,
  3246. _warn
  3247. ) {
  3248. if (el.tag === 'input' || el.tag === 'textarea') {
  3249. genDefaultModel(el, dir.value, dir.modifiers);
  3250. } else {
  3251. genComponentModel(el, dir.value, dir.modifiers);
  3252. }
  3253. }
  3254. function genDefaultModel (
  3255. el,
  3256. value,
  3257. modifiers
  3258. ) {
  3259. var ref = modifiers || {};
  3260. var lazy = ref.lazy;
  3261. var trim = ref.trim;
  3262. var number = ref.number;
  3263. var event = lazy ? 'change' : 'input';
  3264. var valueExpression = "$event.target.attr.value" + (trim ? '.trim()' : '');
  3265. if (number) {
  3266. valueExpression = "_n(" + valueExpression + ")";
  3267. }
  3268. var code = genAssignmentCode(value, valueExpression);
  3269. addAttr(el, 'value', ("(" + value + ")"));
  3270. addHandler(el, event, code, null, true);
  3271. }
  3272. var directives = {
  3273. model: model
  3274. };
  3275. /* globals renderer */
  3276. var isReservedTag = makeMap(
  3277. 'template,script,style,element,content,slot,link,meta,svg,view,' +
  3278. 'a,div,img,image,text,span,richtext,input,switch,textarea,spinner,select,' +
  3279. 'slider,slider-neighbor,indicator,trisition,trisition-group,canvas,' +
  3280. 'list,cell,header,loading,loading-indicator,refresh,scrollable,scroller,' +
  3281. 'video,web,embed,tabbar,tabheader,datepicker,timepicker,marquee,countdown',
  3282. true
  3283. );
  3284. // Elements that you can, intentionally, leave open (and which close themselves)
  3285. // more flexable than web
  3286. var canBeLeftOpenTag$1 = makeMap(
  3287. 'web,spinner,switch,video,textarea,canvas,' +
  3288. 'indicator,marquee,countdown',
  3289. true
  3290. );
  3291. var isUnaryTag$1 = makeMap(
  3292. 'embed,img,image,input,link,meta',
  3293. true
  3294. );
  3295. function mustUseProp () { /* console.log('mustUseProp') */ }
  3296. function getTagNamespace () { /* console.log('getTagNamespace') */ }
  3297. /* */
  3298. var baseOptions = {
  3299. modules: modules,
  3300. directives: directives,
  3301. isUnaryTag: isUnaryTag$1,
  3302. mustUseProp: mustUseProp,
  3303. canBeLeftOpenTag: canBeLeftOpenTag$1,
  3304. isReservedTag: isReservedTag,
  3305. getTagNamespace: getTagNamespace,
  3306. preserveWhitespace: false,
  3307. staticKeys: genStaticKeys(modules)
  3308. };
  3309. var ref = createCompiler(baseOptions);
  3310. var compile = ref.compile;
  3311. exports.compile = compile;