build.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var he = require('he');
  4. /* */
  5. /**
  6. * Convert a value to a string that is actually rendered.
  7. */
  8. /**
  9. * Convert a input value to a number for persistence.
  10. * If the conversion fails, return original string.
  11. */
  12. /**
  13. * Make a map and return a function for checking if a key
  14. * is in that map.
  15. */
  16. function makeMap (
  17. str,
  18. expectsLowerCase
  19. ) {
  20. var map = Object.create(null);
  21. var list = str.split(',');
  22. for (var i = 0; i < list.length; i++) {
  23. map[list[i]] = true;
  24. }
  25. return expectsLowerCase
  26. ? function (val) { return map[val.toLowerCase()]; }
  27. : function (val) { return map[val]; }
  28. }
  29. /**
  30. * Check if a tag is a built-in tag.
  31. */
  32. var isBuiltInTag = makeMap('slot,component', true);
  33. /**
  34. * Remove an item from an array
  35. */
  36. /**
  37. * Check if value is primitive
  38. */
  39. /**
  40. * Create a cached version of a pure function.
  41. */
  42. function cached (fn) {
  43. var cache = Object.create(null);
  44. return (function cachedFn (str) {
  45. var hit = cache[str];
  46. return hit || (cache[str] = fn(str))
  47. })
  48. }
  49. /**
  50. * Camelize a hyphen-delimited string.
  51. */
  52. var camelizeRE = /-(\w)/g;
  53. var camelize = cached(function (str) {
  54. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  55. });
  56. /**
  57. * Capitalize a string.
  58. */
  59. /**
  60. * Simple bind, faster than native
  61. */
  62. /**
  63. * Convert an Array-like object to a real Array.
  64. */
  65. /**
  66. * Mix properties into target object.
  67. */
  68. function extend (to, _from) {
  69. for (var key in _from) {
  70. to[key] = _from[key];
  71. }
  72. return to
  73. }
  74. /**
  75. * Quick object check - this is primarily used to tell
  76. * Objects from primitive values when we know the value
  77. * is a JSON-compliant type.
  78. */
  79. /**
  80. * Merge an Array of Objects into a single Object.
  81. */
  82. /**
  83. * Perform no operation.
  84. */
  85. function noop () {}
  86. /**
  87. * Always return false.
  88. */
  89. var no = function () { return false; };
  90. /**
  91. * Return same value
  92. */
  93. var identity = function (_) { return _; };
  94. /**
  95. * Generate a static keys string from compiler modules.
  96. */
  97. function genStaticKeys (modules) {
  98. return modules.reduce(function (keys, m) {
  99. return keys.concat(m.staticKeys || [])
  100. }, []).join(',')
  101. }
  102. /**
  103. * Check if two values are loosely equal - that is,
  104. * if they are plain objects, do they have the same shape?
  105. */
  106. /**
  107. * Ensure a function is called only once.
  108. */
  109. /* */
  110. var isUnaryTag = makeMap(
  111. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  112. 'link,meta,param,source,track,wbr'
  113. );
  114. // Elements that you can, intentionally, leave open
  115. // (and which close themselves)
  116. var canBeLeftOpenTag = makeMap(
  117. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  118. );
  119. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  120. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  121. var isNonPhrasingTag = makeMap(
  122. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  123. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  124. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  125. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  126. 'title,tr,track'
  127. );
  128. /**
  129. * Not type-checking this file because it's mostly vendor code.
  130. */
  131. /*!
  132. * HTML Parser By John Resig (ejohn.org)
  133. * Modified by Juriy "kangax" Zaytsev
  134. * Original code by Erik Arvidsson, Mozilla Public License
  135. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  136. */
  137. // Regular Expressions for parsing tags and attributes
  138. var singleAttrIdentifier = /([^\s"'<>/=]+)/;
  139. var singleAttrAssign = /(?:=)/;
  140. var singleAttrValues = [
  141. // attr value double quotes
  142. /"([^"]*)"+/.source,
  143. // attr value, single quotes
  144. /'([^']*)'+/.source,
  145. // attr value, no quotes
  146. /([^\s"'=<>`]+)/.source
  147. ];
  148. var attribute = new RegExp(
  149. '^\\s*' + singleAttrIdentifier.source +
  150. '(?:\\s*(' + singleAttrAssign.source + ')' +
  151. '\\s*(?:' + singleAttrValues.join('|') + '))?'
  152. );
  153. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  154. // but for Vue templates we can enforce a simple charset
  155. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  156. var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
  157. var startTagOpen = new RegExp('^<' + qnameCapture);
  158. var startTagClose = /^\s*(\/?)>/;
  159. var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
  160. var doctype = /^<!DOCTYPE [^>]+>/i;
  161. var comment = /^<!--/;
  162. var conditionalComment = /^<!\[/;
  163. var IS_REGEX_CAPTURING_BROKEN = false;
  164. 'x'.replace(/x(.)?/g, function (m, g) {
  165. IS_REGEX_CAPTURING_BROKEN = g === '';
  166. });
  167. // Special Elements (can contain anything)
  168. var isPlainTextElement = makeMap('script,style,textarea', true);
  169. var reCache = {};
  170. var decodingMap = {
  171. '&lt;': '<',
  172. '&gt;': '>',
  173. '&quot;': '"',
  174. '&amp;': '&',
  175. '&#10;': '\n'
  176. };
  177. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  178. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
  179. function decodeAttr (value, shouldDecodeNewlines) {
  180. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  181. return value.replace(re, function (match) { return decodingMap[match]; })
  182. }
  183. function parseHTML (html, options) {
  184. var stack = [];
  185. var expectHTML = options.expectHTML;
  186. var isUnaryTag$$1 = options.isUnaryTag || no;
  187. var index = 0;
  188. var last, lastTag;
  189. while (html) {
  190. last = html;
  191. // Make sure we're not in a plaintext content element like script/style
  192. if (!lastTag || !isPlainTextElement(lastTag)) {
  193. var textEnd = html.indexOf('<');
  194. if (textEnd === 0) {
  195. // Comment:
  196. if (comment.test(html)) {
  197. var commentEnd = html.indexOf('-->');
  198. if (commentEnd >= 0) {
  199. advance(commentEnd + 3);
  200. continue
  201. }
  202. }
  203. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  204. if (conditionalComment.test(html)) {
  205. var conditionalEnd = html.indexOf(']>');
  206. if (conditionalEnd >= 0) {
  207. advance(conditionalEnd + 2);
  208. continue
  209. }
  210. }
  211. // Doctype:
  212. var doctypeMatch = html.match(doctype);
  213. if (doctypeMatch) {
  214. advance(doctypeMatch[0].length);
  215. continue
  216. }
  217. // End tag:
  218. var endTagMatch = html.match(endTag);
  219. if (endTagMatch) {
  220. var curIndex = index;
  221. advance(endTagMatch[0].length);
  222. parseEndTag(endTagMatch[1], curIndex, index);
  223. continue
  224. }
  225. // Start tag:
  226. var startTagMatch = parseStartTag();
  227. if (startTagMatch) {
  228. handleStartTag(startTagMatch);
  229. continue
  230. }
  231. }
  232. var text = (void 0), rest$1 = (void 0), next = (void 0);
  233. if (textEnd >= 0) {
  234. rest$1 = html.slice(textEnd);
  235. while (
  236. !endTag.test(rest$1) &&
  237. !startTagOpen.test(rest$1) &&
  238. !comment.test(rest$1) &&
  239. !conditionalComment.test(rest$1)
  240. ) {
  241. // < in plain text, be forgiving and treat it as text
  242. next = rest$1.indexOf('<', 1);
  243. if (next < 0) { break }
  244. textEnd += next;
  245. rest$1 = html.slice(textEnd);
  246. }
  247. text = html.substring(0, textEnd);
  248. advance(textEnd);
  249. }
  250. if (textEnd < 0) {
  251. text = html;
  252. html = '';
  253. }
  254. if (options.chars && text) {
  255. options.chars(text);
  256. }
  257. } else {
  258. var stackedTag = lastTag.toLowerCase();
  259. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  260. var endTagLength = 0;
  261. var rest = html.replace(reStackedTag, function (all, text, endTag) {
  262. endTagLength = endTag.length;
  263. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  264. text = text
  265. .replace(/<!--([\s\S]*?)-->/g, '$1')
  266. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  267. }
  268. if (options.chars) {
  269. options.chars(text);
  270. }
  271. return ''
  272. });
  273. index += html.length - rest.length;
  274. html = rest;
  275. parseEndTag(stackedTag, index - endTagLength, index);
  276. }
  277. if (html === last) {
  278. options.chars && options.chars(html);
  279. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  280. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  281. }
  282. break
  283. }
  284. }
  285. // Clean up any remaining tags
  286. parseEndTag();
  287. function advance (n) {
  288. index += n;
  289. html = html.substring(n);
  290. }
  291. function parseStartTag () {
  292. var start = html.match(startTagOpen);
  293. if (start) {
  294. var match = {
  295. tagName: start[1],
  296. attrs: [],
  297. start: index
  298. };
  299. advance(start[0].length);
  300. var end, attr;
  301. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  302. advance(attr[0].length);
  303. match.attrs.push(attr);
  304. }
  305. if (end) {
  306. match.unarySlash = end[1];
  307. advance(end[0].length);
  308. match.end = index;
  309. return match
  310. }
  311. }
  312. }
  313. function handleStartTag (match) {
  314. var tagName = match.tagName;
  315. var unarySlash = match.unarySlash;
  316. if (expectHTML) {
  317. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  318. parseEndTag(lastTag);
  319. }
  320. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  321. parseEndTag(tagName);
  322. }
  323. }
  324. var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
  325. var l = match.attrs.length;
  326. var attrs = new Array(l);
  327. for (var i = 0; i < l; i++) {
  328. var args = match.attrs[i];
  329. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  330. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  331. if (args[3] === '') { delete args[3]; }
  332. if (args[4] === '') { delete args[4]; }
  333. if (args[5] === '') { delete args[5]; }
  334. }
  335. var value = args[3] || args[4] || args[5] || '';
  336. attrs[i] = {
  337. name: args[1],
  338. value: decodeAttr(
  339. value,
  340. options.shouldDecodeNewlines
  341. )
  342. };
  343. }
  344. if (!unary) {
  345. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  346. lastTag = tagName;
  347. }
  348. if (options.start) {
  349. options.start(tagName, attrs, unary, match.start, match.end);
  350. }
  351. }
  352. function parseEndTag (tagName, start, end) {
  353. var pos, lowerCasedTagName;
  354. if (start == null) { start = index; }
  355. if (end == null) { end = index; }
  356. if (tagName) {
  357. lowerCasedTagName = tagName.toLowerCase();
  358. }
  359. // Find the closest opened tag of the same type
  360. if (tagName) {
  361. for (pos = stack.length - 1; pos >= 0; pos--) {
  362. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  363. break
  364. }
  365. }
  366. } else {
  367. // If no tag name is provided, clean shop
  368. pos = 0;
  369. }
  370. if (pos >= 0) {
  371. // Close all the open elements, up the stack
  372. for (var i = stack.length - 1; i >= pos; i--) {
  373. if (process.env.NODE_ENV !== 'production' &&
  374. (i > pos || !tagName) &&
  375. options.warn) {
  376. options.warn(
  377. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  378. );
  379. }
  380. if (options.end) {
  381. options.end(stack[i].tag, start, end);
  382. }
  383. }
  384. // Remove the open elements from the stack
  385. stack.length = pos;
  386. lastTag = pos && stack[pos - 1].tag;
  387. } else if (lowerCasedTagName === 'br') {
  388. if (options.start) {
  389. options.start(tagName, [], true, start, end);
  390. }
  391. } else if (lowerCasedTagName === 'p') {
  392. if (options.start) {
  393. options.start(tagName, [], false, start, end);
  394. }
  395. if (options.end) {
  396. options.end(tagName, start, end);
  397. }
  398. }
  399. }
  400. }
  401. /* */
  402. var validDivisionCharRE = /[\w).+\-_$\]]/;
  403. function parseFilters (exp) {
  404. var inSingle = false;
  405. var inDouble = false;
  406. var inTemplateString = false;
  407. var inRegex = false;
  408. var curly = 0;
  409. var square = 0;
  410. var paren = 0;
  411. var lastFilterIndex = 0;
  412. var c, prev, i, expression, filters;
  413. for (i = 0; i < exp.length; i++) {
  414. prev = c;
  415. c = exp.charCodeAt(i);
  416. if (inSingle) {
  417. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  418. } else if (inDouble) {
  419. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  420. } else if (inTemplateString) {
  421. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  422. } else if (inRegex) {
  423. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  424. } else if (
  425. c === 0x7C && // pipe
  426. exp.charCodeAt(i + 1) !== 0x7C &&
  427. exp.charCodeAt(i - 1) !== 0x7C &&
  428. !curly && !square && !paren
  429. ) {
  430. if (expression === undefined) {
  431. // first filter, end of expression
  432. lastFilterIndex = i + 1;
  433. expression = exp.slice(0, i).trim();
  434. } else {
  435. pushFilter();
  436. }
  437. } else {
  438. switch (c) {
  439. case 0x22: inDouble = true; break // "
  440. case 0x27: inSingle = true; break // '
  441. case 0x60: inTemplateString = true; break // `
  442. case 0x28: paren++; break // (
  443. case 0x29: paren--; break // )
  444. case 0x5B: square++; break // [
  445. case 0x5D: square--; break // ]
  446. case 0x7B: curly++; break // {
  447. case 0x7D: curly--; break // }
  448. }
  449. if (c === 0x2f) { // /
  450. var j = i - 1;
  451. var p = (void 0);
  452. // find first non-whitespace prev char
  453. for (; j >= 0; j--) {
  454. p = exp.charAt(j);
  455. if (p !== ' ') { break }
  456. }
  457. if (!p || !validDivisionCharRE.test(p)) {
  458. inRegex = true;
  459. }
  460. }
  461. }
  462. }
  463. if (expression === undefined) {
  464. expression = exp.slice(0, i).trim();
  465. } else if (lastFilterIndex !== 0) {
  466. pushFilter();
  467. }
  468. function pushFilter () {
  469. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  470. lastFilterIndex = i + 1;
  471. }
  472. if (filters) {
  473. for (i = 0; i < filters.length; i++) {
  474. expression = wrapFilter(expression, filters[i]);
  475. }
  476. }
  477. return expression
  478. }
  479. function wrapFilter (exp, filter) {
  480. var i = filter.indexOf('(');
  481. if (i < 0) {
  482. // _f: resolveFilter
  483. return ("_f(\"" + filter + "\")(" + exp + ")")
  484. } else {
  485. var name = filter.slice(0, i);
  486. var args = filter.slice(i + 1);
  487. return ("_f(\"" + name + "\")(" + exp + "," + args)
  488. }
  489. }
  490. /* */
  491. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  492. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  493. var buildRegex = cached(function (delimiters) {
  494. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  495. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  496. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  497. });
  498. function parseText (
  499. text,
  500. delimiters
  501. ) {
  502. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  503. if (!tagRE.test(text)) {
  504. return
  505. }
  506. var tokens = [];
  507. var lastIndex = tagRE.lastIndex = 0;
  508. var match, index;
  509. while ((match = tagRE.exec(text))) {
  510. index = match.index;
  511. // push text token
  512. if (index > lastIndex) {
  513. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  514. }
  515. // tag token
  516. var exp = parseFilters(match[1].trim());
  517. tokens.push(("_s(" + exp + ")"));
  518. lastIndex = index + match[0].length;
  519. }
  520. if (lastIndex < text.length) {
  521. tokens.push(JSON.stringify(text.slice(lastIndex)));
  522. }
  523. return tokens.join('+')
  524. }
  525. /* */
  526. /* globals MutationObserver */
  527. // can we use __proto__?
  528. // Browser environment sniffing
  529. var inBrowser = typeof window !== 'undefined';
  530. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  531. var isIE = UA && /msie|trident/.test(UA);
  532. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  533. var isEdge = UA && UA.indexOf('edge/') > 0;
  534. var isAndroid = UA && UA.indexOf('android') > 0;
  535. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  536. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  537. // this needs to be lazy-evaled because vue may be required before
  538. // vue-server-renderer can set VUE_ENV
  539. var _isServer;
  540. var isServerRendering = function () {
  541. if (_isServer === undefined) {
  542. /* istanbul ignore if */
  543. if (!inBrowser && typeof global !== 'undefined') {
  544. // detect presence of vue-server-renderer and avoid
  545. // Webpack shimming the process
  546. _isServer = global['process'].env.VUE_ENV === 'server';
  547. } else {
  548. _isServer = false;
  549. }
  550. }
  551. return _isServer
  552. };
  553. // detect devtools
  554. /* istanbul ignore next */
  555. function isNative (Ctor) {
  556. return /native code/.test(Ctor.toString())
  557. }
  558. var hasSymbol =
  559. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  560. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  561. /**
  562. * Defer a task to execute it asynchronously.
  563. */
  564. var nextTick = (function () {
  565. var callbacks = [];
  566. var pending = false;
  567. var timerFunc;
  568. function nextTickHandler () {
  569. pending = false;
  570. var copies = callbacks.slice(0);
  571. callbacks.length = 0;
  572. for (var i = 0; i < copies.length; i++) {
  573. copies[i]();
  574. }
  575. }
  576. // the nextTick behavior leverages the microtask queue, which can be accessed
  577. // via either native Promise.then or MutationObserver.
  578. // MutationObserver has wider support, however it is seriously bugged in
  579. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  580. // completely stops working after triggering a few times... so, if native
  581. // Promise is available, we will use it:
  582. /* istanbul ignore if */
  583. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  584. var p = Promise.resolve();
  585. var logError = function (err) { console.error(err); };
  586. timerFunc = function () {
  587. p.then(nextTickHandler).catch(logError);
  588. // in problematic UIWebViews, Promise.then doesn't completely break, but
  589. // it can get stuck in a weird state where callbacks are pushed into the
  590. // microtask queue but the queue isn't being flushed, until the browser
  591. // needs to do some other work, e.g. handle a timer. Therefore we can
  592. // "force" the microtask queue to be flushed by adding an empty timer.
  593. if (isIOS) { setTimeout(noop); }
  594. };
  595. } else if (typeof MutationObserver !== 'undefined' && (
  596. isNative(MutationObserver) ||
  597. // PhantomJS and iOS 7.x
  598. MutationObserver.toString() === '[object MutationObserverConstructor]'
  599. )) {
  600. // use MutationObserver where native Promise is not available,
  601. // e.g. PhantomJS IE11, iOS7, Android 4.4
  602. var counter = 1;
  603. var observer = new MutationObserver(nextTickHandler);
  604. var textNode = document.createTextNode(String(counter));
  605. observer.observe(textNode, {
  606. characterData: true
  607. });
  608. timerFunc = function () {
  609. counter = (counter + 1) % 2;
  610. textNode.data = String(counter);
  611. };
  612. } else {
  613. // fallback to setTimeout
  614. /* istanbul ignore next */
  615. timerFunc = function () {
  616. setTimeout(nextTickHandler, 0);
  617. };
  618. }
  619. return function queueNextTick (cb, ctx) {
  620. var _resolve;
  621. callbacks.push(function () {
  622. if (cb) { cb.call(ctx); }
  623. if (_resolve) { _resolve(ctx); }
  624. });
  625. if (!pending) {
  626. pending = true;
  627. timerFunc();
  628. }
  629. if (!cb && typeof Promise !== 'undefined') {
  630. return new Promise(function (resolve) {
  631. _resolve = resolve;
  632. })
  633. }
  634. }
  635. })();
  636. var _Set;
  637. /* istanbul ignore if */
  638. if (typeof Set !== 'undefined' && isNative(Set)) {
  639. // use native Set when available.
  640. _Set = Set;
  641. } else {
  642. // a non-standard Set polyfill that only works with primitive keys.
  643. _Set = (function () {
  644. function Set () {
  645. this.set = Object.create(null);
  646. }
  647. Set.prototype.has = function has (key) {
  648. return this.set[key] === true
  649. };
  650. Set.prototype.add = function add (key) {
  651. this.set[key] = true;
  652. };
  653. Set.prototype.clear = function clear () {
  654. this.set = Object.create(null);
  655. };
  656. return Set;
  657. }());
  658. }
  659. /* */
  660. function baseWarn (msg) {
  661. console.error(("[Vue compiler]: " + msg));
  662. }
  663. function pluckModuleFunction (
  664. modules,
  665. key
  666. ) {
  667. return modules
  668. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  669. : []
  670. }
  671. function addProp (el, name, value) {
  672. (el.props || (el.props = [])).push({ name: name, value: value });
  673. }
  674. function addAttr (el, name, value) {
  675. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  676. }
  677. function addDirective (
  678. el,
  679. name,
  680. rawName,
  681. value,
  682. arg,
  683. modifiers
  684. ) {
  685. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  686. }
  687. function addHandler (
  688. el,
  689. name,
  690. value,
  691. modifiers,
  692. important
  693. ) {
  694. // check capture modifier
  695. if (modifiers && modifiers.capture) {
  696. delete modifiers.capture;
  697. name = '!' + name; // mark the event as captured
  698. }
  699. if (modifiers && modifiers.once) {
  700. delete modifiers.once;
  701. name = '~' + name; // mark the event as once
  702. }
  703. var events;
  704. if (modifiers && modifiers.native) {
  705. delete modifiers.native;
  706. events = el.nativeEvents || (el.nativeEvents = {});
  707. } else {
  708. events = el.events || (el.events = {});
  709. }
  710. var newHandler = { value: value, modifiers: modifiers };
  711. var handlers = events[name];
  712. /* istanbul ignore if */
  713. if (Array.isArray(handlers)) {
  714. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  715. } else if (handlers) {
  716. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  717. } else {
  718. events[name] = newHandler;
  719. }
  720. }
  721. function getBindingAttr (
  722. el,
  723. name,
  724. getStatic
  725. ) {
  726. var dynamicValue =
  727. getAndRemoveAttr(el, ':' + name) ||
  728. getAndRemoveAttr(el, 'v-bind:' + name);
  729. if (dynamicValue != null) {
  730. return parseFilters(dynamicValue)
  731. } else if (getStatic !== false) {
  732. var staticValue = getAndRemoveAttr(el, name);
  733. if (staticValue != null) {
  734. return JSON.stringify(staticValue)
  735. }
  736. }
  737. }
  738. function getAndRemoveAttr (el, name) {
  739. var val;
  740. if ((val = el.attrsMap[name]) != null) {
  741. var list = el.attrsList;
  742. for (var i = 0, l = list.length; i < l; i++) {
  743. if (list[i].name === name) {
  744. list.splice(i, 1);
  745. break
  746. }
  747. }
  748. }
  749. return val
  750. }
  751. /* */
  752. var onRE = /^@|^v-on:/;
  753. var dirRE = /^v-|^@|^:/;
  754. var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
  755. var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
  756. var argRE = /:(.*)$/;
  757. var bindRE = /^:|^v-bind:/;
  758. var modifierRE = /\.[^.]+/g;
  759. var decodeHTMLCached = cached(he.decode);
  760. // configurable state
  761. var warn;
  762. var delimiters;
  763. var transforms;
  764. var preTransforms;
  765. var postTransforms;
  766. var platformIsPreTag;
  767. var platformMustUseProp;
  768. var platformGetTagNamespace;
  769. /**
  770. * Convert HTML string to AST.
  771. */
  772. function parse (
  773. template,
  774. options
  775. ) {
  776. warn = options.warn || baseWarn;
  777. platformGetTagNamespace = options.getTagNamespace || no;
  778. platformMustUseProp = options.mustUseProp || no;
  779. platformIsPreTag = options.isPreTag || no;
  780. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  781. transforms = pluckModuleFunction(options.modules, 'transformNode');
  782. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  783. delimiters = options.delimiters;
  784. var stack = [];
  785. var preserveWhitespace = options.preserveWhitespace !== false;
  786. var root;
  787. var currentParent;
  788. var inVPre = false;
  789. var inPre = false;
  790. var warned = false;
  791. function warnOnce (msg) {
  792. if (!warned) {
  793. warned = true;
  794. warn(msg);
  795. }
  796. }
  797. function endPre (element) {
  798. // check pre state
  799. if (element.pre) {
  800. inVPre = false;
  801. }
  802. if (platformIsPreTag(element.tag)) {
  803. inPre = false;
  804. }
  805. }
  806. parseHTML(template, {
  807. warn: warn,
  808. expectHTML: options.expectHTML,
  809. isUnaryTag: options.isUnaryTag,
  810. shouldDecodeNewlines: options.shouldDecodeNewlines,
  811. start: function start (tag, attrs, unary) {
  812. // check namespace.
  813. // inherit parent ns if there is one
  814. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  815. // handle IE svg bug
  816. /* istanbul ignore if */
  817. if (isIE && ns === 'svg') {
  818. attrs = guardIESVGBug(attrs);
  819. }
  820. var element = {
  821. type: 1,
  822. tag: tag,
  823. attrsList: attrs,
  824. attrsMap: makeAttrsMap(attrs),
  825. parent: currentParent,
  826. children: []
  827. };
  828. if (ns) {
  829. element.ns = ns;
  830. }
  831. if (isForbiddenTag(element) && !isServerRendering()) {
  832. element.forbidden = true;
  833. process.env.NODE_ENV !== 'production' && warn(
  834. 'Templates should only be responsible for mapping the state to the ' +
  835. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  836. "<" + tag + ">" + ', as they will not be parsed.'
  837. );
  838. }
  839. // apply pre-transforms
  840. for (var i = 0; i < preTransforms.length; i++) {
  841. preTransforms[i](element, options);
  842. }
  843. if (!inVPre) {
  844. processPre(element);
  845. if (element.pre) {
  846. inVPre = true;
  847. }
  848. }
  849. if (platformIsPreTag(element.tag)) {
  850. inPre = true;
  851. }
  852. if (inVPre) {
  853. processRawAttrs(element);
  854. } else {
  855. processFor(element);
  856. processIf(element);
  857. processOnce(element);
  858. processKey(element);
  859. // determine whether this is a plain element after
  860. // removing structural attributes
  861. element.plain = !element.key && !attrs.length;
  862. processRef(element);
  863. processSlot(element);
  864. processComponent(element);
  865. for (var i$1 = 0; i$1 < transforms.length; i$1++) {
  866. transforms[i$1](element, options);
  867. }
  868. processAttrs(element);
  869. }
  870. function checkRootConstraints (el) {
  871. if (process.env.NODE_ENV !== 'production') {
  872. if (el.tag === 'slot' || el.tag === 'template') {
  873. warnOnce(
  874. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  875. 'contain multiple nodes.'
  876. );
  877. }
  878. if (el.attrsMap.hasOwnProperty('v-for')) {
  879. warnOnce(
  880. 'Cannot use v-for on stateful component root element because ' +
  881. 'it renders multiple elements.'
  882. );
  883. }
  884. }
  885. }
  886. // tree management
  887. if (!root) {
  888. root = element;
  889. checkRootConstraints(root);
  890. } else if (!stack.length) {
  891. // allow root elements with v-if, v-else-if and v-else
  892. if (root.if && (element.elseif || element.else)) {
  893. checkRootConstraints(element);
  894. addIfCondition(root, {
  895. exp: element.elseif,
  896. block: element
  897. });
  898. } else if (process.env.NODE_ENV !== 'production') {
  899. warnOnce(
  900. "Component template should contain exactly one root element. " +
  901. "If you are using v-if on multiple elements, " +
  902. "use v-else-if to chain them instead."
  903. );
  904. }
  905. }
  906. if (currentParent && !element.forbidden) {
  907. if (element.elseif || element.else) {
  908. processIfConditions(element, currentParent);
  909. } else if (element.slotScope) { // scoped slot
  910. currentParent.plain = false;
  911. var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  912. } else {
  913. currentParent.children.push(element);
  914. element.parent = currentParent;
  915. }
  916. }
  917. if (!unary) {
  918. currentParent = element;
  919. stack.push(element);
  920. } else {
  921. endPre(element);
  922. }
  923. // apply post-transforms
  924. for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
  925. postTransforms[i$2](element, options);
  926. }
  927. },
  928. end: function end () {
  929. // remove trailing whitespace
  930. var element = stack[stack.length - 1];
  931. var lastNode = element.children[element.children.length - 1];
  932. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  933. element.children.pop();
  934. }
  935. // pop stack
  936. stack.length -= 1;
  937. currentParent = stack[stack.length - 1];
  938. endPre(element);
  939. },
  940. chars: function chars (text) {
  941. if (!currentParent) {
  942. if (process.env.NODE_ENV !== 'production') {
  943. if (text === template) {
  944. warnOnce(
  945. 'Component template requires a root element, rather than just text.'
  946. );
  947. } else if ((text = text.trim())) {
  948. warnOnce(
  949. ("text \"" + text + "\" outside root element will be ignored.")
  950. );
  951. }
  952. }
  953. return
  954. }
  955. // IE textarea placeholder bug
  956. /* istanbul ignore if */
  957. if (isIE &&
  958. currentParent.tag === 'textarea' &&
  959. currentParent.attrsMap.placeholder === text) {
  960. return
  961. }
  962. var children = currentParent.children;
  963. text = inPre || text.trim()
  964. ? decodeHTMLCached(text)
  965. // only preserve whitespace if its not right after a starting tag
  966. : preserveWhitespace && children.length ? ' ' : '';
  967. if (text) {
  968. var expression;
  969. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  970. children.push({
  971. type: 2,
  972. expression: expression,
  973. text: text
  974. });
  975. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  976. children.push({
  977. type: 3,
  978. text: text
  979. });
  980. }
  981. }
  982. }
  983. });
  984. return root
  985. }
  986. function processPre (el) {
  987. if (getAndRemoveAttr(el, 'v-pre') != null) {
  988. el.pre = true;
  989. }
  990. }
  991. function processRawAttrs (el) {
  992. var l = el.attrsList.length;
  993. if (l) {
  994. var attrs = el.attrs = new Array(l);
  995. for (var i = 0; i < l; i++) {
  996. attrs[i] = {
  997. name: el.attrsList[i].name,
  998. value: JSON.stringify(el.attrsList[i].value)
  999. };
  1000. }
  1001. } else if (!el.pre) {
  1002. // non root node in pre blocks with no attributes
  1003. el.plain = true;
  1004. }
  1005. }
  1006. function processKey (el) {
  1007. var exp = getBindingAttr(el, 'key');
  1008. if (exp) {
  1009. if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
  1010. warn("<template> cannot be keyed. Place the key on real elements instead.");
  1011. }
  1012. el.key = exp;
  1013. }
  1014. }
  1015. function processRef (el) {
  1016. var ref = getBindingAttr(el, 'ref');
  1017. if (ref) {
  1018. el.ref = ref;
  1019. el.refInFor = checkInFor(el);
  1020. }
  1021. }
  1022. function processFor (el) {
  1023. var exp;
  1024. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  1025. var inMatch = exp.match(forAliasRE);
  1026. if (!inMatch) {
  1027. process.env.NODE_ENV !== 'production' && warn(
  1028. ("Invalid v-for expression: " + exp)
  1029. );
  1030. return
  1031. }
  1032. el.for = inMatch[2].trim();
  1033. var alias = inMatch[1].trim();
  1034. var iteratorMatch = alias.match(forIteratorRE);
  1035. if (iteratorMatch) {
  1036. el.alias = iteratorMatch[1].trim();
  1037. el.iterator1 = iteratorMatch[2].trim();
  1038. if (iteratorMatch[3]) {
  1039. el.iterator2 = iteratorMatch[3].trim();
  1040. }
  1041. } else {
  1042. el.alias = alias;
  1043. }
  1044. }
  1045. }
  1046. function processIf (el) {
  1047. var exp = getAndRemoveAttr(el, 'v-if');
  1048. if (exp) {
  1049. el.if = exp;
  1050. addIfCondition(el, {
  1051. exp: exp,
  1052. block: el
  1053. });
  1054. } else {
  1055. if (getAndRemoveAttr(el, 'v-else') != null) {
  1056. el.else = true;
  1057. }
  1058. var elseif = getAndRemoveAttr(el, 'v-else-if');
  1059. if (elseif) {
  1060. el.elseif = elseif;
  1061. }
  1062. }
  1063. }
  1064. function processIfConditions (el, parent) {
  1065. var prev = findPrevElement(parent.children);
  1066. if (prev && prev.if) {
  1067. addIfCondition(prev, {
  1068. exp: el.elseif,
  1069. block: el
  1070. });
  1071. } else if (process.env.NODE_ENV !== 'production') {
  1072. warn(
  1073. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  1074. "used on element <" + (el.tag) + "> without corresponding v-if."
  1075. );
  1076. }
  1077. }
  1078. function findPrevElement (children) {
  1079. var i = children.length;
  1080. while (i--) {
  1081. if (children[i].type === 1) {
  1082. return children[i]
  1083. } else {
  1084. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  1085. warn(
  1086. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  1087. "will be ignored."
  1088. );
  1089. }
  1090. children.pop();
  1091. }
  1092. }
  1093. }
  1094. function addIfCondition (el, condition) {
  1095. if (!el.ifConditions) {
  1096. el.ifConditions = [];
  1097. }
  1098. el.ifConditions.push(condition);
  1099. }
  1100. function processOnce (el) {
  1101. var once$$1 = getAndRemoveAttr(el, 'v-once');
  1102. if (once$$1 != null) {
  1103. el.once = true;
  1104. }
  1105. }
  1106. function processSlot (el) {
  1107. if (el.tag === 'slot') {
  1108. el.slotName = getBindingAttr(el, 'name');
  1109. if (process.env.NODE_ENV !== 'production' && el.key) {
  1110. warn(
  1111. "`key` does not work on <slot> because slots are abstract outlets " +
  1112. "and can possibly expand into multiple elements. " +
  1113. "Use the key on a wrapping element instead."
  1114. );
  1115. }
  1116. } else {
  1117. var slotTarget = getBindingAttr(el, 'slot');
  1118. if (slotTarget) {
  1119. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  1120. }
  1121. if (el.tag === 'template') {
  1122. el.slotScope = getAndRemoveAttr(el, 'scope');
  1123. }
  1124. }
  1125. }
  1126. function processComponent (el) {
  1127. var binding;
  1128. if ((binding = getBindingAttr(el, 'is'))) {
  1129. el.component = binding;
  1130. }
  1131. if (getAndRemoveAttr(el, 'inline-template') != null) {
  1132. el.inlineTemplate = true;
  1133. }
  1134. }
  1135. function processAttrs (el) {
  1136. var list = el.attrsList;
  1137. var i, l, name, rawName, value, modifiers, isProp;
  1138. for (i = 0, l = list.length; i < l; i++) {
  1139. name = rawName = list[i].name;
  1140. value = list[i].value;
  1141. if (dirRE.test(name)) {
  1142. // mark element as dynamic
  1143. el.hasBindings = true;
  1144. // modifiers
  1145. modifiers = parseModifiers(name);
  1146. if (modifiers) {
  1147. name = name.replace(modifierRE, '');
  1148. }
  1149. if (bindRE.test(name)) { // v-bind
  1150. name = name.replace(bindRE, '');
  1151. value = parseFilters(value);
  1152. isProp = false;
  1153. if (modifiers) {
  1154. if (modifiers.prop) {
  1155. isProp = true;
  1156. name = camelize(name);
  1157. if (name === 'innerHtml') { name = 'innerHTML'; }
  1158. }
  1159. if (modifiers.camel) {
  1160. name = camelize(name);
  1161. }
  1162. }
  1163. if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  1164. addProp(el, name, value);
  1165. } else {
  1166. addAttr(el, name, value);
  1167. }
  1168. } else if (onRE.test(name)) { // v-on
  1169. name = name.replace(onRE, '');
  1170. addHandler(el, name, value, modifiers);
  1171. } else { // normal directives
  1172. name = name.replace(dirRE, '');
  1173. // parse arg
  1174. var argMatch = name.match(argRE);
  1175. var arg = argMatch && argMatch[1];
  1176. if (arg) {
  1177. name = name.slice(0, -(arg.length + 1));
  1178. }
  1179. addDirective(el, name, rawName, value, arg, modifiers);
  1180. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  1181. checkForAliasModel(el, value);
  1182. }
  1183. }
  1184. } else {
  1185. // literal attribute
  1186. if (process.env.NODE_ENV !== 'production') {
  1187. var expression = parseText(value, delimiters);
  1188. if (expression) {
  1189. warn(
  1190. name + "=\"" + value + "\": " +
  1191. 'Interpolation inside attributes has been removed. ' +
  1192. 'Use v-bind or the colon shorthand instead. For example, ' +
  1193. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  1194. );
  1195. }
  1196. }
  1197. addAttr(el, name, JSON.stringify(value));
  1198. }
  1199. }
  1200. }
  1201. function checkInFor (el) {
  1202. var parent = el;
  1203. while (parent) {
  1204. if (parent.for !== undefined) {
  1205. return true
  1206. }
  1207. parent = parent.parent;
  1208. }
  1209. return false
  1210. }
  1211. function parseModifiers (name) {
  1212. var match = name.match(modifierRE);
  1213. if (match) {
  1214. var ret = {};
  1215. match.forEach(function (m) { ret[m.slice(1)] = true; });
  1216. return ret
  1217. }
  1218. }
  1219. function makeAttrsMap (attrs) {
  1220. var map = {};
  1221. for (var i = 0, l = attrs.length; i < l; i++) {
  1222. if (process.env.NODE_ENV !== 'production' && map[attrs[i].name] && !isIE) {
  1223. warn('duplicate attribute: ' + attrs[i].name);
  1224. }
  1225. map[attrs[i].name] = attrs[i].value;
  1226. }
  1227. return map
  1228. }
  1229. function isForbiddenTag (el) {
  1230. return (
  1231. el.tag === 'style' ||
  1232. (el.tag === 'script' && (
  1233. !el.attrsMap.type ||
  1234. el.attrsMap.type === 'text/javascript'
  1235. ))
  1236. )
  1237. }
  1238. var ieNSBug = /^xmlns:NS\d+/;
  1239. var ieNSPrefix = /^NS\d+:/;
  1240. /* istanbul ignore next */
  1241. function guardIESVGBug (attrs) {
  1242. var res = [];
  1243. for (var i = 0; i < attrs.length; i++) {
  1244. var attr = attrs[i];
  1245. if (!ieNSBug.test(attr.name)) {
  1246. attr.name = attr.name.replace(ieNSPrefix, '');
  1247. res.push(attr);
  1248. }
  1249. }
  1250. return res
  1251. }
  1252. function checkForAliasModel (el, value) {
  1253. var _el = el;
  1254. while (_el) {
  1255. if (_el.for && _el.alias === value) {
  1256. warn(
  1257. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  1258. "You are binding v-model directly to a v-for iteration alias. " +
  1259. "This will not be able to modify the v-for source array because " +
  1260. "writing to the alias is like modifying a function local variable. " +
  1261. "Consider using an array of objects and use v-model on an object property instead."
  1262. );
  1263. }
  1264. _el = _el.parent;
  1265. }
  1266. }
  1267. /* */
  1268. var isStaticKey;
  1269. var isPlatformReservedTag;
  1270. var genStaticKeysCached = cached(genStaticKeys$1);
  1271. /**
  1272. * Goal of the optimizer: walk the generated template AST tree
  1273. * and detect sub-trees that are purely static, i.e. parts of
  1274. * the DOM that never needs to change.
  1275. *
  1276. * Once we detect these sub-trees, we can:
  1277. *
  1278. * 1. Hoist them into constants, so that we no longer need to
  1279. * create fresh nodes for them on each re-render;
  1280. * 2. Completely skip them in the patching process.
  1281. */
  1282. function optimize (root, options) {
  1283. if (!root) { return }
  1284. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  1285. isPlatformReservedTag = options.isReservedTag || no;
  1286. // first pass: mark all non-static nodes.
  1287. markStatic(root);
  1288. // second pass: mark static roots.
  1289. markStaticRoots(root, false);
  1290. }
  1291. function genStaticKeys$1 (keys) {
  1292. return makeMap(
  1293. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  1294. (keys ? ',' + keys : '')
  1295. )
  1296. }
  1297. function markStatic (node) {
  1298. node.static = isStatic(node);
  1299. if (node.type === 1) {
  1300. // do not make component slot content static. this avoids
  1301. // 1. components not able to mutate slot nodes
  1302. // 2. static slot content fails for hot-reloading
  1303. if (
  1304. !isPlatformReservedTag(node.tag) &&
  1305. node.tag !== 'slot' &&
  1306. node.attrsMap['inline-template'] == null
  1307. ) {
  1308. return
  1309. }
  1310. for (var i = 0, l = node.children.length; i < l; i++) {
  1311. var child = node.children[i];
  1312. markStatic(child);
  1313. if (!child.static) {
  1314. node.static = false;
  1315. }
  1316. }
  1317. }
  1318. }
  1319. function markStaticRoots (node, isInFor) {
  1320. if (node.type === 1) {
  1321. if (node.static || node.once) {
  1322. node.staticInFor = isInFor;
  1323. }
  1324. // For a node to qualify as a static root, it should have children that
  1325. // are not just static text. Otherwise the cost of hoisting out will
  1326. // outweigh the benefits and it's better off to just always render it fresh.
  1327. if (node.static && node.children.length && !(
  1328. node.children.length === 1 &&
  1329. node.children[0].type === 3
  1330. )) {
  1331. node.staticRoot = true;
  1332. return
  1333. } else {
  1334. node.staticRoot = false;
  1335. }
  1336. if (node.children) {
  1337. for (var i = 0, l = node.children.length; i < l; i++) {
  1338. markStaticRoots(node.children[i], isInFor || !!node.for);
  1339. }
  1340. }
  1341. if (node.ifConditions) {
  1342. walkThroughConditionsBlocks(node.ifConditions, isInFor);
  1343. }
  1344. }
  1345. }
  1346. function walkThroughConditionsBlocks (conditionBlocks, isInFor) {
  1347. for (var i = 1, len = conditionBlocks.length; i < len; i++) {
  1348. markStaticRoots(conditionBlocks[i].block, isInFor);
  1349. }
  1350. }
  1351. function isStatic (node) {
  1352. if (node.type === 2) { // expression
  1353. return false
  1354. }
  1355. if (node.type === 3) { // text
  1356. return true
  1357. }
  1358. return !!(node.pre || (
  1359. !node.hasBindings && // no dynamic bindings
  1360. !node.if && !node.for && // not v-if or v-for or v-else
  1361. !isBuiltInTag(node.tag) && // not a built-in
  1362. isPlatformReservedTag(node.tag) && // not a component
  1363. !isDirectChildOfTemplateFor(node) &&
  1364. Object.keys(node).every(isStaticKey)
  1365. ))
  1366. }
  1367. function isDirectChildOfTemplateFor (node) {
  1368. while (node.parent) {
  1369. node = node.parent;
  1370. if (node.tag !== 'template') {
  1371. return false
  1372. }
  1373. if (node.for) {
  1374. return true
  1375. }
  1376. }
  1377. return false
  1378. }
  1379. /* */
  1380. var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  1381. var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
  1382. // keyCode aliases
  1383. var keyCodes = {
  1384. esc: 27,
  1385. tab: 9,
  1386. enter: 13,
  1387. space: 32,
  1388. up: 38,
  1389. left: 37,
  1390. right: 39,
  1391. down: 40,
  1392. 'delete': [8, 46]
  1393. };
  1394. // #4868: modifiers that prevent the execution of the listener
  1395. // need to explicitly return null so that we can determine whether to remove
  1396. // the listener for .once
  1397. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  1398. var modifierCode = {
  1399. stop: '$event.stopPropagation();',
  1400. prevent: '$event.preventDefault();',
  1401. self: genGuard("$event.target !== $event.currentTarget"),
  1402. ctrl: genGuard("!$event.ctrlKey"),
  1403. shift: genGuard("!$event.shiftKey"),
  1404. alt: genGuard("!$event.altKey"),
  1405. meta: genGuard("!$event.metaKey"),
  1406. left: genGuard("'button' in $event && $event.button !== 0"),
  1407. middle: genGuard("'button' in $event && $event.button !== 1"),
  1408. right: genGuard("'button' in $event && $event.button !== 2")
  1409. };
  1410. function genHandlers (events, native) {
  1411. var res = native ? 'nativeOn:{' : 'on:{';
  1412. for (var name in events) {
  1413. res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
  1414. }
  1415. return res.slice(0, -1) + '}'
  1416. }
  1417. function genHandler (
  1418. name,
  1419. handler
  1420. ) {
  1421. if (!handler) {
  1422. return 'function(){}'
  1423. }
  1424. if (Array.isArray(handler)) {
  1425. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  1426. }
  1427. var isMethodPath = simplePathRE.test(handler.value);
  1428. var isFunctionExpression = fnExpRE.test(handler.value);
  1429. if (!handler.modifiers) {
  1430. return isMethodPath || isFunctionExpression
  1431. ? handler.value
  1432. : ("function($event){" + (handler.value) + "}") // inline statement
  1433. } else {
  1434. var code = '';
  1435. var genModifierCode = '';
  1436. var keys = [];
  1437. for (var key in handler.modifiers) {
  1438. if (modifierCode[key]) {
  1439. genModifierCode += modifierCode[key];
  1440. // left/right
  1441. if (keyCodes[key]) {
  1442. keys.push(key);
  1443. }
  1444. } else {
  1445. keys.push(key);
  1446. }
  1447. }
  1448. if (keys.length) {
  1449. code += genKeyFilter(keys);
  1450. }
  1451. // Make sure modifiers like prevent and stop get executed after key filtering
  1452. if (genModifierCode) {
  1453. code += genModifierCode;
  1454. }
  1455. var handlerCode = isMethodPath
  1456. ? handler.value + '($event)'
  1457. : isFunctionExpression
  1458. ? ("(" + (handler.value) + ")($event)")
  1459. : handler.value;
  1460. return ("function($event){" + code + handlerCode + "}")
  1461. }
  1462. }
  1463. function genKeyFilter (keys) {
  1464. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  1465. }
  1466. function genFilterCode (key) {
  1467. var keyVal = parseInt(key, 10);
  1468. if (keyVal) {
  1469. return ("$event.keyCode!==" + keyVal)
  1470. }
  1471. var alias = keyCodes[key];
  1472. return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
  1473. }
  1474. /* */
  1475. function bind$1 (el, dir) {
  1476. el.wrapData = function (code) {
  1477. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")")
  1478. };
  1479. }
  1480. /* */
  1481. var baseDirectives = {
  1482. bind: bind$1,
  1483. cloak: noop
  1484. };
  1485. /* */
  1486. // configurable state
  1487. var warn$1;
  1488. var transforms$1;
  1489. var dataGenFns;
  1490. var platformDirectives;
  1491. var isPlatformReservedTag$1;
  1492. var staticRenderFns;
  1493. var onceCount;
  1494. var currentOptions;
  1495. function generate (
  1496. ast,
  1497. options
  1498. ) {
  1499. // save previous staticRenderFns so generate calls can be nested
  1500. var prevStaticRenderFns = staticRenderFns;
  1501. var currentStaticRenderFns = staticRenderFns = [];
  1502. var prevOnceCount = onceCount;
  1503. onceCount = 0;
  1504. currentOptions = options;
  1505. warn$1 = options.warn || baseWarn;
  1506. transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
  1507. dataGenFns = pluckModuleFunction(options.modules, 'genData');
  1508. platformDirectives = options.directives || {};
  1509. isPlatformReservedTag$1 = options.isReservedTag || no;
  1510. var code = ast ? genElement(ast) : '_c("div")';
  1511. staticRenderFns = prevStaticRenderFns;
  1512. onceCount = prevOnceCount;
  1513. return {
  1514. render: ("with(this){return " + code + "}"),
  1515. staticRenderFns: currentStaticRenderFns
  1516. }
  1517. }
  1518. function genElement (el) {
  1519. if (el.staticRoot && !el.staticProcessed) {
  1520. return genStatic(el)
  1521. } else if (el.once && !el.onceProcessed) {
  1522. return genOnce(el)
  1523. } else if (el.for && !el.forProcessed) {
  1524. return genFor(el)
  1525. } else if (el.if && !el.ifProcessed) {
  1526. return genIf(el)
  1527. } else if (el.tag === 'template' && !el.slotTarget) {
  1528. return genChildren(el) || 'void 0'
  1529. } else if (el.tag === 'slot') {
  1530. return genSlot(el)
  1531. } else {
  1532. // component or element
  1533. var code;
  1534. if (el.component) {
  1535. code = genComponent(el.component, el);
  1536. } else {
  1537. var data = el.plain ? undefined : genData(el);
  1538. var children = el.inlineTemplate ? null : genChildren(el, true);
  1539. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  1540. }
  1541. // module transforms
  1542. for (var i = 0; i < transforms$1.length; i++) {
  1543. code = transforms$1[i](el, code);
  1544. }
  1545. return code
  1546. }
  1547. }
  1548. // hoist static sub-trees out
  1549. function genStatic (el) {
  1550. el.staticProcessed = true;
  1551. staticRenderFns.push(("with(this){return " + (genElement(el)) + "}"));
  1552. return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  1553. }
  1554. // v-once
  1555. function genOnce (el) {
  1556. el.onceProcessed = true;
  1557. if (el.if && !el.ifProcessed) {
  1558. return genIf(el)
  1559. } else if (el.staticInFor) {
  1560. var key = '';
  1561. var parent = el.parent;
  1562. while (parent) {
  1563. if (parent.for) {
  1564. key = parent.key;
  1565. break
  1566. }
  1567. parent = parent.parent;
  1568. }
  1569. if (!key) {
  1570. process.env.NODE_ENV !== 'production' && warn$1(
  1571. "v-once can only be used inside v-for that is keyed. "
  1572. );
  1573. return genElement(el)
  1574. }
  1575. return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")")
  1576. } else {
  1577. return genStatic(el)
  1578. }
  1579. }
  1580. function genIf (el) {
  1581. el.ifProcessed = true; // avoid recursion
  1582. return genIfConditions(el.ifConditions.slice())
  1583. }
  1584. function genIfConditions (conditions) {
  1585. if (!conditions.length) {
  1586. return '_e()'
  1587. }
  1588. var condition = conditions.shift();
  1589. if (condition.exp) {
  1590. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions)))
  1591. } else {
  1592. return ("" + (genTernaryExp(condition.block)))
  1593. }
  1594. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  1595. function genTernaryExp (el) {
  1596. return el.once ? genOnce(el) : genElement(el)
  1597. }
  1598. }
  1599. function genFor (el) {
  1600. var exp = el.for;
  1601. var alias = el.alias;
  1602. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  1603. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  1604. if (
  1605. process.env.NODE_ENV !== 'production' &&
  1606. maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key
  1607. ) {
  1608. warn$1(
  1609. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  1610. "v-for should have explicit keys. " +
  1611. "See https://vuejs.org/guide/list.html#key for more info.",
  1612. true /* tip */
  1613. );
  1614. }
  1615. el.forProcessed = true; // avoid recursion
  1616. return "_l((" + exp + ")," +
  1617. "function(" + alias + iterator1 + iterator2 + "){" +
  1618. "return " + (genElement(el)) +
  1619. '})'
  1620. }
  1621. function genData (el) {
  1622. var data = '{';
  1623. // directives first.
  1624. // directives may mutate the el's other properties before they are generated.
  1625. var dirs = genDirectives(el);
  1626. if (dirs) { data += dirs + ','; }
  1627. // key
  1628. if (el.key) {
  1629. data += "key:" + (el.key) + ",";
  1630. }
  1631. // ref
  1632. if (el.ref) {
  1633. data += "ref:" + (el.ref) + ",";
  1634. }
  1635. if (el.refInFor) {
  1636. data += "refInFor:true,";
  1637. }
  1638. // pre
  1639. if (el.pre) {
  1640. data += "pre:true,";
  1641. }
  1642. // record original tag name for components using "is" attribute
  1643. if (el.component) {
  1644. data += "tag:\"" + (el.tag) + "\",";
  1645. }
  1646. // module data generation functions
  1647. for (var i = 0; i < dataGenFns.length; i++) {
  1648. data += dataGenFns[i](el);
  1649. }
  1650. // attributes
  1651. if (el.attrs) {
  1652. data += "attrs:{" + (genProps(el.attrs)) + "},";
  1653. }
  1654. // DOM props
  1655. if (el.props) {
  1656. data += "domProps:{" + (genProps(el.props)) + "},";
  1657. }
  1658. // event handlers
  1659. if (el.events) {
  1660. data += (genHandlers(el.events)) + ",";
  1661. }
  1662. if (el.nativeEvents) {
  1663. data += (genHandlers(el.nativeEvents, true)) + ",";
  1664. }
  1665. // slot target
  1666. if (el.slotTarget) {
  1667. data += "slot:" + (el.slotTarget) + ",";
  1668. }
  1669. // scoped slots
  1670. if (el.scopedSlots) {
  1671. data += (genScopedSlots(el.scopedSlots)) + ",";
  1672. }
  1673. // component v-model
  1674. if (el.model) {
  1675. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  1676. }
  1677. // inline-template
  1678. if (el.inlineTemplate) {
  1679. var inlineTemplate = genInlineTemplate(el);
  1680. if (inlineTemplate) {
  1681. data += inlineTemplate + ",";
  1682. }
  1683. }
  1684. data = data.replace(/,$/, '') + '}';
  1685. // v-bind data wrap
  1686. if (el.wrapData) {
  1687. data = el.wrapData(data);
  1688. }
  1689. return data
  1690. }
  1691. function genDirectives (el) {
  1692. var dirs = el.directives;
  1693. if (!dirs) { return }
  1694. var res = 'directives:[';
  1695. var hasRuntime = false;
  1696. var i, l, dir, needRuntime;
  1697. for (i = 0, l = dirs.length; i < l; i++) {
  1698. dir = dirs[i];
  1699. needRuntime = true;
  1700. var gen = platformDirectives[dir.name] || baseDirectives[dir.name];
  1701. if (gen) {
  1702. // compile-time directive that manipulates AST.
  1703. // returns true if it also needs a runtime counterpart.
  1704. needRuntime = !!gen(el, dir, warn$1);
  1705. }
  1706. if (needRuntime) {
  1707. hasRuntime = true;
  1708. 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))) : '') + "},";
  1709. }
  1710. }
  1711. if (hasRuntime) {
  1712. return res.slice(0, -1) + ']'
  1713. }
  1714. }
  1715. function genInlineTemplate (el) {
  1716. var ast = el.children[0];
  1717. if (process.env.NODE_ENV !== 'production' && (
  1718. el.children.length > 1 || ast.type !== 1
  1719. )) {
  1720. warn$1('Inline-template components must have exactly one child element.');
  1721. }
  1722. if (ast.type === 1) {
  1723. var inlineRenderFns = generate(ast, currentOptions);
  1724. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  1725. }
  1726. }
  1727. function genScopedSlots (slots) {
  1728. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])")
  1729. }
  1730. function genScopedSlot (key, el) {
  1731. return "[" + key + ",function(" + (String(el.attrsMap.scope)) + "){" +
  1732. "return " + (el.tag === 'template'
  1733. ? genChildren(el) || 'void 0'
  1734. : genElement(el)) + "}]"
  1735. }
  1736. function genChildren (el, checkSkip) {
  1737. var children = el.children;
  1738. if (children.length) {
  1739. var el$1 = children[0];
  1740. // optimize single v-for
  1741. if (children.length === 1 &&
  1742. el$1.for &&
  1743. el$1.tag !== 'template' &&
  1744. el$1.tag !== 'slot') {
  1745. return genElement(el$1)
  1746. }
  1747. var normalizationType = checkSkip ? getNormalizationType(children) : 0;
  1748. return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
  1749. }
  1750. }
  1751. // determine the normalization needed for the children array.
  1752. // 0: no normalization needed
  1753. // 1: simple normalization needed (possible 1-level deep nested array)
  1754. // 2: full normalization needed
  1755. function getNormalizationType (children) {
  1756. var res = 0;
  1757. for (var i = 0; i < children.length; i++) {
  1758. var el = children[i];
  1759. if (el.type !== 1) {
  1760. continue
  1761. }
  1762. if (needsNormalization(el) ||
  1763. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  1764. res = 2;
  1765. break
  1766. }
  1767. if (maybeComponent(el) ||
  1768. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  1769. res = 1;
  1770. }
  1771. }
  1772. return res
  1773. }
  1774. function needsNormalization (el) {
  1775. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  1776. }
  1777. function maybeComponent (el) {
  1778. return !isPlatformReservedTag$1(el.tag)
  1779. }
  1780. function genNode (node) {
  1781. if (node.type === 1) {
  1782. return genElement(node)
  1783. } else {
  1784. return genText(node)
  1785. }
  1786. }
  1787. function genText (text) {
  1788. return ("_v(" + (text.type === 2
  1789. ? text.expression // no need for () because already wrapped in _s()
  1790. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  1791. }
  1792. function genSlot (el) {
  1793. var slotName = el.slotName || '"default"';
  1794. var children = genChildren(el);
  1795. var res = "_t(" + slotName + (children ? ("," + children) : '');
  1796. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  1797. var bind$$1 = el.attrsMap['v-bind'];
  1798. if ((attrs || bind$$1) && !children) {
  1799. res += ",null";
  1800. }
  1801. if (attrs) {
  1802. res += "," + attrs;
  1803. }
  1804. if (bind$$1) {
  1805. res += (attrs ? '' : ',null') + "," + bind$$1;
  1806. }
  1807. return res + ')'
  1808. }
  1809. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  1810. function genComponent (componentName, el) {
  1811. var children = el.inlineTemplate ? null : genChildren(el, true);
  1812. return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")")
  1813. }
  1814. function genProps (props) {
  1815. var res = '';
  1816. for (var i = 0; i < props.length; i++) {
  1817. var prop = props[i];
  1818. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  1819. }
  1820. return res.slice(0, -1)
  1821. }
  1822. // #3895, #4268
  1823. function transformSpecialNewlines (text) {
  1824. return text
  1825. .replace(/\u2028/g, '\\u2028')
  1826. .replace(/\u2029/g, '\\u2029')
  1827. }
  1828. /* */
  1829. // these keywords should not appear inside expressions, but operators like
  1830. // typeof, instanceof and in are allowed
  1831. var prohibitedKeywordRE = new RegExp('\\b' + (
  1832. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  1833. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  1834. 'extends,finally,continue,debugger,function,arguments'
  1835. ).split(',').join('\\b|\\b') + '\\b');
  1836. // these unary operators should not be used as property/method names
  1837. var unaryOperatorsRE = new RegExp('\\b' + (
  1838. 'delete,typeof,void'
  1839. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  1840. // check valid identifier for v-for
  1841. var identRE = /[A-Za-z_$][\w$]*/;
  1842. // strip strings in expressions
  1843. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  1844. // detect problematic expressions in a template
  1845. function detectErrors (ast) {
  1846. var errors = [];
  1847. if (ast) {
  1848. checkNode(ast, errors);
  1849. }
  1850. return errors
  1851. }
  1852. function checkNode (node, errors) {
  1853. if (node.type === 1) {
  1854. for (var name in node.attrsMap) {
  1855. if (dirRE.test(name)) {
  1856. var value = node.attrsMap[name];
  1857. if (value) {
  1858. if (name === 'v-for') {
  1859. checkFor(node, ("v-for=\"" + value + "\""), errors);
  1860. } else if (onRE.test(name)) {
  1861. checkEvent(value, (name + "=\"" + value + "\""), errors);
  1862. } else {
  1863. checkExpression(value, (name + "=\"" + value + "\""), errors);
  1864. }
  1865. }
  1866. }
  1867. }
  1868. if (node.children) {
  1869. for (var i = 0; i < node.children.length; i++) {
  1870. checkNode(node.children[i], errors);
  1871. }
  1872. }
  1873. } else if (node.type === 2) {
  1874. checkExpression(node.expression, node.text, errors);
  1875. }
  1876. }
  1877. function checkEvent (exp, text, errors) {
  1878. var keywordMatch = exp.replace(stripStringRE, '').match(unaryOperatorsRE);
  1879. if (keywordMatch) {
  1880. errors.push(
  1881. "avoid using JavaScript unary operator as property name: " +
  1882. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  1883. );
  1884. }
  1885. checkExpression(exp, text, errors);
  1886. }
  1887. function checkFor (node, text, errors) {
  1888. checkExpression(node.for || '', text, errors);
  1889. checkIdentifier(node.alias, 'v-for alias', text, errors);
  1890. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  1891. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  1892. }
  1893. function checkIdentifier (ident, type, text, errors) {
  1894. if (typeof ident === 'string' && !identRE.test(ident)) {
  1895. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  1896. }
  1897. }
  1898. function checkExpression (exp, text, errors) {
  1899. try {
  1900. new Function(("return " + exp));
  1901. } catch (e) {
  1902. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  1903. if (keywordMatch) {
  1904. errors.push(
  1905. "avoid using JavaScript keyword as property name: " +
  1906. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  1907. );
  1908. } else {
  1909. errors.push(("invalid expression: " + (text.trim())));
  1910. }
  1911. }
  1912. }
  1913. /* */
  1914. var config = {
  1915. /**
  1916. * Option merge strategies (used in core/util/options)
  1917. */
  1918. optionMergeStrategies: Object.create(null),
  1919. /**
  1920. * Whether to suppress warnings.
  1921. */
  1922. silent: false,
  1923. /**
  1924. * Show production mode tip message on boot?
  1925. */
  1926. productionTip: process.env.NODE_ENV !== 'production',
  1927. /**
  1928. * Whether to enable devtools
  1929. */
  1930. devtools: process.env.NODE_ENV !== 'production',
  1931. /**
  1932. * Whether to record perf
  1933. */
  1934. performance: false,
  1935. /**
  1936. * Error handler for watcher errors
  1937. */
  1938. errorHandler: null,
  1939. /**
  1940. * Ignore certain custom elements
  1941. */
  1942. ignoredElements: [],
  1943. /**
  1944. * Custom user key aliases for v-on
  1945. */
  1946. keyCodes: Object.create(null),
  1947. /**
  1948. * Check if a tag is reserved so that it cannot be registered as a
  1949. * component. This is platform-dependent and may be overwritten.
  1950. */
  1951. isReservedTag: no,
  1952. /**
  1953. * Check if a tag is an unknown element.
  1954. * Platform-dependent.
  1955. */
  1956. isUnknownElement: no,
  1957. /**
  1958. * Get the namespace of an element
  1959. */
  1960. getTagNamespace: noop,
  1961. /**
  1962. * Parse the real tag name for the specific platform.
  1963. */
  1964. parsePlatformTagName: identity,
  1965. /**
  1966. * Check if an attribute must be bound using property, e.g. value
  1967. * Platform-dependent.
  1968. */
  1969. mustUseProp: no,
  1970. /**
  1971. * List of asset types that a component can own.
  1972. */
  1973. _assetTypes: [
  1974. 'component',
  1975. 'directive',
  1976. 'filter'
  1977. ],
  1978. /**
  1979. * List of lifecycle hooks.
  1980. */
  1981. _lifecycleHooks: [
  1982. 'beforeCreate',
  1983. 'created',
  1984. 'beforeMount',
  1985. 'mounted',
  1986. 'beforeUpdate',
  1987. 'updated',
  1988. 'beforeDestroy',
  1989. 'destroyed',
  1990. 'activated',
  1991. 'deactivated'
  1992. ],
  1993. /**
  1994. * Max circular updates allowed in a scheduler flush cycle.
  1995. */
  1996. _maxUpdateCount: 100
  1997. };
  1998. var warn$2 = noop;
  1999. var tip = noop;
  2000. var formatComponentName;
  2001. if (process.env.NODE_ENV !== 'production') {
  2002. var hasConsole = typeof console !== 'undefined';
  2003. var classifyRE = /(?:^|[-_])(\w)/g;
  2004. var classify = function (str) { return str
  2005. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  2006. .replace(/[-_]/g, ''); };
  2007. warn$2 = function (msg, vm) {
  2008. if (hasConsole && (!config.silent)) {
  2009. console.error("[Vue warn]: " + msg + " " + (
  2010. vm ? formatLocation(formatComponentName(vm)) : ''
  2011. ));
  2012. }
  2013. };
  2014. tip = function (msg, vm) {
  2015. if (hasConsole && (!config.silent)) {
  2016. console.warn("[Vue tip]: " + msg + " " + (
  2017. vm ? formatLocation(formatComponentName(vm)) : ''
  2018. ));
  2019. }
  2020. };
  2021. formatComponentName = function (vm, includeFile) {
  2022. if (vm.$root === vm) {
  2023. return '<Root>'
  2024. }
  2025. var name = typeof vm === 'function' && vm.options
  2026. ? vm.options.name
  2027. : vm._isVue
  2028. ? vm.$options.name || vm.$options._componentTag
  2029. : vm.name;
  2030. var file = vm._isVue && vm.$options.__file;
  2031. if (!name && file) {
  2032. var match = file.match(/([^/\\]+)\.vue$/);
  2033. name = match && match[1];
  2034. }
  2035. return (
  2036. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  2037. (file && includeFile !== false ? (" at " + file) : '')
  2038. )
  2039. };
  2040. var formatLocation = function (str) {
  2041. if (str === "<Anonymous>") {
  2042. str += " - use the \"name\" option for better debugging messages.";
  2043. }
  2044. return ("\n(found in " + str + ")")
  2045. };
  2046. }
  2047. /* */
  2048. function baseCompile (
  2049. template,
  2050. options
  2051. ) {
  2052. var ast = parse(template.trim(), options);
  2053. optimize(ast, options);
  2054. var code = generate(ast, options);
  2055. return {
  2056. ast: ast,
  2057. render: code.render,
  2058. staticRenderFns: code.staticRenderFns
  2059. }
  2060. }
  2061. function makeFunction (code, errors) {
  2062. try {
  2063. return new Function(code)
  2064. } catch (err) {
  2065. errors.push({ err: err, code: code });
  2066. return noop
  2067. }
  2068. }
  2069. function createCompiler (baseOptions) {
  2070. var functionCompileCache = Object.create(null);
  2071. function compile (
  2072. template,
  2073. options
  2074. ) {
  2075. var finalOptions = Object.create(baseOptions);
  2076. var errors = [];
  2077. var tips = [];
  2078. finalOptions.warn = function (msg, tip$$1) {
  2079. (tip$$1 ? tips : errors).push(msg);
  2080. };
  2081. if (options) {
  2082. // merge custom modules
  2083. if (options.modules) {
  2084. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  2085. }
  2086. // merge custom directives
  2087. if (options.directives) {
  2088. finalOptions.directives = extend(
  2089. Object.create(baseOptions.directives),
  2090. options.directives
  2091. );
  2092. }
  2093. // copy other options
  2094. for (var key in options) {
  2095. if (key !== 'modules' && key !== 'directives') {
  2096. finalOptions[key] = options[key];
  2097. }
  2098. }
  2099. }
  2100. var compiled = baseCompile(template, finalOptions);
  2101. if (process.env.NODE_ENV !== 'production') {
  2102. errors.push.apply(errors, detectErrors(compiled.ast));
  2103. }
  2104. compiled.errors = errors;
  2105. compiled.tips = tips;
  2106. return compiled
  2107. }
  2108. function compileToFunctions (
  2109. template,
  2110. options,
  2111. vm
  2112. ) {
  2113. options = options || {};
  2114. /* istanbul ignore if */
  2115. if (process.env.NODE_ENV !== 'production') {
  2116. // detect possible CSP restriction
  2117. try {
  2118. new Function('return 1');
  2119. } catch (e) {
  2120. if (e.toString().match(/unsafe-eval|CSP/)) {
  2121. warn$2(
  2122. 'It seems you are using the standalone build of Vue.js in an ' +
  2123. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  2124. 'The template compiler cannot work in this environment. Consider ' +
  2125. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  2126. 'templates into render functions.'
  2127. );
  2128. }
  2129. }
  2130. }
  2131. // check cache
  2132. var key = options.delimiters
  2133. ? String(options.delimiters) + template
  2134. : template;
  2135. if (functionCompileCache[key]) {
  2136. return functionCompileCache[key]
  2137. }
  2138. // compile
  2139. var compiled = compile(template, options);
  2140. // check compilation errors/tips
  2141. if (process.env.NODE_ENV !== 'production') {
  2142. if (compiled.errors && compiled.errors.length) {
  2143. warn$2(
  2144. "Error compiling template:\n\n" + template + "\n\n" +
  2145. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  2146. vm
  2147. );
  2148. }
  2149. if (compiled.tips && compiled.tips.length) {
  2150. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  2151. }
  2152. }
  2153. // turn code into functions
  2154. var res = {};
  2155. var fnGenErrors = [];
  2156. res.render = makeFunction(compiled.render, fnGenErrors);
  2157. var l = compiled.staticRenderFns.length;
  2158. res.staticRenderFns = new Array(l);
  2159. for (var i = 0; i < l; i++) {
  2160. res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors);
  2161. }
  2162. // check function generation errors.
  2163. // this should only happen if there is a bug in the compiler itself.
  2164. // mostly for codegen development use
  2165. /* istanbul ignore if */
  2166. if (process.env.NODE_ENV !== 'production') {
  2167. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  2168. warn$2(
  2169. "Failed to generate render function:\n\n" +
  2170. fnGenErrors.map(function (ref) {
  2171. var err = ref.err;
  2172. var code = ref.code;
  2173. return ((err.toString()) + " in\n\n" + code + "\n");
  2174. }).join('\n'),
  2175. vm
  2176. );
  2177. }
  2178. }
  2179. return (functionCompileCache[key] = res)
  2180. }
  2181. return {
  2182. compile: compile,
  2183. compileToFunctions: compileToFunctions
  2184. }
  2185. }
  2186. /* */
  2187. function transformNode (el, options) {
  2188. var warn = options.warn || baseWarn;
  2189. var staticClass = getAndRemoveAttr(el, 'class');
  2190. var ref = parseStaticClass(staticClass, options);
  2191. var dynamic = ref.dynamic;
  2192. var classResult = ref.classResult;
  2193. if (process.env.NODE_ENV !== 'production' && dynamic && staticClass) {
  2194. warn(
  2195. "class=\"" + staticClass + "\": " +
  2196. 'Interpolation inside attributes has been deprecated. ' +
  2197. 'Use v-bind or the colon shorthand instead.'
  2198. );
  2199. }
  2200. if (!dynamic && classResult) {
  2201. el.staticClass = classResult;
  2202. }
  2203. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  2204. if (classBinding) {
  2205. el.classBinding = classBinding;
  2206. } else if (dynamic) {
  2207. el.classBinding = classResult;
  2208. }
  2209. }
  2210. function genData$1 (el) {
  2211. var data = '';
  2212. if (el.staticClass) {
  2213. data += "staticClass:" + (el.staticClass) + ",";
  2214. }
  2215. if (el.classBinding) {
  2216. data += "class:" + (el.classBinding) + ",";
  2217. }
  2218. return data
  2219. }
  2220. function parseStaticClass (staticClass, options) {
  2221. // "a b c" -> ["a", "b", "c"] => staticClass: ["a", "b", "c"]
  2222. // "a {{x}} c" -> ["a", x, "c"] => classBinding: '["a", x, "c"]'
  2223. var dynamic = false;
  2224. var classResult = '';
  2225. if (staticClass) {
  2226. var classList = staticClass.trim().split(' ').map(function (name) {
  2227. var result = parseText(name, options.delimiters);
  2228. if (result) {
  2229. dynamic = true;
  2230. return result
  2231. }
  2232. return JSON.stringify(name)
  2233. });
  2234. if (classList.length) {
  2235. classResult = '[' + classList.join(',') + ']';
  2236. }
  2237. }
  2238. return { dynamic: dynamic, classResult: classResult }
  2239. }
  2240. var klass = {
  2241. staticKeys: ['staticClass'],
  2242. transformNode: transformNode,
  2243. genData: genData$1
  2244. };
  2245. /* */
  2246. var normalize = cached(camelize);
  2247. function transformNode$1 (el, options) {
  2248. var warn = options.warn || baseWarn;
  2249. var staticStyle = getAndRemoveAttr(el, 'style');
  2250. var ref = parseStaticStyle(staticStyle, options);
  2251. var dynamic = ref.dynamic;
  2252. var styleResult = ref.styleResult;
  2253. if (process.env.NODE_ENV !== 'production' && dynamic) {
  2254. warn(
  2255. "style=\"" + (String(staticStyle)) + "\": " +
  2256. 'Interpolation inside attributes has been deprecated. ' +
  2257. 'Use v-bind or the colon shorthand instead.'
  2258. );
  2259. }
  2260. if (!dynamic && styleResult) {
  2261. el.staticStyle = styleResult;
  2262. }
  2263. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  2264. if (styleBinding) {
  2265. el.styleBinding = styleBinding;
  2266. } else if (dynamic) {
  2267. el.styleBinding = styleResult;
  2268. }
  2269. }
  2270. function genData$2 (el) {
  2271. var data = '';
  2272. if (el.staticStyle) {
  2273. data += "staticStyle:" + (el.staticStyle) + ",";
  2274. }
  2275. if (el.styleBinding) {
  2276. data += "style:" + (el.styleBinding) + ",";
  2277. }
  2278. return data
  2279. }
  2280. function parseStaticStyle (staticStyle, options) {
  2281. // "width: 200px; height: 200px;" -> {width: 200, height: 200}
  2282. // "width: 200px; height: {{y}}" -> {width: 200, height: y}
  2283. var dynamic = false;
  2284. var styleResult = '';
  2285. if (staticStyle) {
  2286. var styleList = staticStyle.trim().split(';').map(function (style) {
  2287. var result = style.trim().split(':');
  2288. if (result.length !== 2) {
  2289. return
  2290. }
  2291. var key = normalize(result[0].trim());
  2292. var value = result[1].trim();
  2293. var dynamicValue = parseText(value, options.delimiters);
  2294. if (dynamicValue) {
  2295. dynamic = true;
  2296. return key + ':' + dynamicValue
  2297. }
  2298. return key + ':' + JSON.stringify(value)
  2299. }).filter(function (result) { return result; });
  2300. if (styleList.length) {
  2301. styleResult = '{' + styleList.join(',') + '}';
  2302. }
  2303. }
  2304. return { dynamic: dynamic, styleResult: styleResult }
  2305. }
  2306. var style = {
  2307. staticKeys: ['staticStyle'],
  2308. transformNode: transformNode$1,
  2309. genData: genData$2
  2310. };
  2311. /* */
  2312. var normalize$1 = cached(camelize);
  2313. function normalizeKeyName (str) {
  2314. if (str.match(/^v\-/)) {
  2315. return str.replace(/(v-[a-z\-]+\:)([a-z\-]+)$/i, function ($, directive, prop) {
  2316. return directive + normalize$1(prop)
  2317. })
  2318. }
  2319. return normalize$1(str)
  2320. }
  2321. function transformNode$2 (el, options) {
  2322. if (Array.isArray(el.attrsList)) {
  2323. el.attrsList.forEach(function (attr) {
  2324. if (attr.name && attr.name.match(/\-/)) {
  2325. var realName = normalizeKeyName(attr.name);
  2326. if (el.attrsMap) {
  2327. el.attrsMap[realName] = el.attrsMap[attr.name];
  2328. delete el.attrsMap[attr.name];
  2329. }
  2330. attr.name = realName;
  2331. }
  2332. });
  2333. }
  2334. }
  2335. var props = {
  2336. transformNode: transformNode$2
  2337. };
  2338. /* */
  2339. function preTransformNode (el, options) {
  2340. if (el.tag === 'cell' && !el.attrsList.some(function (item) { return item.name === 'append'; })) {
  2341. el.attrsMap.append = 'tree';
  2342. el.attrsList.push({ name: 'append', value: 'tree' });
  2343. }
  2344. if (el.attrsMap.append === 'tree') {
  2345. el.appendAsTree = true;
  2346. }
  2347. }
  2348. function genData$3 (el) {
  2349. return el.appendAsTree ? "appendAsTree:true," : ''
  2350. }
  2351. var append = {
  2352. staticKeys: ['appendAsTree'],
  2353. preTransformNode: preTransformNode,
  2354. genData: genData$3
  2355. };
  2356. var modules = [
  2357. klass,
  2358. style,
  2359. props,
  2360. append
  2361. ];
  2362. /* */
  2363. /**
  2364. * Cross-platform code generation for component v-model
  2365. */
  2366. function genComponentModel (
  2367. el,
  2368. value,
  2369. modifiers
  2370. ) {
  2371. var ref = modifiers || {};
  2372. var number = ref.number;
  2373. var trim = ref.trim;
  2374. var baseValueExpression = '$$v';
  2375. var valueExpression = baseValueExpression;
  2376. if (trim) {
  2377. valueExpression =
  2378. "(typeof " + baseValueExpression + " === 'string'" +
  2379. "? " + baseValueExpression + ".trim()" +
  2380. ": " + baseValueExpression + ")";
  2381. }
  2382. if (number) {
  2383. valueExpression = "_n(" + valueExpression + ")";
  2384. }
  2385. var assignment = genAssignmentCode(value, valueExpression);
  2386. el.model = {
  2387. value: ("(" + value + ")"),
  2388. expression: ("\"" + value + "\""),
  2389. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  2390. };
  2391. }
  2392. /**
  2393. * Cross-platform codegen helper for generating v-model value assignment code.
  2394. */
  2395. function genAssignmentCode (
  2396. value,
  2397. assignment
  2398. ) {
  2399. var modelRs = parseModel(value);
  2400. if (modelRs.idx === null) {
  2401. return (value + "=" + assignment)
  2402. } else {
  2403. return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" +
  2404. "if (!Array.isArray($$exp)){" +
  2405. value + "=" + assignment + "}" +
  2406. "else{$$exp.splice($$idx, 1, " + assignment + ")}"
  2407. }
  2408. }
  2409. /**
  2410. * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
  2411. *
  2412. * for loop possible cases:
  2413. *
  2414. * - test
  2415. * - test[idx]
  2416. * - test[test1[idx]]
  2417. * - test["a"][idx]
  2418. * - xxx.test[a[a].test1[idx]]
  2419. * - test.xxx.a["asa"][test1[idx]]
  2420. *
  2421. */
  2422. var len;
  2423. var str;
  2424. var chr;
  2425. var index;
  2426. var expressionPos;
  2427. var expressionEndPos;
  2428. function parseModel (val) {
  2429. str = val;
  2430. len = str.length;
  2431. index = expressionPos = expressionEndPos = 0;
  2432. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  2433. return {
  2434. exp: val,
  2435. idx: null
  2436. }
  2437. }
  2438. while (!eof()) {
  2439. chr = next();
  2440. /* istanbul ignore if */
  2441. if (isStringStart(chr)) {
  2442. parseString(chr);
  2443. } else if (chr === 0x5B) {
  2444. parseBracket(chr);
  2445. }
  2446. }
  2447. return {
  2448. exp: val.substring(0, expressionPos),
  2449. idx: val.substring(expressionPos + 1, expressionEndPos)
  2450. }
  2451. }
  2452. function next () {
  2453. return str.charCodeAt(++index)
  2454. }
  2455. function eof () {
  2456. return index >= len
  2457. }
  2458. function isStringStart (chr) {
  2459. return chr === 0x22 || chr === 0x27
  2460. }
  2461. function parseBracket (chr) {
  2462. var inBracket = 1;
  2463. expressionPos = index;
  2464. while (!eof()) {
  2465. chr = next();
  2466. if (isStringStart(chr)) {
  2467. parseString(chr);
  2468. continue
  2469. }
  2470. if (chr === 0x5B) { inBracket++; }
  2471. if (chr === 0x5D) { inBracket--; }
  2472. if (inBracket === 0) {
  2473. expressionEndPos = index;
  2474. break
  2475. }
  2476. }
  2477. }
  2478. function parseString (chr) {
  2479. var stringQuote = chr;
  2480. while (!eof()) {
  2481. chr = next();
  2482. if (chr === stringQuote) {
  2483. break
  2484. }
  2485. }
  2486. }
  2487. /* */
  2488. function model (
  2489. el,
  2490. dir,
  2491. _warn
  2492. ) {
  2493. if (el.tag === 'input' || el.tag === 'textarea') {
  2494. genDefaultModel(el, dir.value, dir.modifiers);
  2495. } else {
  2496. genComponentModel(el, dir.value, dir.modifiers);
  2497. }
  2498. }
  2499. function genDefaultModel (
  2500. el,
  2501. value,
  2502. modifiers
  2503. ) {
  2504. var ref = modifiers || {};
  2505. var lazy = ref.lazy;
  2506. var trim = ref.trim;
  2507. var number = ref.number;
  2508. var event = lazy ? 'change' : 'input';
  2509. var valueExpression = "$event.target.attr.value" + (trim ? '.trim()' : '');
  2510. if (number) {
  2511. valueExpression = "_n(" + valueExpression + ")";
  2512. }
  2513. var code = genAssignmentCode(value, valueExpression);
  2514. addAttr(el, 'value', ("(" + value + ")"));
  2515. addHandler(el, event, code, null, true);
  2516. }
  2517. var directives = {
  2518. model: model
  2519. };
  2520. /* globals renderer */
  2521. var isReservedTag = makeMap(
  2522. 'div,img,image,input,switch,indicator,list,scroller,cell,template,text,slider,image'
  2523. );
  2524. function isUnaryTag$1 () { /* console.log('isUnaryTag') */ }
  2525. function mustUseProp () { /* console.log('mustUseProp') */ }
  2526. function getTagNamespace () { /* console.log('getTagNamespace') */ }
  2527. /* */
  2528. var baseOptions = {
  2529. modules: modules,
  2530. directives: directives,
  2531. isUnaryTag: isUnaryTag$1,
  2532. mustUseProp: mustUseProp,
  2533. isReservedTag: isReservedTag,
  2534. getTagNamespace: getTagNamespace,
  2535. preserveWhitespace: false,
  2536. staticKeys: genStaticKeys(modules)
  2537. };
  2538. var ref = createCompiler(baseOptions);
  2539. var compile = ref.compile;
  2540. /* */
  2541. exports.compile = compile;