You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5378 lines
141 KiB

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