1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var deindent = require('de-indent');
|
6 | var he = require('he');
|
7 |
|
8 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
9 |
|
10 | var deindent__default = _interopDefaultLegacy(deindent);
|
11 | var he__default = _interopDefaultLegacy(he);
|
12 |
|
13 | const emptyObject = Object.freeze({});
|
14 | const isArray = Array.isArray;
|
15 |
|
16 |
|
17 | function isUndef(v) {
|
18 | return v === undefined || v === null;
|
19 | }
|
20 | function isDef(v) {
|
21 | return v !== undefined && v !== null;
|
22 | }
|
23 | function isTrue(v) {
|
24 | return v === true;
|
25 | }
|
26 | function isFalse(v) {
|
27 | return v === false;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | function isPrimitive(value) {
|
33 | return (typeof value === 'string' ||
|
34 | typeof value === 'number' ||
|
35 |
|
36 | typeof value === 'symbol' ||
|
37 | typeof value === 'boolean');
|
38 | }
|
39 | function isFunction(value) {
|
40 | return typeof value === 'function';
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | function isObject(obj) {
|
48 | return obj !== null && typeof obj === 'object';
|
49 | }
|
50 |
|
51 |
|
52 |
|
53 | const _toString = Object.prototype.toString;
|
54 | function toRawType(value) {
|
55 | return _toString.call(value).slice(8, -1);
|
56 | }
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | function isPlainObject(obj) {
|
62 | return _toString.call(obj) === '[object Object]';
|
63 | }
|
64 |
|
65 |
|
66 |
|
67 | function isValidArrayIndex(val) {
|
68 | const n = parseFloat(String(val));
|
69 | return n >= 0 && Math.floor(n) === n && isFinite(val);
|
70 | }
|
71 | function isPromise(val) {
|
72 | return (isDef(val) &&
|
73 | typeof val.then === 'function' &&
|
74 | typeof val.catch === 'function');
|
75 | }
|
76 |
|
77 |
|
78 |
|
79 | function toString(val) {
|
80 | return val == null
|
81 | ? ''
|
82 | : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
|
83 | ? JSON.stringify(val, replacer, 2)
|
84 | : String(val);
|
85 | }
|
86 | function replacer(_key, val) {
|
87 |
|
88 | if (val && val.__v_isRef) {
|
89 | return val.value;
|
90 | }
|
91 | return val;
|
92 | }
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | function toNumber(val) {
|
98 | const n = parseFloat(val);
|
99 | return isNaN(n) ? val : n;
|
100 | }
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | function makeMap(str, expectsLowerCase) {
|
106 | const map = Object.create(null);
|
107 | const list = str.split(',');
|
108 | for (let i = 0; i < list.length; i++) {
|
109 | map[list[i]] = true;
|
110 | }
|
111 | return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
|
112 | }
|
113 |
|
114 |
|
115 |
|
116 | const isBuiltInTag = makeMap('slot,component', true);
|
117 |
|
118 |
|
119 |
|
120 | const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
|
121 |
|
122 |
|
123 |
|
124 | const hasOwnProperty = Object.prototype.hasOwnProperty;
|
125 | function hasOwn(obj, key) {
|
126 | return hasOwnProperty.call(obj, key);
|
127 | }
|
128 |
|
129 |
|
130 |
|
131 | function cached(fn) {
|
132 | const cache = Object.create(null);
|
133 | return function cachedFn(str) {
|
134 | const hit = cache[str];
|
135 | return hit || (cache[str] = fn(str));
|
136 | };
|
137 | }
|
138 |
|
139 |
|
140 |
|
141 | const camelizeRE = /-(\w)/g;
|
142 | const camelize = cached((str) => {
|
143 | return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
|
144 | });
|
145 |
|
146 |
|
147 |
|
148 | const capitalize = cached((str) => {
|
149 | return str.charAt(0).toUpperCase() + str.slice(1);
|
150 | });
|
151 |
|
152 |
|
153 |
|
154 | const hyphenateRE = /\B([A-Z])/g;
|
155 | const hyphenate = cached((str) => {
|
156 | return str.replace(hyphenateRE, '-$1').toLowerCase();
|
157 | });
|
158 |
|
159 |
|
160 |
|
161 | function extend(to, _from) {
|
162 | for (const key in _from) {
|
163 | to[key] = _from[key];
|
164 | }
|
165 | return to;
|
166 | }
|
167 |
|
168 |
|
169 |
|
170 | function toObject(arr) {
|
171 | const res = {};
|
172 | for (let i = 0; i < arr.length; i++) {
|
173 | if (arr[i]) {
|
174 | extend(res, arr[i]);
|
175 | }
|
176 | }
|
177 | return res;
|
178 | }
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 | function noop(a, b, c) { }
|
186 |
|
187 |
|
188 |
|
189 | const no = (a, b, c) => false;
|
190 |
|
191 |
|
192 |
|
193 |
|
194 | const identity = (_) => _;
|
195 |
|
196 |
|
197 |
|
198 | function genStaticKeys$1(modules) {
|
199 | return modules
|
200 | .reduce((keys, m) => keys.concat(m.staticKeys || []), [])
|
201 | .join(',');
|
202 | }
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | function looseEqual(a, b) {
|
208 | if (a === b)
|
209 | return true;
|
210 | const isObjectA = isObject(a);
|
211 | const isObjectB = isObject(b);
|
212 | if (isObjectA && isObjectB) {
|
213 | try {
|
214 | const isArrayA = Array.isArray(a);
|
215 | const isArrayB = Array.isArray(b);
|
216 | if (isArrayA && isArrayB) {
|
217 | return (a.length === b.length &&
|
218 | a.every((e, i) => {
|
219 | return looseEqual(e, b[i]);
|
220 | }));
|
221 | }
|
222 | else if (a instanceof Date && b instanceof Date) {
|
223 | return a.getTime() === b.getTime();
|
224 | }
|
225 | else if (!isArrayA && !isArrayB) {
|
226 | const keysA = Object.keys(a);
|
227 | const keysB = Object.keys(b);
|
228 | return (keysA.length === keysB.length &&
|
229 | keysA.every(key => {
|
230 | return looseEqual(a[key], b[key]);
|
231 | }));
|
232 | }
|
233 | else {
|
234 |
|
235 | return false;
|
236 | }
|
237 | }
|
238 | catch (e) {
|
239 |
|
240 | return false;
|
241 | }
|
242 | }
|
243 | else if (!isObjectA && !isObjectB) {
|
244 | return String(a) === String(b);
|
245 | }
|
246 | else {
|
247 | return false;
|
248 | }
|
249 | }
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | function looseIndexOf(arr, val) {
|
256 | for (let i = 0; i < arr.length; i++) {
|
257 | if (looseEqual(arr[i], val))
|
258 | return i;
|
259 | }
|
260 | return -1;
|
261 | }
|
262 |
|
263 | function hasChanged(x, y) {
|
264 | if (x === y) {
|
265 | return x === 0 && 1 / x !== 1 / y;
|
266 | }
|
267 | else {
|
268 | return x === x || y === y;
|
269 | }
|
270 | }
|
271 |
|
272 | const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
|
273 | 'link,meta,param,source,track,wbr');
|
274 |
|
275 |
|
276 | const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
|
277 |
|
278 |
|
279 | const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
|
280 | 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
|
281 | 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
|
282 | 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
|
283 | 'title,tr,track');
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | const 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/;
|
291 |
|
292 |
|
293 |
|
294 | function def(obj, key, val, enumerable) {
|
295 | Object.defineProperty(obj, key, {
|
296 | value: val,
|
297 | enumerable: !!enumerable,
|
298 | writable: true,
|
299 | configurable: true
|
300 | });
|
301 | }
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 | const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
|
308 | const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
|
309 | const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
|
310 | const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
|
311 | const startTagOpen = new RegExp(`^<${qnameCapture}`);
|
312 | const startTagClose = /^\s*(\/?)>/;
|
313 | const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
|
314 | const doctype = /^<!DOCTYPE [^>]+>/i;
|
315 |
|
316 | const comment = /^<!\--/;
|
317 | const conditionalComment = /^<!\[/;
|
318 |
|
319 | const isPlainTextElement = makeMap('script,style,textarea', true);
|
320 | const reCache = {};
|
321 | const decodingMap = {
|
322 | '<': '<',
|
323 | '>': '>',
|
324 | '"': '"',
|
325 | '&': '&',
|
326 | ' ': '\n',
|
327 | '	': '\t',
|
328 | ''': "'"
|
329 | };
|
330 | const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
|
331 | const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
|
332 |
|
333 | const isIgnoreNewlineTag = makeMap('pre,textarea', true);
|
334 | const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
|
335 | function decodeAttr(value, shouldDecodeNewlines) {
|
336 | const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
|
337 | return value.replace(re, match => decodingMap[match]);
|
338 | }
|
339 | function parseHTML(html, options) {
|
340 | const stack = [];
|
341 | const expectHTML = options.expectHTML;
|
342 | const isUnaryTag = options.isUnaryTag || no;
|
343 | const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
|
344 | let index = 0;
|
345 | let last, lastTag;
|
346 | while (html) {
|
347 | last = html;
|
348 |
|
349 | if (!lastTag || !isPlainTextElement(lastTag)) {
|
350 | let textEnd = html.indexOf('<');
|
351 | if (textEnd === 0) {
|
352 |
|
353 | if (comment.test(html)) {
|
354 | const commentEnd = html.indexOf('-->');
|
355 | if (commentEnd >= 0) {
|
356 | if (options.shouldKeepComment && options.comment) {
|
357 | options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
|
358 | }
|
359 | advance(commentEnd + 3);
|
360 | continue;
|
361 | }
|
362 | }
|
363 |
|
364 | if (conditionalComment.test(html)) {
|
365 | const conditionalEnd = html.indexOf(']>');
|
366 | if (conditionalEnd >= 0) {
|
367 | advance(conditionalEnd + 2);
|
368 | continue;
|
369 | }
|
370 | }
|
371 |
|
372 | const doctypeMatch = html.match(doctype);
|
373 | if (doctypeMatch) {
|
374 | advance(doctypeMatch[0].length);
|
375 | continue;
|
376 | }
|
377 |
|
378 | const endTagMatch = html.match(endTag);
|
379 | if (endTagMatch) {
|
380 | const curIndex = index;
|
381 | advance(endTagMatch[0].length);
|
382 | parseEndTag(endTagMatch[1], curIndex, index);
|
383 | continue;
|
384 | }
|
385 |
|
386 | const startTagMatch = parseStartTag();
|
387 | if (startTagMatch) {
|
388 | handleStartTag(startTagMatch);
|
389 | if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
|
390 | advance(1);
|
391 | }
|
392 | continue;
|
393 | }
|
394 | }
|
395 | let text, rest, next;
|
396 | if (textEnd >= 0) {
|
397 | rest = html.slice(textEnd);
|
398 | while (!endTag.test(rest) &&
|
399 | !startTagOpen.test(rest) &&
|
400 | !comment.test(rest) &&
|
401 | !conditionalComment.test(rest)) {
|
402 |
|
403 | next = rest.indexOf('<', 1);
|
404 | if (next < 0)
|
405 | break;
|
406 | textEnd += next;
|
407 | rest = html.slice(textEnd);
|
408 | }
|
409 | text = html.substring(0, textEnd);
|
410 | }
|
411 | if (textEnd < 0) {
|
412 | text = html;
|
413 | }
|
414 | if (text) {
|
415 | advance(text.length);
|
416 | }
|
417 | if (options.chars && text) {
|
418 | options.chars(text, index - text.length, index);
|
419 | }
|
420 | }
|
421 | else {
|
422 | let endTagLength = 0;
|
423 | const stackedTag = lastTag.toLowerCase();
|
424 | const reStackedTag = reCache[stackedTag] ||
|
425 | (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
|
426 | const rest = html.replace(reStackedTag, function (all, text, endTag) {
|
427 | endTagLength = endTag.length;
|
428 | if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
|
429 | text = text
|
430 | .replace(/<!\--([\s\S]*?)-->/g, '$1')
|
431 | .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
|
432 | }
|
433 | if (shouldIgnoreFirstNewline(stackedTag, text)) {
|
434 | text = text.slice(1);
|
435 | }
|
436 | if (options.chars) {
|
437 | options.chars(text);
|
438 | }
|
439 | return '';
|
440 | });
|
441 | index += html.length - rest.length;
|
442 | html = rest;
|
443 | parseEndTag(stackedTag, index - endTagLength, index);
|
444 | }
|
445 | if (html === last) {
|
446 | options.chars && options.chars(html);
|
447 | if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
|
448 | options.warn(`Mal-formatted tag at end of template: "${html}"`, {
|
449 | start: index + html.length
|
450 | });
|
451 | }
|
452 | break;
|
453 | }
|
454 | }
|
455 |
|
456 | parseEndTag();
|
457 | function advance(n) {
|
458 | index += n;
|
459 | html = html.substring(n);
|
460 | }
|
461 | function parseStartTag() {
|
462 | const start = html.match(startTagOpen);
|
463 | if (start) {
|
464 | const match = {
|
465 | tagName: start[1],
|
466 | attrs: [],
|
467 | start: index
|
468 | };
|
469 | advance(start[0].length);
|
470 | let end, attr;
|
471 | while (!(end = html.match(startTagClose)) &&
|
472 | (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
|
473 | attr.start = index;
|
474 | advance(attr[0].length);
|
475 | attr.end = index;
|
476 | match.attrs.push(attr);
|
477 | }
|
478 | if (end) {
|
479 | match.unarySlash = end[1];
|
480 | advance(end[0].length);
|
481 | match.end = index;
|
482 | return match;
|
483 | }
|
484 | }
|
485 | }
|
486 | function handleStartTag(match) {
|
487 | const tagName = match.tagName;
|
488 | const unarySlash = match.unarySlash;
|
489 | if (expectHTML) {
|
490 | if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
|
491 | parseEndTag(lastTag);
|
492 | }
|
493 | if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
|
494 | parseEndTag(tagName);
|
495 | }
|
496 | }
|
497 | const unary = isUnaryTag(tagName) || !!unarySlash;
|
498 | const l = match.attrs.length;
|
499 | const attrs = new Array(l);
|
500 | for (let i = 0; i < l; i++) {
|
501 | const args = match.attrs[i];
|
502 | const value = args[3] || args[4] || args[5] || '';
|
503 | const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
|
504 | ? options.shouldDecodeNewlinesForHref
|
505 | : options.shouldDecodeNewlines;
|
506 | attrs[i] = {
|
507 | name: args[1],
|
508 | value: decodeAttr(value, shouldDecodeNewlines)
|
509 | };
|
510 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
511 | attrs[i].start = args.start + args[0].match(/^\s*/).length;
|
512 | attrs[i].end = args.end;
|
513 | }
|
514 | }
|
515 | if (!unary) {
|
516 | stack.push({
|
517 | tag: tagName,
|
518 | lowerCasedTag: tagName.toLowerCase(),
|
519 | attrs: attrs,
|
520 | start: match.start,
|
521 | end: match.end
|
522 | });
|
523 | lastTag = tagName;
|
524 | }
|
525 | if (options.start) {
|
526 | options.start(tagName, attrs, unary, match.start, match.end);
|
527 | }
|
528 | }
|
529 | function parseEndTag(tagName, start, end) {
|
530 | let pos, lowerCasedTagName;
|
531 | if (start == null)
|
532 | start = index;
|
533 | if (end == null)
|
534 | end = index;
|
535 |
|
536 | if (tagName) {
|
537 | lowerCasedTagName = tagName.toLowerCase();
|
538 | for (pos = stack.length - 1; pos >= 0; pos--) {
|
539 | if (stack[pos].lowerCasedTag === lowerCasedTagName) {
|
540 | break;
|
541 | }
|
542 | }
|
543 | }
|
544 | else {
|
545 |
|
546 | pos = 0;
|
547 | }
|
548 | if (pos >= 0) {
|
549 |
|
550 | for (let i = stack.length - 1; i >= pos; i--) {
|
551 | if (process.env.NODE_ENV !== 'production' && (i > pos || !tagName) && options.warn) {
|
552 | options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
|
553 | start: stack[i].start,
|
554 | end: stack[i].end
|
555 | });
|
556 | }
|
557 | if (options.end) {
|
558 | options.end(stack[i].tag, start, end);
|
559 | }
|
560 | }
|
561 |
|
562 | stack.length = pos;
|
563 | lastTag = pos && stack[pos - 1].tag;
|
564 | }
|
565 | else if (lowerCasedTagName === 'br') {
|
566 | if (options.start) {
|
567 | options.start(tagName, [], true, start, end);
|
568 | }
|
569 | }
|
570 | else if (lowerCasedTagName === 'p') {
|
571 | if (options.start) {
|
572 | options.start(tagName, [], false, start, end);
|
573 | }
|
574 | if (options.end) {
|
575 | options.end(tagName, start, end);
|
576 | }
|
577 | }
|
578 | }
|
579 | }
|
580 |
|
581 | const DEFAULT_FILENAME = 'anonymous.vue';
|
582 | const splitRE = /\r?\n/g;
|
583 | const replaceRE = /./g;
|
584 | const isSpecialTag = makeMap('script,style,template', true);
|
585 |
|
586 |
|
587 |
|
588 | function parseComponent(source, options = {}) {
|
589 | const sfc = {
|
590 | source,
|
591 | filename: DEFAULT_FILENAME,
|
592 | template: null,
|
593 | script: null,
|
594 | scriptSetup: null,
|
595 | styles: [],
|
596 | customBlocks: [],
|
597 | cssVars: [],
|
598 | errors: [],
|
599 | shouldForceReload: null
|
600 | };
|
601 | let depth = 0;
|
602 | let currentBlock = null;
|
603 | let warn = msg => {
|
604 | sfc.errors.push(msg);
|
605 | };
|
606 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
607 | warn = (msg, range) => {
|
608 | const data = { msg };
|
609 | if (range.start != null) {
|
610 | data.start = range.start;
|
611 | }
|
612 | if (range.end != null) {
|
613 | data.end = range.end;
|
614 | }
|
615 | sfc.errors.push(data);
|
616 | };
|
617 | }
|
618 | function start(tag, attrs, unary, start, end) {
|
619 | if (depth === 0) {
|
620 | currentBlock = {
|
621 | type: tag,
|
622 | content: '',
|
623 | start: end,
|
624 | end: 0,
|
625 | attrs: attrs.reduce((cumulated, { name, value }) => {
|
626 | cumulated[name] = value || true;
|
627 | return cumulated;
|
628 | }, {})
|
629 | };
|
630 | if (typeof currentBlock.attrs.src === 'string') {
|
631 | currentBlock.src = currentBlock.attrs.src;
|
632 | }
|
633 | if (isSpecialTag(tag)) {
|
634 | checkAttrs(currentBlock, attrs);
|
635 | if (tag === 'script') {
|
636 | const block = currentBlock;
|
637 | if (block.attrs.setup) {
|
638 | block.setup = currentBlock.attrs.setup;
|
639 | sfc.scriptSetup = block;
|
640 | }
|
641 | else {
|
642 | sfc.script = block;
|
643 | }
|
644 | }
|
645 | else if (tag === 'style') {
|
646 | sfc.styles.push(currentBlock);
|
647 | }
|
648 | else {
|
649 | sfc[tag] = currentBlock;
|
650 | }
|
651 | }
|
652 | else {
|
653 |
|
654 | sfc.customBlocks.push(currentBlock);
|
655 | }
|
656 | }
|
657 | if (!unary) {
|
658 | depth++;
|
659 | }
|
660 | }
|
661 | function checkAttrs(block, attrs) {
|
662 | for (let i = 0; i < attrs.length; i++) {
|
663 | const attr = attrs[i];
|
664 | if (attr.name === 'lang') {
|
665 | block.lang = attr.value;
|
666 | }
|
667 | if (attr.name === 'scoped') {
|
668 | block.scoped = true;
|
669 | }
|
670 | if (attr.name === 'module') {
|
671 | block.module = attr.value || true;
|
672 | }
|
673 | }
|
674 | }
|
675 | function end(tag, start) {
|
676 | if (depth === 1 && currentBlock) {
|
677 | currentBlock.end = start;
|
678 | let text = source.slice(currentBlock.start, currentBlock.end);
|
679 | if (options.deindent === true ||
|
680 |
|
681 | (options.deindent !== false &&
|
682 | !(currentBlock.type === 'script' &&
|
683 | (!currentBlock.lang || /^(j|t)sx?$/.test(currentBlock.lang))))) {
|
684 | text = deindent__default["default"](text);
|
685 | }
|
686 |
|
687 |
|
688 | if (currentBlock.type !== 'template' && options.pad) {
|
689 | text = padContent(currentBlock, options.pad) + text;
|
690 | }
|
691 | currentBlock.content = text;
|
692 | currentBlock = null;
|
693 | }
|
694 | depth--;
|
695 | }
|
696 | function padContent(block, pad) {
|
697 | if (pad === 'space') {
|
698 | return source.slice(0, block.start).replace(replaceRE, ' ');
|
699 | }
|
700 | else {
|
701 | const offset = source.slice(0, block.start).split(splitRE).length;
|
702 | const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n';
|
703 | return Array(offset).join(padChar);
|
704 | }
|
705 | }
|
706 | parseHTML(source, {
|
707 | warn,
|
708 | start,
|
709 | end,
|
710 | outputSourceRange: options.outputSourceRange
|
711 | });
|
712 | return sfc;
|
713 | }
|
714 |
|
715 |
|
716 | const hasProto = '__proto__' in {};
|
717 |
|
718 | const inBrowser = typeof window !== 'undefined';
|
719 | const UA = inBrowser && window.navigator.userAgent.toLowerCase();
|
720 | const isIE = UA && /msie|trident/.test(UA);
|
721 | UA && UA.indexOf('msie 9.0') > 0;
|
722 | const isEdge = UA && UA.indexOf('edge/') > 0;
|
723 | UA && UA.indexOf('android') > 0;
|
724 | UA && /iphone|ipad|ipod|ios/.test(UA);
|
725 | UA && /chrome\/\d+/.test(UA) && !isEdge;
|
726 | UA && /phantomjs/.test(UA);
|
727 | UA && UA.match(/firefox\/(\d+)/);
|
728 |
|
729 |
|
730 | const nativeWatch = {}.watch;
|
731 | let supportsPassive = false;
|
732 | if (inBrowser) {
|
733 | try {
|
734 | const opts = {};
|
735 | Object.defineProperty(opts, 'passive', {
|
736 | get() {
|
737 |
|
738 | supportsPassive = true;
|
739 | }
|
740 | });
|
741 | window.addEventListener('test-passive', null, opts);
|
742 | }
|
743 | catch (e) { }
|
744 | }
|
745 |
|
746 |
|
747 | let _isServer;
|
748 | const isServerRendering = () => {
|
749 | if (_isServer === undefined) {
|
750 |
|
751 | if (!inBrowser && typeof global !== 'undefined') {
|
752 |
|
753 |
|
754 | _isServer =
|
755 | global['process'] && global['process'].env.VUE_ENV === 'server';
|
756 | }
|
757 | else {
|
758 | _isServer = false;
|
759 | }
|
760 | }
|
761 | return _isServer;
|
762 | };
|
763 |
|
764 | function isNative(Ctor) {
|
765 | return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
|
766 | }
|
767 | const hasSymbol = typeof Symbol !== 'undefined' &&
|
768 | isNative(Symbol) &&
|
769 | typeof Reflect !== 'undefined' &&
|
770 | isNative(Reflect.ownKeys);
|
771 | let _Set;
|
772 | if (typeof Set !== 'undefined' && isNative(Set)) {
|
773 |
|
774 | _Set = Set;
|
775 | }
|
776 | else {
|
777 |
|
778 | _Set = class Set {
|
779 | constructor() {
|
780 | this.set = Object.create(null);
|
781 | }
|
782 | has(key) {
|
783 | return this.set[key] === true;
|
784 | }
|
785 | add(key) {
|
786 | this.set[key] = true;
|
787 | }
|
788 | clear() {
|
789 | this.set = Object.create(null);
|
790 | }
|
791 | };
|
792 | }
|
793 |
|
794 | const ASSET_TYPES = ['component', 'directive', 'filter'];
|
795 | const LIFECYCLE_HOOKS = [
|
796 | 'beforeCreate',
|
797 | 'created',
|
798 | 'beforeMount',
|
799 | 'mounted',
|
800 | 'beforeUpdate',
|
801 | 'updated',
|
802 | 'beforeDestroy',
|
803 | 'destroyed',
|
804 | 'activated',
|
805 | 'deactivated',
|
806 | 'errorCaptured',
|
807 | 'serverPrefetch',
|
808 | 'renderTracked',
|
809 | 'renderTriggered'
|
810 | ];
|
811 |
|
812 | var config = {
|
813 | |
814 |
|
815 |
|
816 |
|
817 | optionMergeStrategies: Object.create(null),
|
818 | |
819 |
|
820 |
|
821 | silent: false,
|
822 | |
823 |
|
824 |
|
825 | productionTip: process.env.NODE_ENV !== 'production',
|
826 | |
827 |
|
828 |
|
829 | devtools: process.env.NODE_ENV !== 'production',
|
830 | |
831 |
|
832 |
|
833 | performance: false,
|
834 | |
835 |
|
836 |
|
837 | errorHandler: null,
|
838 | |
839 |
|
840 |
|
841 | warnHandler: null,
|
842 | |
843 |
|
844 |
|
845 | ignoredElements: [],
|
846 | |
847 |
|
848 |
|
849 |
|
850 | keyCodes: Object.create(null),
|
851 | |
852 |
|
853 |
|
854 |
|
855 | isReservedTag: no,
|
856 | |
857 |
|
858 |
|
859 |
|
860 | isReservedAttr: no,
|
861 | |
862 |
|
863 |
|
864 |
|
865 | isUnknownElement: no,
|
866 | |
867 |
|
868 |
|
869 | getTagNamespace: noop,
|
870 | |
871 |
|
872 |
|
873 | parsePlatformTagName: identity,
|
874 | |
875 |
|
876 |
|
877 |
|
878 | mustUseProp: no,
|
879 | |
880 |
|
881 |
|
882 |
|
883 | async: true,
|
884 | |
885 |
|
886 |
|
887 | _lifecycleHooks: LIFECYCLE_HOOKS
|
888 | };
|
889 |
|
890 | let currentInstance = null;
|
891 |
|
892 |
|
893 |
|
894 | function setCurrentInstance(vm = null) {
|
895 | if (!vm)
|
896 | currentInstance && currentInstance._scope.off();
|
897 | currentInstance = vm;
|
898 | vm && vm._scope.on();
|
899 | }
|
900 |
|
901 |
|
902 |
|
903 |
|
904 | class VNode {
|
905 | constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
|
906 | this.tag = tag;
|
907 | this.data = data;
|
908 | this.children = children;
|
909 | this.text = text;
|
910 | this.elm = elm;
|
911 | this.ns = undefined;
|
912 | this.context = context;
|
913 | this.fnContext = undefined;
|
914 | this.fnOptions = undefined;
|
915 | this.fnScopeId = undefined;
|
916 | this.key = data && data.key;
|
917 | this.componentOptions = componentOptions;
|
918 | this.componentInstance = undefined;
|
919 | this.parent = undefined;
|
920 | this.raw = false;
|
921 | this.isStatic = false;
|
922 | this.isRootInsert = true;
|
923 | this.isComment = false;
|
924 | this.isCloned = false;
|
925 | this.isOnce = false;
|
926 | this.asyncFactory = asyncFactory;
|
927 | this.asyncMeta = undefined;
|
928 | this.isAsyncPlaceholder = false;
|
929 | }
|
930 |
|
931 |
|
932 | get child() {
|
933 | return this.componentInstance;
|
934 | }
|
935 | }
|
936 | const createEmptyVNode = (text = '') => {
|
937 | const node = new VNode();
|
938 | node.text = text;
|
939 | node.isComment = true;
|
940 | return node;
|
941 | };
|
942 | function createTextVNode(val) {
|
943 | return new VNode(undefined, undefined, undefined, String(val));
|
944 | }
|
945 |
|
946 |
|
947 |
|
948 |
|
949 | function cloneVNode(vnode) {
|
950 | const cloned = new VNode(vnode.tag, vnode.data,
|
951 |
|
952 |
|
953 |
|
954 | vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
|
955 | cloned.ns = vnode.ns;
|
956 | cloned.isStatic = vnode.isStatic;
|
957 | cloned.key = vnode.key;
|
958 | cloned.isComment = vnode.isComment;
|
959 | cloned.fnContext = vnode.fnContext;
|
960 | cloned.fnOptions = vnode.fnOptions;
|
961 | cloned.fnScopeId = vnode.fnScopeId;
|
962 | cloned.asyncMeta = vnode.asyncMeta;
|
963 | cloned.isCloned = true;
|
964 | return cloned;
|
965 | }
|
966 |
|
967 |
|
968 | if (process.env.NODE_ENV !== 'production') {
|
969 | makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
|
970 | 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
|
971 | 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
|
972 | 'require'
|
973 | );
|
974 | const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
|
975 | if (hasProxy) {
|
976 | const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
|
977 | config.keyCodes = new Proxy(config.keyCodes, {
|
978 | set(target, key, value) {
|
979 | if (isBuiltInModifier(key)) {
|
980 | warn$2(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
|
981 | return false;
|
982 | }
|
983 | else {
|
984 | target[key] = value;
|
985 | return true;
|
986 | }
|
987 | }
|
988 | });
|
989 | }
|
990 | }
|
991 |
|
992 | let uid = 0;
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 | class Dep {
|
999 | constructor() {
|
1000 |
|
1001 | this._pending = false;
|
1002 | this.id = uid++;
|
1003 | this.subs = [];
|
1004 | }
|
1005 | addSub(sub) {
|
1006 | this.subs.push(sub);
|
1007 | }
|
1008 | removeSub(sub) {
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 | this.subs[this.subs.indexOf(sub)] = null;
|
1014 | if (!this._pending) {
|
1015 | this._pending = true;
|
1016 | }
|
1017 | }
|
1018 | depend(info) {
|
1019 | if (Dep.target) {
|
1020 | Dep.target.addDep(this);
|
1021 | if (process.env.NODE_ENV !== 'production' && info && Dep.target.onTrack) {
|
1022 | Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
|
1023 | }
|
1024 | }
|
1025 | }
|
1026 | notify(info) {
|
1027 |
|
1028 | const subs = this.subs.filter(s => s);
|
1029 | if (process.env.NODE_ENV !== 'production' && !config.async) {
|
1030 |
|
1031 |
|
1032 |
|
1033 | subs.sort((a, b) => a.id - b.id);
|
1034 | }
|
1035 | for (let i = 0, l = subs.length; i < l; i++) {
|
1036 | const sub = subs[i];
|
1037 | if (process.env.NODE_ENV !== 'production' && info) {
|
1038 | sub.onTrigger &&
|
1039 | sub.onTrigger(Object.assign({ effect: subs[i] }, info));
|
1040 | }
|
1041 | sub.update();
|
1042 | }
|
1043 | }
|
1044 | }
|
1045 |
|
1046 |
|
1047 |
|
1048 | Dep.target = null;
|
1049 | const targetStack = [];
|
1050 | function pushTarget(target) {
|
1051 | targetStack.push(target);
|
1052 | Dep.target = target;
|
1053 | }
|
1054 | function popTarget() {
|
1055 | targetStack.pop();
|
1056 | Dep.target = targetStack[targetStack.length - 1];
|
1057 | }
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 | const arrayProto = Array.prototype;
|
1064 | const arrayMethods = Object.create(arrayProto);
|
1065 | const methodsToPatch = [
|
1066 | 'push',
|
1067 | 'pop',
|
1068 | 'shift',
|
1069 | 'unshift',
|
1070 | 'splice',
|
1071 | 'sort',
|
1072 | 'reverse'
|
1073 | ];
|
1074 |
|
1075 |
|
1076 |
|
1077 | methodsToPatch.forEach(function (method) {
|
1078 |
|
1079 | const original = arrayProto[method];
|
1080 | def(arrayMethods, method, function mutator(...args) {
|
1081 | const result = original.apply(this, args);
|
1082 | const ob = this.__ob__;
|
1083 | let inserted;
|
1084 | switch (method) {
|
1085 | case 'push':
|
1086 | case 'unshift':
|
1087 | inserted = args;
|
1088 | break;
|
1089 | case 'splice':
|
1090 | inserted = args.slice(2);
|
1091 | break;
|
1092 | }
|
1093 | if (inserted)
|
1094 | ob.observeArray(inserted);
|
1095 |
|
1096 | if (process.env.NODE_ENV !== 'production') {
|
1097 | ob.dep.notify({
|
1098 | type: "array mutation" ,
|
1099 | target: this,
|
1100 | key: method
|
1101 | });
|
1102 | }
|
1103 | else {
|
1104 | ob.dep.notify();
|
1105 | }
|
1106 | return result;
|
1107 | });
|
1108 | });
|
1109 |
|
1110 | const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
1111 | const NO_INITIAL_VALUE = {};
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 | let shouldObserve = true;
|
1117 | function toggleObserving(value) {
|
1118 | shouldObserve = value;
|
1119 | }
|
1120 |
|
1121 | const mockDep = {
|
1122 | notify: noop,
|
1123 | depend: noop,
|
1124 | addSub: noop,
|
1125 | removeSub: noop
|
1126 | };
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 | class Observer {
|
1134 | constructor(value, shallow = false, mock = false) {
|
1135 | this.value = value;
|
1136 | this.shallow = shallow;
|
1137 | this.mock = mock;
|
1138 |
|
1139 | this.dep = mock ? mockDep : new Dep();
|
1140 | this.vmCount = 0;
|
1141 | def(value, '__ob__', this);
|
1142 | if (isArray(value)) {
|
1143 | if (!mock) {
|
1144 | if (hasProto) {
|
1145 | value.__proto__ = arrayMethods;
|
1146 |
|
1147 | }
|
1148 | else {
|
1149 | for (let i = 0, l = arrayKeys.length; i < l; i++) {
|
1150 | const key = arrayKeys[i];
|
1151 | def(value, key, arrayMethods[key]);
|
1152 | }
|
1153 | }
|
1154 | }
|
1155 | if (!shallow) {
|
1156 | this.observeArray(value);
|
1157 | }
|
1158 | }
|
1159 | else {
|
1160 | |
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 | const keys = Object.keys(value);
|
1166 | for (let i = 0; i < keys.length; i++) {
|
1167 | const key = keys[i];
|
1168 | defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
|
1169 | }
|
1170 | }
|
1171 | }
|
1172 | |
1173 |
|
1174 |
|
1175 | observeArray(value) {
|
1176 | for (let i = 0, l = value.length; i < l; i++) {
|
1177 | observe(value[i], false, this.mock);
|
1178 | }
|
1179 | }
|
1180 | }
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 | function observe(value, shallow, ssrMockReactivity) {
|
1188 | if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
|
1189 | return value.__ob__;
|
1190 | }
|
1191 | if (shouldObserve &&
|
1192 | (ssrMockReactivity || !isServerRendering()) &&
|
1193 | (isArray(value) || isPlainObject(value)) &&
|
1194 | Object.isExtensible(value) &&
|
1195 | !value.__v_skip &&
|
1196 | !isRef(value) &&
|
1197 | !(value instanceof VNode)) {
|
1198 | return new Observer(value, shallow, ssrMockReactivity);
|
1199 | }
|
1200 | }
|
1201 |
|
1202 |
|
1203 |
|
1204 | function defineReactive(obj, key, val, customSetter, shallow, mock, observeEvenIfShallow = false) {
|
1205 | const dep = new Dep();
|
1206 | const property = Object.getOwnPropertyDescriptor(obj, key);
|
1207 | if (property && property.configurable === false) {
|
1208 | return;
|
1209 | }
|
1210 |
|
1211 | const getter = property && property.get;
|
1212 | const setter = property && property.set;
|
1213 | if ((!getter || setter) &&
|
1214 | (val === NO_INITIAL_VALUE || arguments.length === 2)) {
|
1215 | val = obj[key];
|
1216 | }
|
1217 | let childOb = shallow ? val && val.__ob__ : observe(val, false, mock);
|
1218 | Object.defineProperty(obj, key, {
|
1219 | enumerable: true,
|
1220 | configurable: true,
|
1221 | get: function reactiveGetter() {
|
1222 | const value = getter ? getter.call(obj) : val;
|
1223 | if (Dep.target) {
|
1224 | if (process.env.NODE_ENV !== 'production') {
|
1225 | dep.depend({
|
1226 | target: obj,
|
1227 | type: "get" ,
|
1228 | key
|
1229 | });
|
1230 | }
|
1231 | else {
|
1232 | dep.depend();
|
1233 | }
|
1234 | if (childOb) {
|
1235 | childOb.dep.depend();
|
1236 | if (isArray(value)) {
|
1237 | dependArray(value);
|
1238 | }
|
1239 | }
|
1240 | }
|
1241 | return isRef(value) && !shallow ? value.value : value;
|
1242 | },
|
1243 | set: function reactiveSetter(newVal) {
|
1244 | const value = getter ? getter.call(obj) : val;
|
1245 | if (!hasChanged(value, newVal)) {
|
1246 | return;
|
1247 | }
|
1248 | if (process.env.NODE_ENV !== 'production' && customSetter) {
|
1249 | customSetter();
|
1250 | }
|
1251 | if (setter) {
|
1252 | setter.call(obj, newVal);
|
1253 | }
|
1254 | else if (getter) {
|
1255 |
|
1256 | return;
|
1257 | }
|
1258 | else if (!shallow && isRef(value) && !isRef(newVal)) {
|
1259 | value.value = newVal;
|
1260 | return;
|
1261 | }
|
1262 | else {
|
1263 | val = newVal;
|
1264 | }
|
1265 | childOb = shallow ? newVal && newVal.__ob__ : observe(newVal, false, mock);
|
1266 | if (process.env.NODE_ENV !== 'production') {
|
1267 | dep.notify({
|
1268 | type: "set" ,
|
1269 | target: obj,
|
1270 | key,
|
1271 | newValue: newVal,
|
1272 | oldValue: value
|
1273 | });
|
1274 | }
|
1275 | else {
|
1276 | dep.notify();
|
1277 | }
|
1278 | }
|
1279 | });
|
1280 | return dep;
|
1281 | }
|
1282 | function set(target, key, val) {
|
1283 | if (process.env.NODE_ENV !== 'production' && (isUndef(target) || isPrimitive(target))) {
|
1284 | warn$2(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
|
1285 | }
|
1286 | if (isReadonly(target)) {
|
1287 | process.env.NODE_ENV !== 'production' && warn$2(`Set operation on key "${key}" failed: target is readonly.`);
|
1288 | return;
|
1289 | }
|
1290 | const ob = target.__ob__;
|
1291 | if (isArray(target) && isValidArrayIndex(key)) {
|
1292 | target.length = Math.max(target.length, key);
|
1293 | target.splice(key, 1, val);
|
1294 |
|
1295 | if (ob && !ob.shallow && ob.mock) {
|
1296 | observe(val, false, true);
|
1297 | }
|
1298 | return val;
|
1299 | }
|
1300 | if (key in target && !(key in Object.prototype)) {
|
1301 | target[key] = val;
|
1302 | return val;
|
1303 | }
|
1304 | if (target._isVue || (ob && ob.vmCount)) {
|
1305 | process.env.NODE_ENV !== 'production' &&
|
1306 | warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
|
1307 | 'at runtime - declare it upfront in the data option.');
|
1308 | return val;
|
1309 | }
|
1310 | if (!ob) {
|
1311 | target[key] = val;
|
1312 | return val;
|
1313 | }
|
1314 | defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
|
1315 | if (process.env.NODE_ENV !== 'production') {
|
1316 | ob.dep.notify({
|
1317 | type: "add" ,
|
1318 | target: target,
|
1319 | key,
|
1320 | newValue: val,
|
1321 | oldValue: undefined
|
1322 | });
|
1323 | }
|
1324 | else {
|
1325 | ob.dep.notify();
|
1326 | }
|
1327 | return val;
|
1328 | }
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 | function dependArray(value) {
|
1334 | for (let e, i = 0, l = value.length; i < l; i++) {
|
1335 | e = value[i];
|
1336 | if (e && e.__ob__) {
|
1337 | e.__ob__.dep.depend();
|
1338 | }
|
1339 | if (isArray(e)) {
|
1340 | dependArray(e);
|
1341 | }
|
1342 | }
|
1343 | }
|
1344 |
|
1345 | function isReadonly(value) {
|
1346 | return !!(value && value.__v_isReadonly);
|
1347 | }
|
1348 |
|
1349 | function isRef(r) {
|
1350 | return !!(r && r.__v_isRef === true);
|
1351 | }
|
1352 |
|
1353 | if (process.env.NODE_ENV !== 'production') ;
|
1354 |
|
1355 | const normalizeEvent = cached((name) => {
|
1356 | const passive = name.charAt(0) === '&';
|
1357 | name = passive ? name.slice(1) : name;
|
1358 | const once = name.charAt(0) === '~';
|
1359 | name = once ? name.slice(1) : name;
|
1360 | const capture = name.charAt(0) === '!';
|
1361 | name = capture ? name.slice(1) : name;
|
1362 | return {
|
1363 | name,
|
1364 | once,
|
1365 | capture,
|
1366 | passive
|
1367 | };
|
1368 | });
|
1369 | function createFnInvoker(fns, vm) {
|
1370 | function invoker() {
|
1371 | const fns = invoker.fns;
|
1372 | if (isArray(fns)) {
|
1373 | const cloned = fns.slice();
|
1374 | for (let i = 0; i < cloned.length; i++) {
|
1375 | invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
|
1376 | }
|
1377 | }
|
1378 | else {
|
1379 |
|
1380 | return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
|
1381 | }
|
1382 | }
|
1383 | invoker.fns = fns;
|
1384 | return invoker;
|
1385 | }
|
1386 | function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
|
1387 | let name, cur, old, event;
|
1388 | for (name in on) {
|
1389 | cur = on[name];
|
1390 | old = oldOn[name];
|
1391 | event = normalizeEvent(name);
|
1392 | if (isUndef(cur)) {
|
1393 | process.env.NODE_ENV !== 'production' &&
|
1394 | warn$2(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
|
1395 | }
|
1396 | else if (isUndef(old)) {
|
1397 | if (isUndef(cur.fns)) {
|
1398 | cur = on[name] = createFnInvoker(cur, vm);
|
1399 | }
|
1400 | if (isTrue(event.once)) {
|
1401 | cur = on[name] = createOnceHandler(event.name, cur, event.capture);
|
1402 | }
|
1403 | add(event.name, cur, event.capture, event.passive, event.params);
|
1404 | }
|
1405 | else if (cur !== old) {
|
1406 | old.fns = cur;
|
1407 | on[name] = old;
|
1408 | }
|
1409 | }
|
1410 | for (name in oldOn) {
|
1411 | if (isUndef(on[name])) {
|
1412 | event = normalizeEvent(name);
|
1413 | remove(event.name, oldOn[name], event.capture);
|
1414 | }
|
1415 | }
|
1416 | }
|
1417 |
|
1418 | function extractPropsFromVNodeData(data, Ctor, tag) {
|
1419 |
|
1420 |
|
1421 |
|
1422 | const propOptions = Ctor.options.props;
|
1423 | if (isUndef(propOptions)) {
|
1424 | return;
|
1425 | }
|
1426 | const res = {};
|
1427 | const { attrs, props } = data;
|
1428 | if (isDef(attrs) || isDef(props)) {
|
1429 | for (const key in propOptions) {
|
1430 | const altKey = hyphenate(key);
|
1431 | if (process.env.NODE_ENV !== 'production') {
|
1432 | const keyInLowerCase = key.toLowerCase();
|
1433 | if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
|
1434 | tip(`Prop "${keyInLowerCase}" is passed to component ` +
|
1435 | `${formatComponentName(
|
1436 | // @ts-expect-error tag is string
|
1437 | tag || Ctor)}, but the declared prop name is` +
|
1438 | ` "${key}". ` +
|
1439 | `Note that HTML attributes are case-insensitive and camelCased ` +
|
1440 | `props need to use their kebab-case equivalents when using in-DOM ` +
|
1441 | `templates. You should probably use "${altKey}" instead of "${key}".`);
|
1442 | }
|
1443 | }
|
1444 | checkProp(res, props, key, altKey, true) ||
|
1445 | checkProp(res, attrs, key, altKey, false);
|
1446 | }
|
1447 | }
|
1448 | return res;
|
1449 | }
|
1450 | function checkProp(res, hash, key, altKey, preserve) {
|
1451 | if (isDef(hash)) {
|
1452 | if (hasOwn(hash, key)) {
|
1453 | res[key] = hash[key];
|
1454 | if (!preserve) {
|
1455 | delete hash[key];
|
1456 | }
|
1457 | return true;
|
1458 | }
|
1459 | else if (hasOwn(hash, altKey)) {
|
1460 | res[key] = hash[altKey];
|
1461 | if (!preserve) {
|
1462 | delete hash[altKey];
|
1463 | }
|
1464 | return true;
|
1465 | }
|
1466 | }
|
1467 | return false;
|
1468 | }
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 | function simpleNormalizeChildren(children) {
|
1482 | for (let i = 0; i < children.length; i++) {
|
1483 | if (isArray(children[i])) {
|
1484 | return Array.prototype.concat.apply([], children);
|
1485 | }
|
1486 | }
|
1487 | return children;
|
1488 | }
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 | function normalizeChildren(children) {
|
1494 | return isPrimitive(children)
|
1495 | ? [createTextVNode(children)]
|
1496 | : isArray(children)
|
1497 | ? normalizeArrayChildren(children)
|
1498 | : undefined;
|
1499 | }
|
1500 | function isTextNode(node) {
|
1501 | return isDef(node) && isDef(node.text) && isFalse(node.isComment);
|
1502 | }
|
1503 | function normalizeArrayChildren(children, nestedIndex) {
|
1504 | const res = [];
|
1505 | let i, c, lastIndex, last;
|
1506 | for (i = 0; i < children.length; i++) {
|
1507 | c = children[i];
|
1508 | if (isUndef(c) || typeof c === 'boolean')
|
1509 | continue;
|
1510 | lastIndex = res.length - 1;
|
1511 | last = res[lastIndex];
|
1512 |
|
1513 | if (isArray(c)) {
|
1514 | if (c.length > 0) {
|
1515 | c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
|
1516 |
|
1517 | if (isTextNode(c[0]) && isTextNode(last)) {
|
1518 | res[lastIndex] = createTextVNode(last.text + c[0].text);
|
1519 | c.shift();
|
1520 | }
|
1521 | res.push.apply(res, c);
|
1522 | }
|
1523 | }
|
1524 | else if (isPrimitive(c)) {
|
1525 | if (isTextNode(last)) {
|
1526 |
|
1527 |
|
1528 |
|
1529 | res[lastIndex] = createTextVNode(last.text + c);
|
1530 | }
|
1531 | else if (c !== '') {
|
1532 |
|
1533 | res.push(createTextVNode(c));
|
1534 | }
|
1535 | }
|
1536 | else {
|
1537 | if (isTextNode(c) && isTextNode(last)) {
|
1538 |
|
1539 | res[lastIndex] = createTextVNode(last.text + c.text);
|
1540 | }
|
1541 | else {
|
1542 |
|
1543 | if (isTrue(children._isVList) &&
|
1544 | isDef(c.tag) &&
|
1545 | isUndef(c.key) &&
|
1546 | isDef(nestedIndex)) {
|
1547 | c.key = `__vlist${nestedIndex}_${i}__`;
|
1548 | }
|
1549 | res.push(c);
|
1550 | }
|
1551 | }
|
1552 | }
|
1553 | return res;
|
1554 | }
|
1555 |
|
1556 | const SIMPLE_NORMALIZE = 1;
|
1557 | const ALWAYS_NORMALIZE = 2;
|
1558 |
|
1559 |
|
1560 | function createElement(context, tag, data, children, normalizationType, alwaysNormalize) {
|
1561 | if (isArray(data) || isPrimitive(data)) {
|
1562 | normalizationType = children;
|
1563 | children = data;
|
1564 | data = undefined;
|
1565 | }
|
1566 | if (isTrue(alwaysNormalize)) {
|
1567 | normalizationType = ALWAYS_NORMALIZE;
|
1568 | }
|
1569 | return _createElement(context, tag, data, children, normalizationType);
|
1570 | }
|
1571 | function _createElement(context, tag, data, children, normalizationType) {
|
1572 | if (isDef(data) && isDef(data.__ob__)) {
|
1573 | process.env.NODE_ENV !== 'production' &&
|
1574 | warn$2(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
|
1575 | return createEmptyVNode();
|
1576 | }
|
1577 |
|
1578 | if (isDef(data) && isDef(data.is)) {
|
1579 | tag = data.is;
|
1580 | }
|
1581 | if (!tag) {
|
1582 |
|
1583 | return createEmptyVNode();
|
1584 | }
|
1585 |
|
1586 | if (process.env.NODE_ENV !== 'production' && isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
|
1587 | warn$2('Avoid using non-primitive value as key, ' +
|
1588 | 'use string/number value instead.', context);
|
1589 | }
|
1590 |
|
1591 | if (isArray(children) && isFunction(children[0])) {
|
1592 | data = data || {};
|
1593 | data.scopedSlots = { default: children[0] };
|
1594 | children.length = 0;
|
1595 | }
|
1596 | if (normalizationType === ALWAYS_NORMALIZE) {
|
1597 | children = normalizeChildren(children);
|
1598 | }
|
1599 | else if (normalizationType === SIMPLE_NORMALIZE) {
|
1600 | children = simpleNormalizeChildren(children);
|
1601 | }
|
1602 | let vnode, ns;
|
1603 | if (typeof tag === 'string') {
|
1604 | let Ctor;
|
1605 | ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
|
1606 | if ((!data || !data.pre) &&
|
1607 | isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
|
1608 |
|
1609 | vnode = createComponent(Ctor, data, context, children, tag);
|
1610 | }
|
1611 | else {
|
1612 |
|
1613 |
|
1614 |
|
1615 | vnode = new VNode(tag, data, children, undefined, undefined, context);
|
1616 | }
|
1617 | }
|
1618 | else {
|
1619 |
|
1620 | vnode = createComponent(tag, data, context, children);
|
1621 | }
|
1622 | if (isArray(vnode)) {
|
1623 | return vnode;
|
1624 | }
|
1625 | else if (isDef(vnode)) {
|
1626 | if (isDef(ns))
|
1627 | applyNS(vnode, ns);
|
1628 | if (isDef(data))
|
1629 | registerDeepBindings(data);
|
1630 | return vnode;
|
1631 | }
|
1632 | else {
|
1633 | return createEmptyVNode();
|
1634 | }
|
1635 | }
|
1636 | function applyNS(vnode, ns, force) {
|
1637 | vnode.ns = ns;
|
1638 | if (vnode.tag === 'foreignObject') {
|
1639 |
|
1640 | ns = undefined;
|
1641 | force = true;
|
1642 | }
|
1643 | if (isDef(vnode.children)) {
|
1644 | for (let i = 0, l = vnode.children.length; i < l; i++) {
|
1645 | const child = vnode.children[i];
|
1646 | if (isDef(child.tag) &&
|
1647 | (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
|
1648 | applyNS(child, ns, force);
|
1649 | }
|
1650 | }
|
1651 | }
|
1652 | }
|
1653 |
|
1654 |
|
1655 |
|
1656 | function registerDeepBindings(data) {
|
1657 | if (isObject(data.style)) {
|
1658 | traverse(data.style);
|
1659 | }
|
1660 | if (isObject(data.class)) {
|
1661 | traverse(data.class);
|
1662 | }
|
1663 | }
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 | function renderList(val, render) {
|
1669 | let ret = null, i, l, keys, key;
|
1670 | if (isArray(val) || typeof val === 'string') {
|
1671 | ret = new Array(val.length);
|
1672 | for (i = 0, l = val.length; i < l; i++) {
|
1673 | ret[i] = render(val[i], i);
|
1674 | }
|
1675 | }
|
1676 | else if (typeof val === 'number') {
|
1677 | ret = new Array(val);
|
1678 | for (i = 0; i < val; i++) {
|
1679 | ret[i] = render(i + 1, i);
|
1680 | }
|
1681 | }
|
1682 | else if (isObject(val)) {
|
1683 | if (hasSymbol && val[Symbol.iterator]) {
|
1684 | ret = [];
|
1685 | const iterator = val[Symbol.iterator]();
|
1686 | let result = iterator.next();
|
1687 | while (!result.done) {
|
1688 | ret.push(render(result.value, ret.length));
|
1689 | result = iterator.next();
|
1690 | }
|
1691 | }
|
1692 | else {
|
1693 | keys = Object.keys(val);
|
1694 | ret = new Array(keys.length);
|
1695 | for (i = 0, l = keys.length; i < l; i++) {
|
1696 | key = keys[i];
|
1697 | ret[i] = render(val[key], key, i);
|
1698 | }
|
1699 | }
|
1700 | }
|
1701 | if (!isDef(ret)) {
|
1702 | ret = [];
|
1703 | }
|
1704 | ret._isVList = true;
|
1705 | return ret;
|
1706 | }
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 | function renderSlot(name, fallbackRender, props, bindObject) {
|
1712 | const scopedSlotFn = this.$scopedSlots[name];
|
1713 | let nodes;
|
1714 | if (scopedSlotFn) {
|
1715 |
|
1716 | props = props || {};
|
1717 | if (bindObject) {
|
1718 | if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
|
1719 | warn$2('slot v-bind without argument expects an Object', this);
|
1720 | }
|
1721 | props = extend(extend({}, bindObject), props);
|
1722 | }
|
1723 | nodes =
|
1724 | scopedSlotFn(props) ||
|
1725 | (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
|
1726 | }
|
1727 | else {
|
1728 | nodes =
|
1729 | this.$slots[name] ||
|
1730 | (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
|
1731 | }
|
1732 | const target = props && props.slot;
|
1733 | if (target) {
|
1734 | return this.$createElement('template', { slot: target }, nodes);
|
1735 | }
|
1736 | else {
|
1737 | return nodes;
|
1738 | }
|
1739 | }
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 | function resolveFilter(id) {
|
1745 | return resolveAsset(this.$options, 'filters', id, true) || identity;
|
1746 | }
|
1747 |
|
1748 | function isKeyNotMatch(expect, actual) {
|
1749 | if (isArray(expect)) {
|
1750 | return expect.indexOf(actual) === -1;
|
1751 | }
|
1752 | else {
|
1753 | return expect !== actual;
|
1754 | }
|
1755 | }
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 | function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
|
1762 | const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
|
1763 | if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
|
1764 | return isKeyNotMatch(builtInKeyName, eventKeyName);
|
1765 | }
|
1766 | else if (mappedKeyCode) {
|
1767 | return isKeyNotMatch(mappedKeyCode, eventKeyCode);
|
1768 | }
|
1769 | else if (eventKeyName) {
|
1770 | return hyphenate(eventKeyName) !== key;
|
1771 | }
|
1772 | return eventKeyCode === undefined;
|
1773 | }
|
1774 |
|
1775 |
|
1776 |
|
1777 |
|
1778 | function bindObjectProps(data, tag, value, asProp, isSync) {
|
1779 | if (value) {
|
1780 | if (!isObject(value)) {
|
1781 | process.env.NODE_ENV !== 'production' &&
|
1782 | warn$2('v-bind without argument expects an Object or Array value', this);
|
1783 | }
|
1784 | else {
|
1785 | if (isArray(value)) {
|
1786 | value = toObject(value);
|
1787 | }
|
1788 | let hash;
|
1789 | for (const key in value) {
|
1790 | if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
|
1791 | hash = data;
|
1792 | }
|
1793 | else {
|
1794 | const type = data.attrs && data.attrs.type;
|
1795 | hash =
|
1796 | asProp || config.mustUseProp(tag, type, key)
|
1797 | ? data.domProps || (data.domProps = {})
|
1798 | : data.attrs || (data.attrs = {});
|
1799 | }
|
1800 | const camelizedKey = camelize(key);
|
1801 | const hyphenatedKey = hyphenate(key);
|
1802 | if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
|
1803 | hash[key] = value[key];
|
1804 | if (isSync) {
|
1805 | const on = data.on || (data.on = {});
|
1806 | on[`update:${key}`] = function ($event) {
|
1807 | value[key] = $event;
|
1808 | };
|
1809 | }
|
1810 | }
|
1811 | }
|
1812 | }
|
1813 | }
|
1814 | return data;
|
1815 | }
|
1816 |
|
1817 |
|
1818 |
|
1819 |
|
1820 | function renderStatic(index, isInFor) {
|
1821 | const cached = this._staticTrees || (this._staticTrees = []);
|
1822 | let tree = cached[index];
|
1823 |
|
1824 |
|
1825 | if (tree && !isInFor) {
|
1826 | return tree;
|
1827 | }
|
1828 |
|
1829 | tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this
|
1830 | );
|
1831 | markStatic$1(tree, `__static__${index}`, false);
|
1832 | return tree;
|
1833 | }
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 | function markOnce(tree, index, key) {
|
1839 | markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
|
1840 | return tree;
|
1841 | }
|
1842 | function markStatic$1(tree, key, isOnce) {
|
1843 | if (isArray(tree)) {
|
1844 | for (let i = 0; i < tree.length; i++) {
|
1845 | if (tree[i] && typeof tree[i] !== 'string') {
|
1846 | markStaticNode(tree[i], `${key}_${i}`, isOnce);
|
1847 | }
|
1848 | }
|
1849 | }
|
1850 | else {
|
1851 | markStaticNode(tree, key, isOnce);
|
1852 | }
|
1853 | }
|
1854 | function markStaticNode(node, key, isOnce) {
|
1855 | node.isStatic = true;
|
1856 | node.key = key;
|
1857 | node.isOnce = isOnce;
|
1858 | }
|
1859 |
|
1860 | function bindObjectListeners(data, value) {
|
1861 | if (value) {
|
1862 | if (!isPlainObject(value)) {
|
1863 | process.env.NODE_ENV !== 'production' && warn$2('v-on without argument expects an Object value', this);
|
1864 | }
|
1865 | else {
|
1866 | const on = (data.on = data.on ? extend({}, data.on) : {});
|
1867 | for (const key in value) {
|
1868 | const existing = on[key];
|
1869 | const ours = value[key];
|
1870 | on[key] = existing ? [].concat(existing, ours) : ours;
|
1871 | }
|
1872 | }
|
1873 | }
|
1874 | return data;
|
1875 | }
|
1876 |
|
1877 | function resolveScopedSlots(fns, res,
|
1878 | // the following are added in 2.6
|
1879 | hasDynamicKeys, contentHashKey) {
|
1880 | res = res || { $stable: !hasDynamicKeys };
|
1881 | for (let i = 0; i < fns.length; i++) {
|
1882 | const slot = fns[i];
|
1883 | if (isArray(slot)) {
|
1884 | resolveScopedSlots(slot, res, hasDynamicKeys);
|
1885 | }
|
1886 | else if (slot) {
|
1887 |
|
1888 |
|
1889 | if (slot.proxy) {
|
1890 |
|
1891 | slot.fn.proxy = true;
|
1892 | }
|
1893 | res[slot.key] = slot.fn;
|
1894 | }
|
1895 | }
|
1896 | if (contentHashKey) {
|
1897 | res.$key = contentHashKey;
|
1898 | }
|
1899 | return res;
|
1900 | }
|
1901 |
|
1902 |
|
1903 | function bindDynamicKeys(baseObj, values) {
|
1904 | for (let i = 0; i < values.length; i += 2) {
|
1905 | const key = values[i];
|
1906 | if (typeof key === 'string' && key) {
|
1907 | baseObj[values[i]] = values[i + 1];
|
1908 | }
|
1909 | else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
|
1910 |
|
1911 | warn$2(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
|
1912 | }
|
1913 | }
|
1914 | return baseObj;
|
1915 | }
|
1916 |
|
1917 |
|
1918 |
|
1919 | function prependModifier(value, symbol) {
|
1920 | return typeof value === 'string' ? symbol + value : value;
|
1921 | }
|
1922 |
|
1923 | function installRenderHelpers(target) {
|
1924 | target._o = markOnce;
|
1925 | target._n = toNumber;
|
1926 | target._s = toString;
|
1927 | target._l = renderList;
|
1928 | target._t = renderSlot;
|
1929 | target._q = looseEqual;
|
1930 | target._i = looseIndexOf;
|
1931 | target._m = renderStatic;
|
1932 | target._f = resolveFilter;
|
1933 | target._k = checkKeyCodes;
|
1934 | target._b = bindObjectProps;
|
1935 | target._v = createTextVNode;
|
1936 | target._e = createEmptyVNode;
|
1937 | target._u = resolveScopedSlots;
|
1938 | target._g = bindObjectListeners;
|
1939 | target._d = bindDynamicKeys;
|
1940 | target._p = prependModifier;
|
1941 | }
|
1942 |
|
1943 |
|
1944 |
|
1945 |
|
1946 | function resolveSlots(children, context) {
|
1947 | if (!children || !children.length) {
|
1948 | return {};
|
1949 | }
|
1950 | const slots = {};
|
1951 | for (let i = 0, l = children.length; i < l; i++) {
|
1952 | const child = children[i];
|
1953 | const data = child.data;
|
1954 |
|
1955 | if (data && data.attrs && data.attrs.slot) {
|
1956 | delete data.attrs.slot;
|
1957 | }
|
1958 |
|
1959 |
|
1960 | if ((child.context === context || child.fnContext === context) &&
|
1961 | data &&
|
1962 | data.slot != null) {
|
1963 | const name = data.slot;
|
1964 | const slot = slots[name] || (slots[name] = []);
|
1965 | if (child.tag === 'template') {
|
1966 | slot.push.apply(slot, child.children || []);
|
1967 | }
|
1968 | else {
|
1969 | slot.push(child);
|
1970 | }
|
1971 | }
|
1972 | else {
|
1973 | (slots.default || (slots.default = [])).push(child);
|
1974 | }
|
1975 | }
|
1976 |
|
1977 | for (const name in slots) {
|
1978 | if (slots[name].every(isWhitespace)) {
|
1979 | delete slots[name];
|
1980 | }
|
1981 | }
|
1982 | return slots;
|
1983 | }
|
1984 | function isWhitespace(node) {
|
1985 | return (node.isComment && !node.asyncFactory) || node.text === ' ';
|
1986 | }
|
1987 |
|
1988 | function isAsyncPlaceholder(node) {
|
1989 |
|
1990 | return node.isComment && node.asyncFactory;
|
1991 | }
|
1992 |
|
1993 | function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
|
1994 | let res;
|
1995 | const hasNormalSlots = Object.keys(normalSlots).length > 0;
|
1996 | const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
|
1997 | const key = scopedSlots && scopedSlots.$key;
|
1998 | if (!scopedSlots) {
|
1999 | res = {};
|
2000 | }
|
2001 | else if (scopedSlots._normalized) {
|
2002 |
|
2003 | return scopedSlots._normalized;
|
2004 | }
|
2005 | else if (isStable &&
|
2006 | prevScopedSlots &&
|
2007 | prevScopedSlots !== emptyObject &&
|
2008 | key === prevScopedSlots.$key &&
|
2009 | !hasNormalSlots &&
|
2010 | !prevScopedSlots.$hasNormal) {
|
2011 |
|
2012 |
|
2013 | return prevScopedSlots;
|
2014 | }
|
2015 | else {
|
2016 | res = {};
|
2017 | for (const key in scopedSlots) {
|
2018 | if (scopedSlots[key] && key[0] !== '$') {
|
2019 | res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
|
2020 | }
|
2021 | }
|
2022 | }
|
2023 |
|
2024 | for (const key in normalSlots) {
|
2025 | if (!(key in res)) {
|
2026 | res[key] = proxyNormalSlot(normalSlots, key);
|
2027 | }
|
2028 | }
|
2029 |
|
2030 |
|
2031 | if (scopedSlots && Object.isExtensible(scopedSlots)) {
|
2032 | scopedSlots._normalized = res;
|
2033 | }
|
2034 | def(res, '$stable', isStable);
|
2035 | def(res, '$key', key);
|
2036 | def(res, '$hasNormal', hasNormalSlots);
|
2037 | return res;
|
2038 | }
|
2039 | function normalizeScopedSlot(vm, normalSlots, key, fn) {
|
2040 | const normalized = function () {
|
2041 | const cur = currentInstance;
|
2042 | setCurrentInstance(vm);
|
2043 | let res = arguments.length ? fn.apply(null, arguments) : fn({});
|
2044 | res =
|
2045 | res && typeof res === 'object' && !isArray(res)
|
2046 | ? [res]
|
2047 | : normalizeChildren(res);
|
2048 | const vnode = res && res[0];
|
2049 | setCurrentInstance(cur);
|
2050 | return res &&
|
2051 | (!vnode ||
|
2052 | (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)))
|
2053 | ? undefined
|
2054 | : res;
|
2055 | };
|
2056 |
|
2057 |
|
2058 |
|
2059 | if (fn.proxy) {
|
2060 | Object.defineProperty(normalSlots, key, {
|
2061 | get: normalized,
|
2062 | enumerable: true,
|
2063 | configurable: true
|
2064 | });
|
2065 | }
|
2066 | return normalized;
|
2067 | }
|
2068 | function proxyNormalSlot(slots, key) {
|
2069 | return () => slots[key];
|
2070 | }
|
2071 |
|
2072 | function syncSetupProxy(to, from, prev, instance, type) {
|
2073 | let changed = false;
|
2074 | for (const key in from) {
|
2075 | if (!(key in to)) {
|
2076 | changed = true;
|
2077 | defineProxyAttr(to, key, instance, type);
|
2078 | }
|
2079 | else if (from[key] !== prev[key]) {
|
2080 | changed = true;
|
2081 | }
|
2082 | }
|
2083 | for (const key in to) {
|
2084 | if (!(key in from)) {
|
2085 | changed = true;
|
2086 | delete to[key];
|
2087 | }
|
2088 | }
|
2089 | return changed;
|
2090 | }
|
2091 | function defineProxyAttr(proxy, key, instance, type) {
|
2092 | Object.defineProperty(proxy, key, {
|
2093 | enumerable: true,
|
2094 | configurable: true,
|
2095 | get() {
|
2096 | return instance[type][key];
|
2097 | }
|
2098 | });
|
2099 | }
|
2100 |
|
2101 | function createAsyncPlaceholder(factory, data, context, children, tag) {
|
2102 | const node = createEmptyVNode();
|
2103 | node.asyncFactory = factory;
|
2104 | node.asyncMeta = { data, context, children, tag };
|
2105 | return node;
|
2106 | }
|
2107 | function resolveAsyncComponent(factory, baseCtor) {
|
2108 | if (isTrue(factory.error) && isDef(factory.errorComp)) {
|
2109 | return factory.errorComp;
|
2110 | }
|
2111 | if (isDef(factory.resolved)) {
|
2112 | return factory.resolved;
|
2113 | }
|
2114 | if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
|
2115 | return factory.loadingComp;
|
2116 | }
|
2117 | }
|
2118 |
|
2119 | let target;
|
2120 | function add(event, fn) {
|
2121 | target.$on(event, fn);
|
2122 | }
|
2123 | function remove(event, fn) {
|
2124 | target.$off(event, fn);
|
2125 | }
|
2126 | function createOnceHandler(event, fn) {
|
2127 | const _target = target;
|
2128 | return function onceHandler() {
|
2129 | const res = fn.apply(null, arguments);
|
2130 | if (res !== null) {
|
2131 | _target.$off(event, onceHandler);
|
2132 | }
|
2133 | };
|
2134 | }
|
2135 | function updateComponentListeners(vm, listeners, oldListeners) {
|
2136 | target = vm;
|
2137 | updateListeners(listeners, oldListeners || {}, add, remove, createOnceHandler, vm);
|
2138 | target = undefined;
|
2139 | }
|
2140 |
|
2141 | let activeInstance = null;
|
2142 | function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
|
2143 | if (process.env.NODE_ENV !== 'production') ;
|
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 |
|
2149 | const newScopedSlots = parentVnode.data.scopedSlots;
|
2150 | const oldScopedSlots = vm.$scopedSlots;
|
2151 | const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
|
2152 | (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
|
2153 | (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
|
2154 | (!newScopedSlots && vm.$scopedSlots.$key));
|
2155 |
|
2156 |
|
2157 |
|
2158 | let needsForceUpdate = !!(renderChildren ||
|
2159 | vm.$options._renderChildren ||
|
2160 | hasDynamicScopedSlot);
|
2161 | const prevVNode = vm.$vnode;
|
2162 | vm.$options._parentVnode = parentVnode;
|
2163 | vm.$vnode = parentVnode;
|
2164 | if (vm._vnode) {
|
2165 |
|
2166 | vm._vnode.parent = parentVnode;
|
2167 | }
|
2168 | vm.$options._renderChildren = renderChildren;
|
2169 |
|
2170 |
|
2171 |
|
2172 | const attrs = parentVnode.data.attrs || emptyObject;
|
2173 | if (vm._attrsProxy) {
|
2174 |
|
2175 |
|
2176 | if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
|
2177 | needsForceUpdate = true;
|
2178 | }
|
2179 | }
|
2180 | vm.$attrs = attrs;
|
2181 |
|
2182 | listeners = listeners || emptyObject;
|
2183 | const prevListeners = vm.$options._parentListeners;
|
2184 | if (vm._listenersProxy) {
|
2185 | syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
|
2186 | }
|
2187 | vm.$listeners = vm.$options._parentListeners = listeners;
|
2188 | updateComponentListeners(vm, listeners, prevListeners);
|
2189 |
|
2190 | if (propsData && vm.$options.props) {
|
2191 | toggleObserving(false);
|
2192 | const props = vm._props;
|
2193 | const propKeys = vm.$options._propKeys || [];
|
2194 | for (let i = 0; i < propKeys.length; i++) {
|
2195 | const key = propKeys[i];
|
2196 | const propOptions = vm.$options.props;
|
2197 | props[key] = validateProp(key, propOptions, propsData, vm);
|
2198 | }
|
2199 | toggleObserving(true);
|
2200 |
|
2201 | vm.$options.propsData = propsData;
|
2202 | }
|
2203 |
|
2204 | if (needsForceUpdate) {
|
2205 | vm.$slots = resolveSlots(renderChildren, parentVnode.context);
|
2206 | vm.$forceUpdate();
|
2207 | }
|
2208 | if (process.env.NODE_ENV !== 'production') ;
|
2209 | }
|
2210 | function isInInactiveTree(vm) {
|
2211 | while (vm && (vm = vm.$parent)) {
|
2212 | if (vm._inactive)
|
2213 | return true;
|
2214 | }
|
2215 | return false;
|
2216 | }
|
2217 | function activateChildComponent(vm, direct) {
|
2218 | if (direct) {
|
2219 | vm._directInactive = false;
|
2220 | if (isInInactiveTree(vm)) {
|
2221 | return;
|
2222 | }
|
2223 | }
|
2224 | else if (vm._directInactive) {
|
2225 | return;
|
2226 | }
|
2227 | if (vm._inactive || vm._inactive === null) {
|
2228 | vm._inactive = false;
|
2229 | for (let i = 0; i < vm.$children.length; i++) {
|
2230 | activateChildComponent(vm.$children[i]);
|
2231 | }
|
2232 | callHook(vm, 'activated');
|
2233 | }
|
2234 | }
|
2235 | function deactivateChildComponent(vm, direct) {
|
2236 | if (direct) {
|
2237 | vm._directInactive = true;
|
2238 | if (isInInactiveTree(vm)) {
|
2239 | return;
|
2240 | }
|
2241 | }
|
2242 | if (!vm._inactive) {
|
2243 | vm._inactive = true;
|
2244 | for (let i = 0; i < vm.$children.length; i++) {
|
2245 | deactivateChildComponent(vm.$children[i]);
|
2246 | }
|
2247 | callHook(vm, 'deactivated');
|
2248 | }
|
2249 | }
|
2250 | function callHook(vm, hook, args, setContext = true) {
|
2251 |
|
2252 | pushTarget();
|
2253 | const prevInst = currentInstance;
|
2254 | setContext && setCurrentInstance(vm);
|
2255 | const handlers = vm.$options[hook];
|
2256 | const info = `${hook} hook`;
|
2257 | if (handlers) {
|
2258 | for (let i = 0, j = handlers.length; i < j; i++) {
|
2259 | invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
|
2260 | }
|
2261 | }
|
2262 | if (vm._hasHookEvent) {
|
2263 | vm.$emit('hook:' + hook);
|
2264 | }
|
2265 | if (setContext) {
|
2266 | setCurrentInstance(prevInst);
|
2267 | }
|
2268 | popTarget();
|
2269 | }
|
2270 |
|
2271 |
|
2272 | let getNow = Date.now;
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 |
|
2278 |
|
2279 | if (inBrowser && !isIE) {
|
2280 | const performance = window.performance;
|
2281 | if (performance &&
|
2282 | typeof performance.now === 'function' &&
|
2283 | getNow() > document.createEvent('Event').timeStamp) {
|
2284 |
|
2285 |
|
2286 |
|
2287 |
|
2288 | getNow = () => performance.now();
|
2289 | }
|
2290 | }
|
2291 |
|
2292 |
|
2293 |
|
2294 |
|
2295 | function queueActivatedComponent(vm) {
|
2296 |
|
2297 |
|
2298 | vm._inactive = false;
|
2299 | }
|
2300 |
|
2301 | function handleError(err, vm, info) {
|
2302 |
|
2303 |
|
2304 | pushTarget();
|
2305 | try {
|
2306 | if (vm) {
|
2307 | let cur = vm;
|
2308 | while ((cur = cur.$parent)) {
|
2309 | const hooks = cur.$options.errorCaptured;
|
2310 | if (hooks) {
|
2311 | for (let i = 0; i < hooks.length; i++) {
|
2312 | try {
|
2313 | const capture = hooks[i].call(cur, err, vm, info) === false;
|
2314 | if (capture)
|
2315 | return;
|
2316 | }
|
2317 | catch (e) {
|
2318 | globalHandleError(e, cur, 'errorCaptured hook');
|
2319 | }
|
2320 | }
|
2321 | }
|
2322 | }
|
2323 | }
|
2324 | globalHandleError(err, vm, info);
|
2325 | }
|
2326 | finally {
|
2327 | popTarget();
|
2328 | }
|
2329 | }
|
2330 | function invokeWithErrorHandling(handler, context, args, vm, info) {
|
2331 | let res;
|
2332 | try {
|
2333 | res = args ? handler.apply(context, args) : handler.call(context);
|
2334 | if (res && !res._isVue && isPromise(res) && !res._handled) {
|
2335 | res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
|
2336 | res._handled = true;
|
2337 | }
|
2338 | }
|
2339 | catch (e) {
|
2340 | handleError(e, vm, info);
|
2341 | }
|
2342 | return res;
|
2343 | }
|
2344 | function globalHandleError(err, vm, info) {
|
2345 | logError(err, vm, info);
|
2346 | }
|
2347 | function logError(err, vm, info) {
|
2348 | if (process.env.NODE_ENV !== 'production') {
|
2349 | warn$2(`Error in ${info}: "${err.toString()}"`, vm);
|
2350 | }
|
2351 |
|
2352 | if (inBrowser && typeof console !== 'undefined') {
|
2353 | console.error(err);
|
2354 | }
|
2355 | else {
|
2356 | throw err;
|
2357 | }
|
2358 | }
|
2359 |
|
2360 |
|
2361 | const callbacks = [];
|
2362 | function flushCallbacks() {
|
2363 | const copies = callbacks.slice(0);
|
2364 | callbacks.length = 0;
|
2365 | for (let i = 0; i < copies.length; i++) {
|
2366 | copies[i]();
|
2367 | }
|
2368 | }
|
2369 |
|
2370 |
|
2371 |
|
2372 |
|
2373 |
|
2374 |
|
2375 |
|
2376 | if (typeof Promise !== 'undefined' && isNative(Promise)) {
|
2377 | Promise.resolve();
|
2378 | }
|
2379 | else if (!isIE &&
|
2380 | typeof MutationObserver !== 'undefined' &&
|
2381 | (isNative(MutationObserver) ||
|
2382 |
|
2383 | MutationObserver.toString() === '[object MutationObserverConstructor]')) {
|
2384 |
|
2385 |
|
2386 |
|
2387 | let counter = 1;
|
2388 | const observer = new MutationObserver(flushCallbacks);
|
2389 | const textNode = document.createTextNode(String(counter));
|
2390 | observer.observe(textNode, {
|
2391 | characterData: true
|
2392 | });
|
2393 | }
|
2394 | else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) ;
|
2395 | else ;
|
2396 |
|
2397 | const seenObjects = new _Set();
|
2398 |
|
2399 |
|
2400 |
|
2401 |
|
2402 |
|
2403 | function traverse(val) {
|
2404 | _traverse(val, seenObjects);
|
2405 | seenObjects.clear();
|
2406 | return val;
|
2407 | }
|
2408 | function _traverse(val, seen) {
|
2409 | let i, keys;
|
2410 | const isA = isArray(val);
|
2411 | if ((!isA && !isObject(val)) ||
|
2412 | val.__v_skip ||
|
2413 | Object.isFrozen(val) ||
|
2414 | val instanceof VNode) {
|
2415 | return;
|
2416 | }
|
2417 | if (val.__ob__) {
|
2418 | const depId = val.__ob__.dep.id;
|
2419 | if (seen.has(depId)) {
|
2420 | return;
|
2421 | }
|
2422 | seen.add(depId);
|
2423 | }
|
2424 | if (isA) {
|
2425 | i = val.length;
|
2426 | while (i--)
|
2427 | _traverse(val[i], seen);
|
2428 | }
|
2429 | else if (isRef(val)) {
|
2430 | _traverse(val.value, seen);
|
2431 | }
|
2432 | else {
|
2433 | keys = Object.keys(val);
|
2434 | i = keys.length;
|
2435 | while (i--)
|
2436 | _traverse(val[keys[i]], seen);
|
2437 | }
|
2438 | }
|
2439 |
|
2440 | function resolveInject(inject, vm) {
|
2441 | if (inject) {
|
2442 |
|
2443 | const result = Object.create(null);
|
2444 | const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
|
2445 | for (let i = 0; i < keys.length; i++) {
|
2446 | const key = keys[i];
|
2447 |
|
2448 | if (key === '__ob__')
|
2449 | continue;
|
2450 | const provideKey = inject[key].from;
|
2451 | if (provideKey in vm._provided) {
|
2452 | result[key] = vm._provided[provideKey];
|
2453 | }
|
2454 | else if ('default' in inject[key]) {
|
2455 | const provideDefault = inject[key].default;
|
2456 | result[key] = isFunction(provideDefault)
|
2457 | ? provideDefault.call(vm)
|
2458 | : provideDefault;
|
2459 | }
|
2460 | else if (process.env.NODE_ENV !== 'production') {
|
2461 | warn$2(`Injection "${key}" not found`, vm);
|
2462 | }
|
2463 | }
|
2464 | return result;
|
2465 | }
|
2466 | }
|
2467 |
|
2468 | function resolveConstructorOptions(Ctor) {
|
2469 | let options = Ctor.options;
|
2470 | if (Ctor.super) {
|
2471 | const superOptions = resolveConstructorOptions(Ctor.super);
|
2472 | const cachedSuperOptions = Ctor.superOptions;
|
2473 | if (superOptions !== cachedSuperOptions) {
|
2474 |
|
2475 |
|
2476 | Ctor.superOptions = superOptions;
|
2477 |
|
2478 | const modifiedOptions = resolveModifiedOptions(Ctor);
|
2479 |
|
2480 | if (modifiedOptions) {
|
2481 | extend(Ctor.extendOptions, modifiedOptions);
|
2482 | }
|
2483 | options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
|
2484 | if (options.name) {
|
2485 | options.components[options.name] = Ctor;
|
2486 | }
|
2487 | }
|
2488 | }
|
2489 | return options;
|
2490 | }
|
2491 | function resolveModifiedOptions(Ctor) {
|
2492 | let modified;
|
2493 | const latest = Ctor.options;
|
2494 | const sealed = Ctor.sealedOptions;
|
2495 | for (const key in latest) {
|
2496 | if (latest[key] !== sealed[key]) {
|
2497 | if (!modified)
|
2498 | modified = {};
|
2499 | modified[key] = latest[key];
|
2500 | }
|
2501 | }
|
2502 | return modified;
|
2503 | }
|
2504 |
|
2505 | function FunctionalRenderContext(data, props, children, parent, Ctor) {
|
2506 | const options = Ctor.options;
|
2507 |
|
2508 |
|
2509 | let contextVm;
|
2510 | if (hasOwn(parent, '_uid')) {
|
2511 | contextVm = Object.create(parent);
|
2512 | contextVm._original = parent;
|
2513 | }
|
2514 | else {
|
2515 |
|
2516 |
|
2517 |
|
2518 | contextVm = parent;
|
2519 |
|
2520 | parent = parent._original;
|
2521 | }
|
2522 | const isCompiled = isTrue(options._compiled);
|
2523 | const needNormalization = !isCompiled;
|
2524 | this.data = data;
|
2525 | this.props = props;
|
2526 | this.children = children;
|
2527 | this.parent = parent;
|
2528 | this.listeners = data.on || emptyObject;
|
2529 | this.injections = resolveInject(options.inject, parent);
|
2530 | this.slots = () => {
|
2531 | if (!this.$slots) {
|
2532 | normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
|
2533 | }
|
2534 | return this.$slots;
|
2535 | };
|
2536 | Object.defineProperty(this, 'scopedSlots', {
|
2537 | enumerable: true,
|
2538 | get() {
|
2539 | return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
|
2540 | }
|
2541 | });
|
2542 |
|
2543 | if (isCompiled) {
|
2544 |
|
2545 | this.$options = options;
|
2546 |
|
2547 | this.$slots = this.slots();
|
2548 | this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
|
2549 | }
|
2550 | if (options._scopeId) {
|
2551 | this._c = (a, b, c, d) => {
|
2552 | const vnode = createElement(contextVm, a, b, c, d, needNormalization);
|
2553 | if (vnode && !isArray(vnode)) {
|
2554 | vnode.fnScopeId = options._scopeId;
|
2555 | vnode.fnContext = parent;
|
2556 | }
|
2557 | return vnode;
|
2558 | };
|
2559 | }
|
2560 | else {
|
2561 | this._c = (a, b, c, d) => createElement(contextVm, a, b, c, d, needNormalization);
|
2562 | }
|
2563 | }
|
2564 | installRenderHelpers(FunctionalRenderContext.prototype);
|
2565 | function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
|
2566 | const options = Ctor.options;
|
2567 | const props = {};
|
2568 | const propOptions = options.props;
|
2569 | if (isDef(propOptions)) {
|
2570 | for (const key in propOptions) {
|
2571 | props[key] = validateProp(key, propOptions, propsData || emptyObject);
|
2572 | }
|
2573 | }
|
2574 | else {
|
2575 | if (isDef(data.attrs))
|
2576 | mergeProps(props, data.attrs);
|
2577 | if (isDef(data.props))
|
2578 | mergeProps(props, data.props);
|
2579 | }
|
2580 | const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
|
2581 | const vnode = options.render.call(null, renderContext._c, renderContext);
|
2582 | if (vnode instanceof VNode) {
|
2583 | return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
|
2584 | }
|
2585 | else if (isArray(vnode)) {
|
2586 | const vnodes = normalizeChildren(vnode) || [];
|
2587 | const res = new Array(vnodes.length);
|
2588 | for (let i = 0; i < vnodes.length; i++) {
|
2589 | res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
|
2590 | }
|
2591 | return res;
|
2592 | }
|
2593 | }
|
2594 | function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
|
2595 |
|
2596 |
|
2597 |
|
2598 | const clone = cloneVNode(vnode);
|
2599 | clone.fnContext = contextVm;
|
2600 | clone.fnOptions = options;
|
2601 | if (process.env.NODE_ENV !== 'production') {
|
2602 | (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
|
2603 | renderContext;
|
2604 | }
|
2605 | if (data.slot) {
|
2606 | (clone.data || (clone.data = {})).slot = data.slot;
|
2607 | }
|
2608 | return clone;
|
2609 | }
|
2610 | function mergeProps(to, from) {
|
2611 | for (const key in from) {
|
2612 | to[camelize(key)] = from[key];
|
2613 | }
|
2614 | }
|
2615 |
|
2616 | function getComponentName(options) {
|
2617 | return options.name || options.__name || options._componentTag;
|
2618 | }
|
2619 |
|
2620 | const componentVNodeHooks = {
|
2621 | init(vnode, hydrating) {
|
2622 | if (vnode.componentInstance &&
|
2623 | !vnode.componentInstance._isDestroyed &&
|
2624 | vnode.data.keepAlive) {
|
2625 |
|
2626 | const mountedNode = vnode;
|
2627 | componentVNodeHooks.prepatch(mountedNode, mountedNode);
|
2628 | }
|
2629 | else {
|
2630 | const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
|
2631 | child.$mount(hydrating ? vnode.elm : undefined, hydrating);
|
2632 | }
|
2633 | },
|
2634 | prepatch(oldVnode, vnode) {
|
2635 | const options = vnode.componentOptions;
|
2636 | const child = (vnode.componentInstance = oldVnode.componentInstance);
|
2637 | updateChildComponent(child, options.propsData,
|
2638 | options.listeners,
|
2639 | vnode,
|
2640 | options.children
|
2641 | );
|
2642 | },
|
2643 | insert(vnode) {
|
2644 | const { context, componentInstance } = vnode;
|
2645 | if (!componentInstance._isMounted) {
|
2646 | componentInstance._isMounted = true;
|
2647 | callHook(componentInstance, 'mounted');
|
2648 | }
|
2649 | if (vnode.data.keepAlive) {
|
2650 | if (context._isMounted) {
|
2651 |
|
2652 |
|
2653 |
|
2654 |
|
2655 |
|
2656 | queueActivatedComponent(componentInstance);
|
2657 | }
|
2658 | else {
|
2659 | activateChildComponent(componentInstance, true );
|
2660 | }
|
2661 | }
|
2662 | },
|
2663 | destroy(vnode) {
|
2664 | const { componentInstance } = vnode;
|
2665 | if (!componentInstance._isDestroyed) {
|
2666 | if (!vnode.data.keepAlive) {
|
2667 | componentInstance.$destroy();
|
2668 | }
|
2669 | else {
|
2670 | deactivateChildComponent(componentInstance, true );
|
2671 | }
|
2672 | }
|
2673 | }
|
2674 | };
|
2675 | const hooksToMerge = Object.keys(componentVNodeHooks);
|
2676 | function createComponent(Ctor, data, context, children, tag) {
|
2677 | if (isUndef(Ctor)) {
|
2678 | return;
|
2679 | }
|
2680 | const baseCtor = context.$options._base;
|
2681 |
|
2682 | if (isObject(Ctor)) {
|
2683 | Ctor = baseCtor.extend(Ctor);
|
2684 | }
|
2685 |
|
2686 |
|
2687 | if (typeof Ctor !== 'function') {
|
2688 | if (process.env.NODE_ENV !== 'production') {
|
2689 | warn$2(`Invalid Component definition: ${String(Ctor)}`, context);
|
2690 | }
|
2691 | return;
|
2692 | }
|
2693 |
|
2694 | let asyncFactory;
|
2695 |
|
2696 | if (isUndef(Ctor.cid)) {
|
2697 | asyncFactory = Ctor;
|
2698 | Ctor = resolveAsyncComponent(asyncFactory);
|
2699 | if (Ctor === undefined) {
|
2700 |
|
2701 |
|
2702 |
|
2703 | return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
|
2704 | }
|
2705 | }
|
2706 | data = data || {};
|
2707 |
|
2708 |
|
2709 | resolveConstructorOptions(Ctor);
|
2710 |
|
2711 | if (isDef(data.model)) {
|
2712 |
|
2713 | transformModel(Ctor.options, data);
|
2714 | }
|
2715 |
|
2716 |
|
2717 | const propsData = extractPropsFromVNodeData(data, Ctor, tag);
|
2718 |
|
2719 |
|
2720 | if (isTrue(Ctor.options.functional)) {
|
2721 | return createFunctionalComponent(Ctor, propsData, data, context, children);
|
2722 | }
|
2723 |
|
2724 |
|
2725 | const listeners = data.on;
|
2726 |
|
2727 |
|
2728 | data.on = data.nativeOn;
|
2729 |
|
2730 | if (isTrue(Ctor.options.abstract)) {
|
2731 |
|
2732 |
|
2733 |
|
2734 | const slot = data.slot;
|
2735 | data = {};
|
2736 | if (slot) {
|
2737 | data.slot = slot;
|
2738 | }
|
2739 | }
|
2740 |
|
2741 | installComponentHooks(data);
|
2742 |
|
2743 |
|
2744 | const name = getComponentName(Ctor.options) || tag;
|
2745 | const vnode = new VNode(
|
2746 |
|
2747 | `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
|
2748 |
|
2749 | { Ctor, propsData, listeners, tag, children }, asyncFactory);
|
2750 | return vnode;
|
2751 | }
|
2752 | function createComponentInstanceForVnode(
|
2753 | // we know it's MountedComponentVNode but flow doesn't
|
2754 | vnode,
|
2755 | // activeInstance in lifecycle state
|
2756 | parent) {
|
2757 | const options = {
|
2758 | _isComponent: true,
|
2759 | _parentVnode: vnode,
|
2760 | parent
|
2761 | };
|
2762 |
|
2763 | const inlineTemplate = vnode.data.inlineTemplate;
|
2764 | if (isDef(inlineTemplate)) {
|
2765 | options.render = inlineTemplate.render;
|
2766 | options.staticRenderFns = inlineTemplate.staticRenderFns;
|
2767 | }
|
2768 | return new vnode.componentOptions.Ctor(options);
|
2769 | }
|
2770 | function installComponentHooks(data) {
|
2771 | const hooks = data.hook || (data.hook = {});
|
2772 | for (let i = 0; i < hooksToMerge.length; i++) {
|
2773 | const key = hooksToMerge[i];
|
2774 | const existing = hooks[key];
|
2775 | const toMerge = componentVNodeHooks[key];
|
2776 |
|
2777 | if (existing !== toMerge && !(existing && existing._merged)) {
|
2778 | hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
|
2779 | }
|
2780 | }
|
2781 | }
|
2782 | function mergeHook(f1, f2) {
|
2783 | const merged = (a, b) => {
|
2784 |
|
2785 | f1(a, b);
|
2786 | f2(a, b);
|
2787 | };
|
2788 | merged._merged = true;
|
2789 | return merged;
|
2790 | }
|
2791 |
|
2792 |
|
2793 | function transformModel(options, data) {
|
2794 | const prop = (options.model && options.model.prop) || 'value';
|
2795 | const event = (options.model && options.model.event) || 'input';
|
2796 | (data.attrs || (data.attrs = {}))[prop] = data.model.value;
|
2797 | const on = data.on || (data.on = {});
|
2798 | const existing = on[event];
|
2799 | const callback = data.model.callback;
|
2800 | if (isDef(existing)) {
|
2801 | if (isArray(existing)
|
2802 | ? existing.indexOf(callback) === -1
|
2803 | : existing !== callback) {
|
2804 | on[event] = [callback].concat(existing);
|
2805 | }
|
2806 | }
|
2807 | else {
|
2808 | on[event] = callback;
|
2809 | }
|
2810 | }
|
2811 |
|
2812 | let warn$2 = noop;
|
2813 | let tip = noop;
|
2814 | let generateComponentTrace;
|
2815 | let formatComponentName;
|
2816 | if (process.env.NODE_ENV !== 'production') {
|
2817 | const hasConsole = typeof console !== 'undefined';
|
2818 | const classifyRE = /(?:^|[-_])(\w)/g;
|
2819 | const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
|
2820 | warn$2 = (msg, vm = currentInstance) => {
|
2821 | const trace = vm ? generateComponentTrace(vm) : '';
|
2822 | if (hasConsole && !config.silent) {
|
2823 | console.error(`[Vue warn]: ${msg}${trace}`);
|
2824 | }
|
2825 | };
|
2826 | tip = (msg, vm) => {
|
2827 | if (hasConsole && !config.silent) {
|
2828 | console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
|
2829 | }
|
2830 | };
|
2831 | formatComponentName = (vm, includeFile) => {
|
2832 | if (vm.$root === vm) {
|
2833 | return '<Root>';
|
2834 | }
|
2835 | const options = isFunction(vm) && vm.cid != null
|
2836 | ? vm.options
|
2837 | : vm._isVue
|
2838 | ? vm.$options || vm.constructor.options
|
2839 | : vm;
|
2840 | let name = getComponentName(options);
|
2841 | const file = options.__file;
|
2842 | if (!name && file) {
|
2843 | const match = file.match(/([^/\\]+)\.vue$/);
|
2844 | name = match && match[1];
|
2845 | }
|
2846 | return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
|
2847 | (file && includeFile !== false ? ` at ${file}` : ''));
|
2848 | };
|
2849 | const repeat = (str, n) => {
|
2850 | let res = '';
|
2851 | while (n) {
|
2852 | if (n % 2 === 1)
|
2853 | res += str;
|
2854 | if (n > 1)
|
2855 | str += str;
|
2856 | n >>= 1;
|
2857 | }
|
2858 | return res;
|
2859 | };
|
2860 | generateComponentTrace = (vm) => {
|
2861 | if (vm._isVue && vm.$parent) {
|
2862 | const tree = [];
|
2863 | let currentRecursiveSequence = 0;
|
2864 | while (vm) {
|
2865 | if (tree.length > 0) {
|
2866 | const last = tree[tree.length - 1];
|
2867 | if (last.constructor === vm.constructor) {
|
2868 | currentRecursiveSequence++;
|
2869 | vm = vm.$parent;
|
2870 | continue;
|
2871 | }
|
2872 | else if (currentRecursiveSequence > 0) {
|
2873 | tree[tree.length - 1] = [last, currentRecursiveSequence];
|
2874 | currentRecursiveSequence = 0;
|
2875 | }
|
2876 | }
|
2877 | tree.push(vm);
|
2878 | vm = vm.$parent;
|
2879 | }
|
2880 | return ('\n\nfound in\n\n' +
|
2881 | tree
|
2882 | .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
|
2883 | ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
|
2884 | : formatComponentName(vm)}`)
|
2885 | .join('\n'));
|
2886 | }
|
2887 | else {
|
2888 | return `\n\n(found in ${formatComponentName(vm)})`;
|
2889 | }
|
2890 | };
|
2891 | }
|
2892 |
|
2893 |
|
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 | const strats = config.optionMergeStrategies;
|
2899 |
|
2900 |
|
2901 |
|
2902 | if (process.env.NODE_ENV !== 'production') {
|
2903 | strats.el = strats.propsData = function (parent, child, vm, key) {
|
2904 | if (!vm) {
|
2905 | warn$2(`option "${key}" can only be used during instance ` +
|
2906 | 'creation with the `new` keyword.');
|
2907 | }
|
2908 | return defaultStrat(parent, child);
|
2909 | };
|
2910 | }
|
2911 |
|
2912 |
|
2913 |
|
2914 | function mergeData(to, from, recursive = true) {
|
2915 | if (!from)
|
2916 | return to;
|
2917 | let key, toVal, fromVal;
|
2918 | const keys = hasSymbol
|
2919 | ? Reflect.ownKeys(from)
|
2920 | : Object.keys(from);
|
2921 | for (let i = 0; i < keys.length; i++) {
|
2922 | key = keys[i];
|
2923 |
|
2924 | if (key === '__ob__')
|
2925 | continue;
|
2926 | toVal = to[key];
|
2927 | fromVal = from[key];
|
2928 | if (!recursive || !hasOwn(to, key)) {
|
2929 | set(to, key, fromVal);
|
2930 | }
|
2931 | else if (toVal !== fromVal &&
|
2932 | isPlainObject(toVal) &&
|
2933 | isPlainObject(fromVal)) {
|
2934 | mergeData(toVal, fromVal);
|
2935 | }
|
2936 | }
|
2937 | return to;
|
2938 | }
|
2939 |
|
2940 |
|
2941 |
|
2942 | function mergeDataOrFn(parentVal, childVal, vm) {
|
2943 | if (!vm) {
|
2944 |
|
2945 | if (!childVal) {
|
2946 | return parentVal;
|
2947 | }
|
2948 | if (!parentVal) {
|
2949 | return childVal;
|
2950 | }
|
2951 |
|
2952 |
|
2953 |
|
2954 |
|
2955 |
|
2956 | return function mergedDataFn() {
|
2957 | return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
|
2958 | };
|
2959 | }
|
2960 | else {
|
2961 | return function mergedInstanceDataFn() {
|
2962 |
|
2963 | const instanceData = isFunction(childVal)
|
2964 | ? childVal.call(vm, vm)
|
2965 | : childVal;
|
2966 | const defaultData = isFunction(parentVal)
|
2967 | ? parentVal.call(vm, vm)
|
2968 | : parentVal;
|
2969 | if (instanceData) {
|
2970 | return mergeData(instanceData, defaultData);
|
2971 | }
|
2972 | else {
|
2973 | return defaultData;
|
2974 | }
|
2975 | };
|
2976 | }
|
2977 | }
|
2978 | strats.data = function (parentVal, childVal, vm) {
|
2979 | if (!vm) {
|
2980 | if (childVal && typeof childVal !== 'function') {
|
2981 | process.env.NODE_ENV !== 'production' &&
|
2982 | warn$2('The "data" option should be a function ' +
|
2983 | 'that returns a per-instance value in component ' +
|
2984 | 'definitions.', vm);
|
2985 | return parentVal;
|
2986 | }
|
2987 | return mergeDataOrFn(parentVal, childVal);
|
2988 | }
|
2989 | return mergeDataOrFn(parentVal, childVal, vm);
|
2990 | };
|
2991 |
|
2992 |
|
2993 |
|
2994 | function mergeLifecycleHook(parentVal, childVal) {
|
2995 | const res = childVal
|
2996 | ? parentVal
|
2997 | ? parentVal.concat(childVal)
|
2998 | : isArray(childVal)
|
2999 | ? childVal
|
3000 | : [childVal]
|
3001 | : parentVal;
|
3002 | return res ? dedupeHooks(res) : res;
|
3003 | }
|
3004 | function dedupeHooks(hooks) {
|
3005 | const res = [];
|
3006 | for (let i = 0; i < hooks.length; i++) {
|
3007 | if (res.indexOf(hooks[i]) === -1) {
|
3008 | res.push(hooks[i]);
|
3009 | }
|
3010 | }
|
3011 | return res;
|
3012 | }
|
3013 | LIFECYCLE_HOOKS.forEach(hook => {
|
3014 | strats[hook] = mergeLifecycleHook;
|
3015 | });
|
3016 |
|
3017 |
|
3018 |
|
3019 |
|
3020 |
|
3021 |
|
3022 |
|
3023 | function mergeAssets(parentVal, childVal, vm, key) {
|
3024 | const res = Object.create(parentVal || null);
|
3025 | if (childVal) {
|
3026 | process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
|
3027 | return extend(res, childVal);
|
3028 | }
|
3029 | else {
|
3030 | return res;
|
3031 | }
|
3032 | }
|
3033 | ASSET_TYPES.forEach(function (type) {
|
3034 | strats[type + 's'] = mergeAssets;
|
3035 | });
|
3036 |
|
3037 |
|
3038 |
|
3039 |
|
3040 |
|
3041 |
|
3042 | strats.watch = function (parentVal, childVal, vm, key) {
|
3043 |
|
3044 |
|
3045 | if (parentVal === nativeWatch)
|
3046 | parentVal = undefined;
|
3047 |
|
3048 | if (childVal === nativeWatch)
|
3049 | childVal = undefined;
|
3050 |
|
3051 | if (!childVal)
|
3052 | return Object.create(parentVal || null);
|
3053 | if (process.env.NODE_ENV !== 'production') {
|
3054 | assertObjectType(key, childVal, vm);
|
3055 | }
|
3056 | if (!parentVal)
|
3057 | return childVal;
|
3058 | const ret = {};
|
3059 | extend(ret, parentVal);
|
3060 | for (const key in childVal) {
|
3061 | let parent = ret[key];
|
3062 | const child = childVal[key];
|
3063 | if (parent && !isArray(parent)) {
|
3064 | parent = [parent];
|
3065 | }
|
3066 | ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
|
3067 | }
|
3068 | return ret;
|
3069 | };
|
3070 |
|
3071 |
|
3072 |
|
3073 | strats.props =
|
3074 | strats.methods =
|
3075 | strats.inject =
|
3076 | strats.computed =
|
3077 | function (parentVal, childVal, vm, key) {
|
3078 | if (childVal && process.env.NODE_ENV !== 'production') {
|
3079 | assertObjectType(key, childVal, vm);
|
3080 | }
|
3081 | if (!parentVal)
|
3082 | return childVal;
|
3083 | const ret = Object.create(null);
|
3084 | extend(ret, parentVal);
|
3085 | if (childVal)
|
3086 | extend(ret, childVal);
|
3087 | return ret;
|
3088 | };
|
3089 | strats.provide = function (parentVal, childVal) {
|
3090 | if (!parentVal)
|
3091 | return childVal;
|
3092 | return function () {
|
3093 | const ret = Object.create(null);
|
3094 | mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
|
3095 | if (childVal) {
|
3096 | mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false
|
3097 | );
|
3098 | }
|
3099 | return ret;
|
3100 | };
|
3101 | };
|
3102 |
|
3103 |
|
3104 |
|
3105 | const defaultStrat = function (parentVal, childVal) {
|
3106 | return childVal === undefined ? parentVal : childVal;
|
3107 | };
|
3108 |
|
3109 |
|
3110 |
|
3111 | function checkComponents(options) {
|
3112 | for (const key in options.components) {
|
3113 | validateComponentName(key);
|
3114 | }
|
3115 | }
|
3116 | function validateComponentName(name) {
|
3117 | if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
|
3118 | warn$2('Invalid component name: "' +
|
3119 | name +
|
3120 | '". Component names ' +
|
3121 | 'should conform to valid custom element name in html5 specification.');
|
3122 | }
|
3123 | if (isBuiltInTag(name) || config.isReservedTag(name)) {
|
3124 | warn$2('Do not use built-in or reserved HTML elements as component ' +
|
3125 | 'id: ' +
|
3126 | name);
|
3127 | }
|
3128 | }
|
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 | function normalizeProps(options, vm) {
|
3134 | const props = options.props;
|
3135 | if (!props)
|
3136 | return;
|
3137 | const res = {};
|
3138 | let i, val, name;
|
3139 | if (isArray(props)) {
|
3140 | i = props.length;
|
3141 | while (i--) {
|
3142 | val = props[i];
|
3143 | if (typeof val === 'string') {
|
3144 | name = camelize(val);
|
3145 | res[name] = { type: null };
|
3146 | }
|
3147 | else if (process.env.NODE_ENV !== 'production') {
|
3148 | warn$2('props must be strings when using array syntax.');
|
3149 | }
|
3150 | }
|
3151 | }
|
3152 | else if (isPlainObject(props)) {
|
3153 | for (const key in props) {
|
3154 | val = props[key];
|
3155 | name = camelize(key);
|
3156 | res[name] = isPlainObject(val) ? val : { type: val };
|
3157 | }
|
3158 | }
|
3159 | else if (process.env.NODE_ENV !== 'production') {
|
3160 | warn$2(`Invalid value for option "props": expected an Array or an Object, ` +
|
3161 | `but got ${toRawType(props)}.`, vm);
|
3162 | }
|
3163 | options.props = res;
|
3164 | }
|
3165 |
|
3166 |
|
3167 |
|
3168 | function normalizeInject(options, vm) {
|
3169 | const inject = options.inject;
|
3170 | if (!inject)
|
3171 | return;
|
3172 | const normalized = (options.inject = {});
|
3173 | if (isArray(inject)) {
|
3174 | for (let i = 0; i < inject.length; i++) {
|
3175 | normalized[inject[i]] = { from: inject[i] };
|
3176 | }
|
3177 | }
|
3178 | else if (isPlainObject(inject)) {
|
3179 | for (const key in inject) {
|
3180 | const val = inject[key];
|
3181 | normalized[key] = isPlainObject(val)
|
3182 | ? extend({ from: key }, val)
|
3183 | : { from: val };
|
3184 | }
|
3185 | }
|
3186 | else if (process.env.NODE_ENV !== 'production') {
|
3187 | warn$2(`Invalid value for option "inject": expected an Array or an Object, ` +
|
3188 | `but got ${toRawType(inject)}.`, vm);
|
3189 | }
|
3190 | }
|
3191 |
|
3192 |
|
3193 |
|
3194 | function normalizeDirectives(options) {
|
3195 | const dirs = options.directives;
|
3196 | if (dirs) {
|
3197 | for (const key in dirs) {
|
3198 | const def = dirs[key];
|
3199 | if (isFunction(def)) {
|
3200 | dirs[key] = { bind: def, update: def };
|
3201 | }
|
3202 | }
|
3203 | }
|
3204 | }
|
3205 | function assertObjectType(name, value, vm) {
|
3206 | if (!isPlainObject(value)) {
|
3207 | warn$2(`Invalid value for option "${name}": expected an Object, ` +
|
3208 | `but got ${toRawType(value)}.`, vm);
|
3209 | }
|
3210 | }
|
3211 |
|
3212 |
|
3213 |
|
3214 |
|
3215 | function mergeOptions(parent, child, vm) {
|
3216 | if (process.env.NODE_ENV !== 'production') {
|
3217 | checkComponents(child);
|
3218 | }
|
3219 | if (isFunction(child)) {
|
3220 |
|
3221 | child = child.options;
|
3222 | }
|
3223 | normalizeProps(child, vm);
|
3224 | normalizeInject(child, vm);
|
3225 | normalizeDirectives(child);
|
3226 |
|
3227 |
|
3228 |
|
3229 |
|
3230 | if (!child._base) {
|
3231 | if (child.extends) {
|
3232 | parent = mergeOptions(parent, child.extends, vm);
|
3233 | }
|
3234 | if (child.mixins) {
|
3235 | for (let i = 0, l = child.mixins.length; i < l; i++) {
|
3236 | parent = mergeOptions(parent, child.mixins[i], vm);
|
3237 | }
|
3238 | }
|
3239 | }
|
3240 | const options = {};
|
3241 | let key;
|
3242 | for (key in parent) {
|
3243 | mergeField(key);
|
3244 | }
|
3245 | for (key in child) {
|
3246 | if (!hasOwn(parent, key)) {
|
3247 | mergeField(key);
|
3248 | }
|
3249 | }
|
3250 | function mergeField(key) {
|
3251 | const strat = strats[key] || defaultStrat;
|
3252 | options[key] = strat(parent[key], child[key], vm, key);
|
3253 | }
|
3254 | return options;
|
3255 | }
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 | function resolveAsset(options, type, id, warnMissing) {
|
3262 |
|
3263 | if (typeof id !== 'string') {
|
3264 | return;
|
3265 | }
|
3266 | const assets = options[type];
|
3267 |
|
3268 | if (hasOwn(assets, id))
|
3269 | return assets[id];
|
3270 | const camelizedId = camelize(id);
|
3271 | if (hasOwn(assets, camelizedId))
|
3272 | return assets[camelizedId];
|
3273 | const PascalCaseId = capitalize(camelizedId);
|
3274 | if (hasOwn(assets, PascalCaseId))
|
3275 | return assets[PascalCaseId];
|
3276 |
|
3277 | const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
|
3278 | if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
|
3279 | warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
|
3280 | }
|
3281 | return res;
|
3282 | }
|
3283 |
|
3284 | function validateProp(key, propOptions, propsData, vm) {
|
3285 | const prop = propOptions[key];
|
3286 | const absent = !hasOwn(propsData, key);
|
3287 | let value = propsData[key];
|
3288 |
|
3289 | const booleanIndex = getTypeIndex(Boolean, prop.type);
|
3290 | if (booleanIndex > -1) {
|
3291 | if (absent && !hasOwn(prop, 'default')) {
|
3292 | value = false;
|
3293 | }
|
3294 | else if (value === '' || value === hyphenate(key)) {
|
3295 |
|
3296 |
|
3297 | const stringIndex = getTypeIndex(String, prop.type);
|
3298 | if (stringIndex < 0 || booleanIndex < stringIndex) {
|
3299 | value = true;
|
3300 | }
|
3301 | }
|
3302 | }
|
3303 |
|
3304 | if (value === undefined) {
|
3305 | value = getPropDefaultValue(vm, prop, key);
|
3306 |
|
3307 |
|
3308 | const prevShouldObserve = shouldObserve;
|
3309 | toggleObserving(true);
|
3310 | observe(value);
|
3311 | toggleObserving(prevShouldObserve);
|
3312 | }
|
3313 | if (process.env.NODE_ENV !== 'production') {
|
3314 | assertProp(prop, key, value, vm, absent);
|
3315 | }
|
3316 | return value;
|
3317 | }
|
3318 |
|
3319 |
|
3320 |
|
3321 | function getPropDefaultValue(vm, prop, key) {
|
3322 |
|
3323 | if (!hasOwn(prop, 'default')) {
|
3324 | return undefined;
|
3325 | }
|
3326 | const def = prop.default;
|
3327 |
|
3328 | if (process.env.NODE_ENV !== 'production' && isObject(def)) {
|
3329 | warn$2('Invalid default value for prop "' +
|
3330 | key +
|
3331 | '": ' +
|
3332 | 'Props with type Object/Array must use a factory function ' +
|
3333 | 'to return the default value.', vm);
|
3334 | }
|
3335 |
|
3336 |
|
3337 | if (vm &&
|
3338 | vm.$options.propsData &&
|
3339 | vm.$options.propsData[key] === undefined &&
|
3340 | vm._props[key] !== undefined) {
|
3341 | return vm._props[key];
|
3342 | }
|
3343 |
|
3344 |
|
3345 | return isFunction(def) && getType(prop.type) !== 'Function'
|
3346 | ? def.call(vm)
|
3347 | : def;
|
3348 | }
|
3349 |
|
3350 |
|
3351 |
|
3352 | function assertProp(prop, name, value, vm, absent) {
|
3353 | if (prop.required && absent) {
|
3354 | warn$2('Missing required prop: "' + name + '"', vm);
|
3355 | return;
|
3356 | }
|
3357 | if (value == null && !prop.required) {
|
3358 | return;
|
3359 | }
|
3360 | let type = prop.type;
|
3361 | let valid = !type || type === true;
|
3362 | const expectedTypes = [];
|
3363 | if (type) {
|
3364 | if (!isArray(type)) {
|
3365 | type = [type];
|
3366 | }
|
3367 | for (let i = 0; i < type.length && !valid; i++) {
|
3368 | const assertedType = assertType(value, type[i], vm);
|
3369 | expectedTypes.push(assertedType.expectedType || '');
|
3370 | valid = assertedType.valid;
|
3371 | }
|
3372 | }
|
3373 | const haveExpectedTypes = expectedTypes.some(t => t);
|
3374 | if (!valid && haveExpectedTypes) {
|
3375 | warn$2(getInvalidTypeMessage(name, value, expectedTypes), vm);
|
3376 | return;
|
3377 | }
|
3378 | const validator = prop.validator;
|
3379 | if (validator) {
|
3380 | if (!validator(value)) {
|
3381 | warn$2('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
|
3382 | }
|
3383 | }
|
3384 | }
|
3385 | const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
|
3386 | function assertType(value, type, vm) {
|
3387 | let valid;
|
3388 | const expectedType = getType(type);
|
3389 | if (simpleCheckRE.test(expectedType)) {
|
3390 | const t = typeof value;
|
3391 | valid = t === expectedType.toLowerCase();
|
3392 |
|
3393 | if (!valid && t === 'object') {
|
3394 | valid = value instanceof type;
|
3395 | }
|
3396 | }
|
3397 | else if (expectedType === 'Object') {
|
3398 | valid = isPlainObject(value);
|
3399 | }
|
3400 | else if (expectedType === 'Array') {
|
3401 | valid = isArray(value);
|
3402 | }
|
3403 | else {
|
3404 | try {
|
3405 | valid = value instanceof type;
|
3406 | }
|
3407 | catch (e) {
|
3408 | warn$2('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
|
3409 | valid = false;
|
3410 | }
|
3411 | }
|
3412 | return {
|
3413 | valid,
|
3414 | expectedType
|
3415 | };
|
3416 | }
|
3417 | const functionTypeCheckRE = /^\s*function (\w+)/;
|
3418 |
|
3419 |
|
3420 |
|
3421 |
|
3422 |
|
3423 | function getType(fn) {
|
3424 | const match = fn && fn.toString().match(functionTypeCheckRE);
|
3425 | return match ? match[1] : '';
|
3426 | }
|
3427 | function isSameType(a, b) {
|
3428 | return getType(a) === getType(b);
|
3429 | }
|
3430 | function getTypeIndex(type, expectedTypes) {
|
3431 | if (!isArray(expectedTypes)) {
|
3432 | return isSameType(expectedTypes, type) ? 0 : -1;
|
3433 | }
|
3434 | for (let i = 0, len = expectedTypes.length; i < len; i++) {
|
3435 | if (isSameType(expectedTypes[i], type)) {
|
3436 | return i;
|
3437 | }
|
3438 | }
|
3439 | return -1;
|
3440 | }
|
3441 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
3442 | let message = `Invalid prop: type check failed for prop "${name}".` +
|
3443 | ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
|
3444 | const expectedType = expectedTypes[0];
|
3445 | const receivedType = toRawType(value);
|
3446 |
|
3447 | if (expectedTypes.length === 1 &&
|
3448 | isExplicable(expectedType) &&
|
3449 | isExplicable(typeof value) &&
|
3450 | !isBoolean(expectedType, receivedType)) {
|
3451 | message += ` with value ${styleValue(value, expectedType)}`;
|
3452 | }
|
3453 | message += `, got ${receivedType} `;
|
3454 |
|
3455 | if (isExplicable(receivedType)) {
|
3456 | message += `with value ${styleValue(value, receivedType)}.`;
|
3457 | }
|
3458 | return message;
|
3459 | }
|
3460 | function styleValue(value, type) {
|
3461 | if (type === 'String') {
|
3462 | return `"${value}"`;
|
3463 | }
|
3464 | else if (type === 'Number') {
|
3465 | return `${Number(value)}`;
|
3466 | }
|
3467 | else {
|
3468 | return `${value}`;
|
3469 | }
|
3470 | }
|
3471 | const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
|
3472 | function isExplicable(value) {
|
3473 | return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
|
3474 | }
|
3475 | function isBoolean(...args) {
|
3476 | return args.some(elem => elem.toLowerCase() === 'boolean');
|
3477 | }
|
3478 |
|
3479 |
|
3480 |
|
3481 | makeMap('style,class');
|
3482 |
|
3483 | const acceptValue = makeMap('input,textarea,option,select,progress');
|
3484 | const mustUseProp = (tag, type, attr) => {
|
3485 | return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
|
3486 | (attr === 'selected' && tag === 'option') ||
|
3487 | (attr === 'checked' && tag === 'input') ||
|
3488 | (attr === 'muted' && tag === 'video'));
|
3489 | };
|
3490 | const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
|
3491 | makeMap('events,caret,typing,plaintext-only');
|
3492 | const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
|
3493 | 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
|
3494 | 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
|
3495 | 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
|
3496 | 'required,reversed,scoped,seamless,selected,sortable,' +
|
3497 | 'truespeed,typemustmatch,visible');
|
3498 |
|
3499 | const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
|
3500 | 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
|
3501 | 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
|
3502 | 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
|
3503 | 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
|
3504 | 'embed,object,param,source,canvas,script,noscript,del,ins,' +
|
3505 | 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
|
3506 | 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
|
3507 | 'output,progress,select,textarea,' +
|
3508 | 'details,dialog,menu,menuitem,summary,' +
|
3509 | 'content,element,shadow,template,blockquote,iframe,tfoot');
|
3510 |
|
3511 |
|
3512 | const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
|
3513 | 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
|
3514 | 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
|
3515 | const isPreTag = (tag) => tag === 'pre';
|
3516 | const isReservedTag = (tag) => {
|
3517 | return isHTMLTag(tag) || isSVG(tag);
|
3518 | };
|
3519 | function getTagNamespace(tag) {
|
3520 | if (isSVG(tag)) {
|
3521 | return 'svg';
|
3522 | }
|
3523 |
|
3524 |
|
3525 | if (tag === 'math') {
|
3526 | return 'math';
|
3527 | }
|
3528 | }
|
3529 | makeMap('text,number,password,search,email,tel,url');
|
3530 |
|
3531 | const validDivisionCharRE = /[\w).+\-_$\]]/;
|
3532 | function parseFilters(exp) {
|
3533 | let inSingle = false;
|
3534 | let inDouble = false;
|
3535 | let inTemplateString = false;
|
3536 | let inRegex = false;
|
3537 | let curly = 0;
|
3538 | let square = 0;
|
3539 | let paren = 0;
|
3540 | let lastFilterIndex = 0;
|
3541 | let c, prev, i, expression, filters;
|
3542 | for (i = 0; i < exp.length; i++) {
|
3543 | prev = c;
|
3544 | c = exp.charCodeAt(i);
|
3545 | if (inSingle) {
|
3546 | if (c === 0x27 && prev !== 0x5c)
|
3547 | inSingle = false;
|
3548 | }
|
3549 | else if (inDouble) {
|
3550 | if (c === 0x22 && prev !== 0x5c)
|
3551 | inDouble = false;
|
3552 | }
|
3553 | else if (inTemplateString) {
|
3554 | if (c === 0x60 && prev !== 0x5c)
|
3555 | inTemplateString = false;
|
3556 | }
|
3557 | else if (inRegex) {
|
3558 | if (c === 0x2f && prev !== 0x5c)
|
3559 | inRegex = false;
|
3560 | }
|
3561 | else if (c === 0x7c &&
|
3562 | exp.charCodeAt(i + 1) !== 0x7c &&
|
3563 | exp.charCodeAt(i - 1) !== 0x7c &&
|
3564 | !curly &&
|
3565 | !square &&
|
3566 | !paren) {
|
3567 | if (expression === undefined) {
|
3568 |
|
3569 | lastFilterIndex = i + 1;
|
3570 | expression = exp.slice(0, i).trim();
|
3571 | }
|
3572 | else {
|
3573 | pushFilter();
|
3574 | }
|
3575 | }
|
3576 | else {
|
3577 | switch (c) {
|
3578 | case 0x22:
|
3579 | inDouble = true;
|
3580 | break;
|
3581 | case 0x27:
|
3582 | inSingle = true;
|
3583 | break;
|
3584 | case 0x60:
|
3585 | inTemplateString = true;
|
3586 | break;
|
3587 | case 0x28:
|
3588 | paren++;
|
3589 | break;
|
3590 | case 0x29:
|
3591 | paren--;
|
3592 | break;
|
3593 | case 0x5b:
|
3594 | square++;
|
3595 | break;
|
3596 | case 0x5d:
|
3597 | square--;
|
3598 | break;
|
3599 | case 0x7b:
|
3600 | curly++;
|
3601 | break;
|
3602 | case 0x7d:
|
3603 | curly--;
|
3604 | break;
|
3605 | }
|
3606 | if (c === 0x2f) {
|
3607 |
|
3608 | let j = i - 1;
|
3609 | let p;
|
3610 |
|
3611 | for (; j >= 0; j--) {
|
3612 | p = exp.charAt(j);
|
3613 | if (p !== ' ')
|
3614 | break;
|
3615 | }
|
3616 | if (!p || !validDivisionCharRE.test(p)) {
|
3617 | inRegex = true;
|
3618 | }
|
3619 | }
|
3620 | }
|
3621 | }
|
3622 | if (expression === undefined) {
|
3623 | expression = exp.slice(0, i).trim();
|
3624 | }
|
3625 | else if (lastFilterIndex !== 0) {
|
3626 | pushFilter();
|
3627 | }
|
3628 | function pushFilter() {
|
3629 | (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
|
3630 | lastFilterIndex = i + 1;
|
3631 | }
|
3632 | if (filters) {
|
3633 | for (i = 0; i < filters.length; i++) {
|
3634 | expression = wrapFilter(expression, filters[i]);
|
3635 | }
|
3636 | }
|
3637 | return expression;
|
3638 | }
|
3639 | function wrapFilter(exp, filter) {
|
3640 | const i = filter.indexOf('(');
|
3641 | if (i < 0) {
|
3642 |
|
3643 | return `_f("${filter}")(${exp})`;
|
3644 | }
|
3645 | else {
|
3646 | const name = filter.slice(0, i);
|
3647 | const args = filter.slice(i + 1);
|
3648 | return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
|
3649 | }
|
3650 | }
|
3651 |
|
3652 | const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
|
3653 | const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
|
3654 | const buildRegex = cached(delimiters => {
|
3655 | const open = delimiters[0].replace(regexEscapeRE, '\\$&');
|
3656 | const close = delimiters[1].replace(regexEscapeRE, '\\$&');
|
3657 | return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
|
3658 | });
|
3659 | function parseText(text, delimiters) {
|
3660 |
|
3661 | const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
|
3662 | if (!tagRE.test(text)) {
|
3663 | return;
|
3664 | }
|
3665 | const tokens = [];
|
3666 | const rawTokens = [];
|
3667 | let lastIndex = (tagRE.lastIndex = 0);
|
3668 | let match, index, tokenValue;
|
3669 | while ((match = tagRE.exec(text))) {
|
3670 | index = match.index;
|
3671 |
|
3672 | if (index > lastIndex) {
|
3673 | rawTokens.push((tokenValue = text.slice(lastIndex, index)));
|
3674 | tokens.push(JSON.stringify(tokenValue));
|
3675 | }
|
3676 |
|
3677 | const exp = parseFilters(match[1].trim());
|
3678 | tokens.push(`_s(${exp})`);
|
3679 | rawTokens.push({ '@binding': exp });
|
3680 | lastIndex = index + match[0].length;
|
3681 | }
|
3682 | if (lastIndex < text.length) {
|
3683 | rawTokens.push((tokenValue = text.slice(lastIndex)));
|
3684 | tokens.push(JSON.stringify(tokenValue));
|
3685 | }
|
3686 | return {
|
3687 | expression: tokens.join('+'),
|
3688 | tokens: rawTokens
|
3689 | };
|
3690 | }
|
3691 |
|
3692 |
|
3693 | function baseWarn(msg, range) {
|
3694 | console.error(`[Vue compiler]: ${msg}`);
|
3695 | }
|
3696 |
|
3697 | function pluckModuleFunction(modules, key) {
|
3698 | return modules ? modules.map(m => m[key]).filter(_ => _) : [];
|
3699 | }
|
3700 | function addProp(el, name, value, range, dynamic) {
|
3701 | (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
|
3702 | el.plain = false;
|
3703 | }
|
3704 | function addAttr(el, name, value, range, dynamic) {
|
3705 | const attrs = dynamic
|
3706 | ? el.dynamicAttrs || (el.dynamicAttrs = [])
|
3707 | : el.attrs || (el.attrs = []);
|
3708 | attrs.push(rangeSetItem({ name, value, dynamic }, range));
|
3709 | el.plain = false;
|
3710 | }
|
3711 |
|
3712 | function addRawAttr(el, name, value, range) {
|
3713 | el.attrsMap[name] = value;
|
3714 | el.attrsList.push(rangeSetItem({ name, value }, range));
|
3715 | }
|
3716 | function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
|
3717 | (el.directives || (el.directives = [])).push(rangeSetItem({
|
3718 | name,
|
3719 | rawName,
|
3720 | value,
|
3721 | arg,
|
3722 | isDynamicArg,
|
3723 | modifiers
|
3724 | }, range));
|
3725 | el.plain = false;
|
3726 | }
|
3727 | function prependModifierMarker(symbol, name, dynamic) {
|
3728 | return dynamic ? `_p(${name},"${symbol}")` : symbol + name;
|
3729 | }
|
3730 | function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
|
3731 | modifiers = modifiers || emptyObject;
|
3732 |
|
3733 |
|
3734 | if (process.env.NODE_ENV !== 'production' && warn && modifiers.prevent && modifiers.passive) {
|
3735 | warn("passive and prevent can't be used together. " +
|
3736 | "Passive handler can't prevent default event.", range);
|
3737 | }
|
3738 |
|
3739 |
|
3740 |
|
3741 | if (modifiers.right) {
|
3742 | if (dynamic) {
|
3743 | name = `(${name})==='click'?'contextmenu':(${name})`;
|
3744 | }
|
3745 | else if (name === 'click') {
|
3746 | name = 'contextmenu';
|
3747 | delete modifiers.right;
|
3748 | }
|
3749 | }
|
3750 | else if (modifiers.middle) {
|
3751 | if (dynamic) {
|
3752 | name = `(${name})==='click'?'mouseup':(${name})`;
|
3753 | }
|
3754 | else if (name === 'click') {
|
3755 | name = 'mouseup';
|
3756 | }
|
3757 | }
|
3758 |
|
3759 | if (modifiers.capture) {
|
3760 | delete modifiers.capture;
|
3761 | name = prependModifierMarker('!', name, dynamic);
|
3762 | }
|
3763 | if (modifiers.once) {
|
3764 | delete modifiers.once;
|
3765 | name = prependModifierMarker('~', name, dynamic);
|
3766 | }
|
3767 |
|
3768 | if (modifiers.passive) {
|
3769 | delete modifiers.passive;
|
3770 | name = prependModifierMarker('&', name, dynamic);
|
3771 | }
|
3772 | let events;
|
3773 | if (modifiers.native) {
|
3774 | delete modifiers.native;
|
3775 | events = el.nativeEvents || (el.nativeEvents = {});
|
3776 | }
|
3777 | else {
|
3778 | events = el.events || (el.events = {});
|
3779 | }
|
3780 | const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
|
3781 | if (modifiers !== emptyObject) {
|
3782 | newHandler.modifiers = modifiers;
|
3783 | }
|
3784 | const handlers = events[name];
|
3785 |
|
3786 | if (Array.isArray(handlers)) {
|
3787 | important ? handlers.unshift(newHandler) : handlers.push(newHandler);
|
3788 | }
|
3789 | else if (handlers) {
|
3790 | events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
|
3791 | }
|
3792 | else {
|
3793 | events[name] = newHandler;
|
3794 | }
|
3795 | el.plain = false;
|
3796 | }
|
3797 | function getRawBindingAttr(el, name) {
|
3798 | return (el.rawAttrsMap[':' + name] ||
|
3799 | el.rawAttrsMap['v-bind:' + name] ||
|
3800 | el.rawAttrsMap[name]);
|
3801 | }
|
3802 | function getBindingAttr(el, name, getStatic) {
|
3803 | const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
|
3804 | if (dynamicValue != null) {
|
3805 | return parseFilters(dynamicValue);
|
3806 | }
|
3807 | else if (getStatic !== false) {
|
3808 | const staticValue = getAndRemoveAttr(el, name);
|
3809 | if (staticValue != null) {
|
3810 | return JSON.stringify(staticValue);
|
3811 | }
|
3812 | }
|
3813 | }
|
3814 |
|
3815 |
|
3816 |
|
3817 |
|
3818 | function getAndRemoveAttr(el, name, removeFromMap) {
|
3819 | let val;
|
3820 | if ((val = el.attrsMap[name]) != null) {
|
3821 | const list = el.attrsList;
|
3822 | for (let i = 0, l = list.length; i < l; i++) {
|
3823 | if (list[i].name === name) {
|
3824 | list.splice(i, 1);
|
3825 | break;
|
3826 | }
|
3827 | }
|
3828 | }
|
3829 | if (removeFromMap) {
|
3830 | delete el.attrsMap[name];
|
3831 | }
|
3832 | return val;
|
3833 | }
|
3834 | function getAndRemoveAttrByRegex(el, name) {
|
3835 | const list = el.attrsList;
|
3836 | for (let i = 0, l = list.length; i < l; i++) {
|
3837 | const attr = list[i];
|
3838 | if (name.test(attr.name)) {
|
3839 | list.splice(i, 1);
|
3840 | return attr;
|
3841 | }
|
3842 | }
|
3843 | }
|
3844 | function rangeSetItem(item, range) {
|
3845 | if (range) {
|
3846 | if (range.start != null) {
|
3847 | item.start = range.start;
|
3848 | }
|
3849 | if (range.end != null) {
|
3850 | item.end = range.end;
|
3851 | }
|
3852 | }
|
3853 | return item;
|
3854 | }
|
3855 |
|
3856 | function transformNode$1(el, options) {
|
3857 | const warn = options.warn || baseWarn;
|
3858 | const staticClass = getAndRemoveAttr(el, 'class');
|
3859 | if (process.env.NODE_ENV !== 'production' && staticClass) {
|
3860 | const res = parseText(staticClass, options.delimiters);
|
3861 | if (res) {
|
3862 | warn(`class="${staticClass}": ` +
|
3863 | 'Interpolation inside attributes has been removed. ' +
|
3864 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
3865 | 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
|
3866 | }
|
3867 | }
|
3868 | if (staticClass) {
|
3869 | el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
|
3870 | }
|
3871 | const classBinding = getBindingAttr(el, 'class', false );
|
3872 | if (classBinding) {
|
3873 | el.classBinding = classBinding;
|
3874 | }
|
3875 | }
|
3876 | function genData$2(el) {
|
3877 | let data = '';
|
3878 | if (el.staticClass) {
|
3879 | data += `staticClass:${el.staticClass},`;
|
3880 | }
|
3881 | if (el.classBinding) {
|
3882 | data += `class:${el.classBinding},`;
|
3883 | }
|
3884 | return data;
|
3885 | }
|
3886 | var klass = {
|
3887 | staticKeys: ['staticClass'],
|
3888 | transformNode: transformNode$1,
|
3889 | genData: genData$2
|
3890 | };
|
3891 |
|
3892 | const parseStyleText = cached(function (cssText) {
|
3893 | const res = {};
|
3894 | const listDelimiter = /;(?![^(]*\))/g;
|
3895 | const propertyDelimiter = /:(.+)/;
|
3896 | cssText.split(listDelimiter).forEach(function (item) {
|
3897 | if (item) {
|
3898 | const tmp = item.split(propertyDelimiter);
|
3899 | tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
|
3900 | }
|
3901 | });
|
3902 | return res;
|
3903 | });
|
3904 |
|
3905 | function transformNode(el, options) {
|
3906 | const warn = options.warn || baseWarn;
|
3907 | const staticStyle = getAndRemoveAttr(el, 'style');
|
3908 | if (staticStyle) {
|
3909 |
|
3910 | if (process.env.NODE_ENV !== 'production') {
|
3911 | const res = parseText(staticStyle, options.delimiters);
|
3912 | if (res) {
|
3913 | warn(`style="${staticStyle}": ` +
|
3914 | 'Interpolation inside attributes has been removed. ' +
|
3915 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
3916 | 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
|
3917 | }
|
3918 | }
|
3919 | el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
|
3920 | }
|
3921 | const styleBinding = getBindingAttr(el, 'style', false );
|
3922 | if (styleBinding) {
|
3923 | el.styleBinding = styleBinding;
|
3924 | }
|
3925 | }
|
3926 | function genData$1(el) {
|
3927 | let data = '';
|
3928 | if (el.staticStyle) {
|
3929 | data += `staticStyle:${el.staticStyle},`;
|
3930 | }
|
3931 | if (el.styleBinding) {
|
3932 | data += `style:(${el.styleBinding}),`;
|
3933 | }
|
3934 | return data;
|
3935 | }
|
3936 | var style = {
|
3937 | staticKeys: ['staticStyle'],
|
3938 | transformNode,
|
3939 | genData: genData$1
|
3940 | };
|
3941 |
|
3942 |
|
3943 |
|
3944 |
|
3945 | function genComponentModel(el, value, modifiers) {
|
3946 | const { number, trim } = modifiers || {};
|
3947 | const baseValueExpression = '$$v';
|
3948 | let valueExpression = baseValueExpression;
|
3949 | if (trim) {
|
3950 | valueExpression =
|
3951 | `(typeof ${baseValueExpression} === 'string'` +
|
3952 | `? ${baseValueExpression}.trim()` +
|
3953 | `: ${baseValueExpression})`;
|
3954 | }
|
3955 | if (number) {
|
3956 | valueExpression = `_n(${valueExpression})`;
|
3957 | }
|
3958 | const assignment = genAssignmentCode(value, valueExpression);
|
3959 | el.model = {
|
3960 | value: `(${value})`,
|
3961 | expression: JSON.stringify(value),
|
3962 | callback: `function (${baseValueExpression}) {${assignment}}`
|
3963 | };
|
3964 | }
|
3965 |
|
3966 |
|
3967 |
|
3968 | function genAssignmentCode(value, assignment) {
|
3969 | const res = parseModel(value);
|
3970 | if (res.key === null) {
|
3971 | return `${value}=${assignment}`;
|
3972 | }
|
3973 | else {
|
3974 | return `$set(${res.exp}, ${res.key}, ${assignment})`;
|
3975 | }
|
3976 | }
|
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 |
|
3983 |
|
3984 |
|
3985 |
|
3986 |
|
3987 |
|
3988 |
|
3989 |
|
3990 |
|
3991 | let len, str, chr, index, expressionPos, expressionEndPos;
|
3992 | function parseModel(val) {
|
3993 |
|
3994 |
|
3995 | val = val.trim();
|
3996 | len = val.length;
|
3997 | if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
|
3998 | index = val.lastIndexOf('.');
|
3999 | if (index > -1) {
|
4000 | return {
|
4001 | exp: val.slice(0, index),
|
4002 | key: '"' + val.slice(index + 1) + '"'
|
4003 | };
|
4004 | }
|
4005 | else {
|
4006 | return {
|
4007 | exp: val,
|
4008 | key: null
|
4009 | };
|
4010 | }
|
4011 | }
|
4012 | str = val;
|
4013 | index = expressionPos = expressionEndPos = 0;
|
4014 | while (!eof()) {
|
4015 | chr = next();
|
4016 |
|
4017 | if (isStringStart(chr)) {
|
4018 | parseString(chr);
|
4019 | }
|
4020 | else if (chr === 0x5b) {
|
4021 | parseBracket(chr);
|
4022 | }
|
4023 | }
|
4024 | return {
|
4025 | exp: val.slice(0, expressionPos),
|
4026 | key: val.slice(expressionPos + 1, expressionEndPos)
|
4027 | };
|
4028 | }
|
4029 | function next() {
|
4030 | return str.charCodeAt(++index);
|
4031 | }
|
4032 | function eof() {
|
4033 | return index >= len;
|
4034 | }
|
4035 | function isStringStart(chr) {
|
4036 | return chr === 0x22 || chr === 0x27;
|
4037 | }
|
4038 | function parseBracket(chr) {
|
4039 | let inBracket = 1;
|
4040 | expressionPos = index;
|
4041 | while (!eof()) {
|
4042 | chr = next();
|
4043 | if (isStringStart(chr)) {
|
4044 | parseString(chr);
|
4045 | continue;
|
4046 | }
|
4047 | if (chr === 0x5b)
|
4048 | inBracket++;
|
4049 | if (chr === 0x5d)
|
4050 | inBracket--;
|
4051 | if (inBracket === 0) {
|
4052 | expressionEndPos = index;
|
4053 | break;
|
4054 | }
|
4055 | }
|
4056 | }
|
4057 | function parseString(chr) {
|
4058 | const stringQuote = chr;
|
4059 | while (!eof()) {
|
4060 | chr = next();
|
4061 | if (chr === stringQuote) {
|
4062 | break;
|
4063 | }
|
4064 | }
|
4065 | }
|
4066 |
|
4067 | const onRE = /^@|^v-on:/;
|
4068 | const dirRE = /^v-|^@|^:|^#/;
|
4069 | const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
4070 | const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
4071 | const stripParensRE = /^\(|\)$/g;
|
4072 | const dynamicArgRE = /^\[.*\]$/;
|
4073 | const argRE = /:(.*)$/;
|
4074 | const bindRE = /^:|^\.|^v-bind:/;
|
4075 | const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
|
4076 | const slotRE = /^v-slot(:|$)|^#/;
|
4077 | const lineBreakRE = /[\r\n]/;
|
4078 | const whitespaceRE = /[ \f\t\r\n]+/g;
|
4079 | const invalidAttributeRE = /[\s"'<>\/=]/;
|
4080 | const decodeHTMLCached = cached(he__default["default"].decode);
|
4081 | const emptySlotScopeToken = `_empty_`;
|
4082 |
|
4083 | let warn$1;
|
4084 | let delimiters;
|
4085 | let transforms;
|
4086 | let preTransforms;
|
4087 | let postTransforms;
|
4088 | let platformIsPreTag;
|
4089 | let platformMustUseProp;
|
4090 | let platformGetTagNamespace;
|
4091 | let maybeComponent;
|
4092 | function createASTElement(tag, attrs, parent) {
|
4093 | return {
|
4094 | type: 1,
|
4095 | tag,
|
4096 | attrsList: attrs,
|
4097 | attrsMap: makeAttrsMap(attrs),
|
4098 | rawAttrsMap: {},
|
4099 | parent,
|
4100 | children: []
|
4101 | };
|
4102 | }
|
4103 |
|
4104 |
|
4105 |
|
4106 | function parse(template, options) {
|
4107 | warn$1 = options.warn || baseWarn;
|
4108 | platformIsPreTag = options.isPreTag || no;
|
4109 | platformMustUseProp = options.mustUseProp || no;
|
4110 | platformGetTagNamespace = options.getTagNamespace || no;
|
4111 | const isReservedTag = options.isReservedTag || no;
|
4112 | maybeComponent = (el) => !!(el.component ||
|
4113 | el.attrsMap[':is'] ||
|
4114 | el.attrsMap['v-bind:is'] ||
|
4115 | !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
|
4116 | transforms = pluckModuleFunction(options.modules, 'transformNode');
|
4117 | preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
|
4118 | postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
|
4119 | delimiters = options.delimiters;
|
4120 | const stack = [];
|
4121 | const preserveWhitespace = options.preserveWhitespace !== false;
|
4122 | const whitespaceOption = options.whitespace;
|
4123 | let root;
|
4124 | let currentParent;
|
4125 | let inVPre = false;
|
4126 | let inPre = false;
|
4127 | let warned = false;
|
4128 | function warnOnce(msg, range) {
|
4129 | if (!warned) {
|
4130 | warned = true;
|
4131 | warn$1(msg, range);
|
4132 | }
|
4133 | }
|
4134 | function closeElement(element) {
|
4135 | trimEndingWhitespace(element);
|
4136 | if (!inVPre && !element.processed) {
|
4137 | element = processElement(element, options);
|
4138 | }
|
4139 |
|
4140 | if (!stack.length && element !== root) {
|
4141 |
|
4142 | if (root.if && (element.elseif || element.else)) {
|
4143 | if (process.env.NODE_ENV !== 'production') {
|
4144 | checkRootConstraints(element);
|
4145 | }
|
4146 | addIfCondition(root, {
|
4147 | exp: element.elseif,
|
4148 | block: element
|
4149 | });
|
4150 | }
|
4151 | else if (process.env.NODE_ENV !== 'production') {
|
4152 | warnOnce(`Component template should contain exactly one root element. ` +
|
4153 | `If you are using v-if on multiple elements, ` +
|
4154 | `use v-else-if to chain them instead.`, { start: element.start });
|
4155 | }
|
4156 | }
|
4157 | if (currentParent && !element.forbidden) {
|
4158 | if (element.elseif || element.else) {
|
4159 | processIfConditions(element, currentParent);
|
4160 | }
|
4161 | else {
|
4162 | if (element.slotScope) {
|
4163 |
|
4164 |
|
4165 |
|
4166 | const name = element.slotTarget || '"default"';
|
4167 | (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
|
4168 | }
|
4169 | currentParent.children.push(element);
|
4170 | element.parent = currentParent;
|
4171 | }
|
4172 | }
|
4173 |
|
4174 |
|
4175 | element.children = element.children.filter(c => !c.slotScope);
|
4176 |
|
4177 | trimEndingWhitespace(element);
|
4178 |
|
4179 | if (element.pre) {
|
4180 | inVPre = false;
|
4181 | }
|
4182 | if (platformIsPreTag(element.tag)) {
|
4183 | inPre = false;
|
4184 | }
|
4185 |
|
4186 | for (let i = 0; i < postTransforms.length; i++) {
|
4187 | postTransforms[i](element, options);
|
4188 | }
|
4189 | }
|
4190 | function trimEndingWhitespace(el) {
|
4191 |
|
4192 | if (!inPre) {
|
4193 | let lastNode;
|
4194 | while ((lastNode = el.children[el.children.length - 1]) &&
|
4195 | lastNode.type === 3 &&
|
4196 | lastNode.text === ' ') {
|
4197 | el.children.pop();
|
4198 | }
|
4199 | }
|
4200 | }
|
4201 | function checkRootConstraints(el) {
|
4202 | if (el.tag === 'slot' || el.tag === 'template') {
|
4203 | warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
|
4204 | 'contain multiple nodes.', { start: el.start });
|
4205 | }
|
4206 | if (el.attrsMap.hasOwnProperty('v-for')) {
|
4207 | warnOnce('Cannot use v-for on stateful component root element because ' +
|
4208 | 'it renders multiple elements.', el.rawAttrsMap['v-for']);
|
4209 | }
|
4210 | }
|
4211 | parseHTML(template, {
|
4212 | warn: warn$1,
|
4213 | expectHTML: options.expectHTML,
|
4214 | isUnaryTag: options.isUnaryTag,
|
4215 | canBeLeftOpenTag: options.canBeLeftOpenTag,
|
4216 | shouldDecodeNewlines: options.shouldDecodeNewlines,
|
4217 | shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
|
4218 | shouldKeepComment: options.comments,
|
4219 | outputSourceRange: options.outputSourceRange,
|
4220 | start(tag, attrs, unary, start, end) {
|
4221 |
|
4222 |
|
4223 | const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
|
4224 |
|
4225 |
|
4226 | if (isIE && ns === 'svg') {
|
4227 | attrs = guardIESVGBug(attrs);
|
4228 | }
|
4229 | let element = createASTElement(tag, attrs, currentParent);
|
4230 | if (ns) {
|
4231 | element.ns = ns;
|
4232 | }
|
4233 | if (process.env.NODE_ENV !== 'production') {
|
4234 | if (options.outputSourceRange) {
|
4235 | element.start = start;
|
4236 | element.end = end;
|
4237 | element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
|
4238 | cumulated[attr.name] = attr;
|
4239 | return cumulated;
|
4240 | }, {});
|
4241 | }
|
4242 | attrs.forEach(attr => {
|
4243 | if (invalidAttributeRE.test(attr.name)) {
|
4244 | warn$1(`Invalid dynamic argument expression: attribute names cannot contain ` +
|
4245 | `spaces, quotes, <, >, / or =.`, options.outputSourceRange
|
4246 | ? {
|
4247 | start: attr.start + attr.name.indexOf(`[`),
|
4248 | end: attr.start + attr.name.length
|
4249 | }
|
4250 | : undefined);
|
4251 | }
|
4252 | });
|
4253 | }
|
4254 | if (isForbiddenTag(element) && !isServerRendering()) {
|
4255 | element.forbidden = true;
|
4256 | process.env.NODE_ENV !== 'production' &&
|
4257 | warn$1('Templates should only be responsible for mapping the state to the ' +
|
4258 | 'UI. Avoid placing tags with side-effects in your templates, such as ' +
|
4259 | `<${tag}>` +
|
4260 | ', as they will not be parsed.', { start: element.start });
|
4261 | }
|
4262 |
|
4263 | for (let i = 0; i < preTransforms.length; i++) {
|
4264 | element = preTransforms[i](element, options) || element;
|
4265 | }
|
4266 | if (!inVPre) {
|
4267 | processPre(element);
|
4268 | if (element.pre) {
|
4269 | inVPre = true;
|
4270 | }
|
4271 | }
|
4272 | if (platformIsPreTag(element.tag)) {
|
4273 | inPre = true;
|
4274 | }
|
4275 | if (inVPre) {
|
4276 | processRawAttrs(element);
|
4277 | }
|
4278 | else if (!element.processed) {
|
4279 |
|
4280 | processFor(element);
|
4281 | processIf(element);
|
4282 | processOnce(element);
|
4283 | }
|
4284 | if (!root) {
|
4285 | root = element;
|
4286 | if (process.env.NODE_ENV !== 'production') {
|
4287 | checkRootConstraints(root);
|
4288 | }
|
4289 | }
|
4290 | if (!unary) {
|
4291 | currentParent = element;
|
4292 | stack.push(element);
|
4293 | }
|
4294 | else {
|
4295 | closeElement(element);
|
4296 | }
|
4297 | },
|
4298 | end(tag, start, end) {
|
4299 | const element = stack[stack.length - 1];
|
4300 |
|
4301 | stack.length -= 1;
|
4302 | currentParent = stack[stack.length - 1];
|
4303 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
4304 | element.end = end;
|
4305 | }
|
4306 | closeElement(element);
|
4307 | },
|
4308 | chars(text, start, end) {
|
4309 | if (!currentParent) {
|
4310 | if (process.env.NODE_ENV !== 'production') {
|
4311 | if (text === template) {
|
4312 | warnOnce('Component template requires a root element, rather than just text.', { start });
|
4313 | }
|
4314 | else if ((text = text.trim())) {
|
4315 | warnOnce(`text "${text}" outside root element will be ignored.`, {
|
4316 | start
|
4317 | });
|
4318 | }
|
4319 | }
|
4320 | return;
|
4321 | }
|
4322 |
|
4323 |
|
4324 | if (isIE &&
|
4325 | currentParent.tag === 'textarea' &&
|
4326 | currentParent.attrsMap.placeholder === text) {
|
4327 | return;
|
4328 | }
|
4329 | const children = currentParent.children;
|
4330 | if (inPre || text.trim()) {
|
4331 | text = isTextTag(currentParent)
|
4332 | ? text
|
4333 | : decodeHTMLCached(text);
|
4334 | }
|
4335 | else if (!children.length) {
|
4336 |
|
4337 | text = '';
|
4338 | }
|
4339 | else if (whitespaceOption) {
|
4340 | if (whitespaceOption === 'condense') {
|
4341 |
|
4342 |
|
4343 | text = lineBreakRE.test(text) ? '' : ' ';
|
4344 | }
|
4345 | else {
|
4346 | text = ' ';
|
4347 | }
|
4348 | }
|
4349 | else {
|
4350 | text = preserveWhitespace ? ' ' : '';
|
4351 | }
|
4352 | if (text) {
|
4353 | if (!inPre && whitespaceOption === 'condense') {
|
4354 |
|
4355 | text = text.replace(whitespaceRE, ' ');
|
4356 | }
|
4357 | let res;
|
4358 | let child;
|
4359 | if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
|
4360 | child = {
|
4361 | type: 2,
|
4362 | expression: res.expression,
|
4363 | tokens: res.tokens,
|
4364 | text
|
4365 | };
|
4366 | }
|
4367 | else if (text !== ' ' ||
|
4368 | !children.length ||
|
4369 | children[children.length - 1].text !== ' ') {
|
4370 | child = {
|
4371 | type: 3,
|
4372 | text
|
4373 | };
|
4374 | }
|
4375 | if (child) {
|
4376 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
4377 | child.start = start;
|
4378 | child.end = end;
|
4379 | }
|
4380 | children.push(child);
|
4381 | }
|
4382 | }
|
4383 | },
|
4384 | comment(text, start, end) {
|
4385 |
|
4386 |
|
4387 | if (currentParent) {
|
4388 | const child = {
|
4389 | type: 3,
|
4390 | text,
|
4391 | isComment: true
|
4392 | };
|
4393 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
4394 | child.start = start;
|
4395 | child.end = end;
|
4396 | }
|
4397 | currentParent.children.push(child);
|
4398 | }
|
4399 | }
|
4400 | });
|
4401 | return root;
|
4402 | }
|
4403 | function processPre(el) {
|
4404 | if (getAndRemoveAttr(el, 'v-pre') != null) {
|
4405 | el.pre = true;
|
4406 | }
|
4407 | }
|
4408 | function processRawAttrs(el) {
|
4409 | const list = el.attrsList;
|
4410 | const len = list.length;
|
4411 | if (len) {
|
4412 | const attrs = (el.attrs = new Array(len));
|
4413 | for (let i = 0; i < len; i++) {
|
4414 | attrs[i] = {
|
4415 | name: list[i].name,
|
4416 | value: JSON.stringify(list[i].value)
|
4417 | };
|
4418 | if (list[i].start != null) {
|
4419 | attrs[i].start = list[i].start;
|
4420 | attrs[i].end = list[i].end;
|
4421 | }
|
4422 | }
|
4423 | }
|
4424 | else if (!el.pre) {
|
4425 |
|
4426 | el.plain = true;
|
4427 | }
|
4428 | }
|
4429 | function processElement(element, options) {
|
4430 | processKey(element);
|
4431 |
|
4432 |
|
4433 | element.plain =
|
4434 | !element.key && !element.scopedSlots && !element.attrsList.length;
|
4435 | processRef(element);
|
4436 | processSlotContent(element);
|
4437 | processSlotOutlet(element);
|
4438 | processComponent(element);
|
4439 | for (let i = 0; i < transforms.length; i++) {
|
4440 | element = transforms[i](element, options) || element;
|
4441 | }
|
4442 | processAttrs(element);
|
4443 | return element;
|
4444 | }
|
4445 | function processKey(el) {
|
4446 | const exp = getBindingAttr(el, 'key');
|
4447 | if (exp) {
|
4448 | if (process.env.NODE_ENV !== 'production') {
|
4449 | if (el.tag === 'template') {
|
4450 | warn$1(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
|
4451 | }
|
4452 | if (el.for) {
|
4453 | const iterator = el.iterator2 || el.iterator1;
|
4454 | const parent = el.parent;
|
4455 | if (iterator &&
|
4456 | iterator === exp &&
|
4457 | parent &&
|
4458 | parent.tag === 'transition-group') {
|
4459 | warn$1(`Do not use v-for index as key on <transition-group> children, ` +
|
4460 | `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true );
|
4461 | }
|
4462 | }
|
4463 | }
|
4464 | el.key = exp;
|
4465 | }
|
4466 | }
|
4467 | function processRef(el) {
|
4468 | const ref = getBindingAttr(el, 'ref');
|
4469 | if (ref) {
|
4470 | el.ref = ref;
|
4471 | el.refInFor = checkInFor(el);
|
4472 | }
|
4473 | }
|
4474 | function processFor(el) {
|
4475 | let exp;
|
4476 | if ((exp = getAndRemoveAttr(el, 'v-for'))) {
|
4477 | const res = parseFor(exp);
|
4478 | if (res) {
|
4479 | extend(el, res);
|
4480 | }
|
4481 | else if (process.env.NODE_ENV !== 'production') {
|
4482 | warn$1(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
|
4483 | }
|
4484 | }
|
4485 | }
|
4486 | function parseFor(exp) {
|
4487 | const inMatch = exp.match(forAliasRE);
|
4488 | if (!inMatch)
|
4489 | return;
|
4490 | const res = {};
|
4491 | res.for = inMatch[2].trim();
|
4492 | const alias = inMatch[1].trim().replace(stripParensRE, '');
|
4493 | const iteratorMatch = alias.match(forIteratorRE);
|
4494 | if (iteratorMatch) {
|
4495 | res.alias = alias.replace(forIteratorRE, '').trim();
|
4496 | res.iterator1 = iteratorMatch[1].trim();
|
4497 | if (iteratorMatch[2]) {
|
4498 | res.iterator2 = iteratorMatch[2].trim();
|
4499 | }
|
4500 | }
|
4501 | else {
|
4502 | res.alias = alias;
|
4503 | }
|
4504 | return res;
|
4505 | }
|
4506 | function processIf(el) {
|
4507 | const exp = getAndRemoveAttr(el, 'v-if');
|
4508 | if (exp) {
|
4509 | el.if = exp;
|
4510 | addIfCondition(el, {
|
4511 | exp: exp,
|
4512 | block: el
|
4513 | });
|
4514 | }
|
4515 | else {
|
4516 | if (getAndRemoveAttr(el, 'v-else') != null) {
|
4517 | el.else = true;
|
4518 | }
|
4519 | const elseif = getAndRemoveAttr(el, 'v-else-if');
|
4520 | if (elseif) {
|
4521 | el.elseif = elseif;
|
4522 | }
|
4523 | }
|
4524 | }
|
4525 | function processIfConditions(el, parent) {
|
4526 | const prev = findPrevElement(parent.children);
|
4527 | if (prev && prev.if) {
|
4528 | addIfCondition(prev, {
|
4529 | exp: el.elseif,
|
4530 | block: el
|
4531 | });
|
4532 | }
|
4533 | else if (process.env.NODE_ENV !== 'production') {
|
4534 | warn$1(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
|
4535 | `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
|
4536 | }
|
4537 | }
|
4538 | function findPrevElement(children) {
|
4539 | let i = children.length;
|
4540 | while (i--) {
|
4541 | if (children[i].type === 1) {
|
4542 | return children[i];
|
4543 | }
|
4544 | else {
|
4545 | if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
|
4546 | warn$1(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
|
4547 | `will be ignored.`, children[i]);
|
4548 | }
|
4549 | children.pop();
|
4550 | }
|
4551 | }
|
4552 | }
|
4553 | function addIfCondition(el, condition) {
|
4554 | if (!el.ifConditions) {
|
4555 | el.ifConditions = [];
|
4556 | }
|
4557 | el.ifConditions.push(condition);
|
4558 | }
|
4559 | function processOnce(el) {
|
4560 | const once = getAndRemoveAttr(el, 'v-once');
|
4561 | if (once != null) {
|
4562 | el.once = true;
|
4563 | }
|
4564 | }
|
4565 |
|
4566 |
|
4567 | function processSlotContent(el) {
|
4568 | let slotScope;
|
4569 | if (el.tag === 'template') {
|
4570 | slotScope = getAndRemoveAttr(el, 'scope');
|
4571 |
|
4572 | if (process.env.NODE_ENV !== 'production' && slotScope) {
|
4573 | warn$1(`the "scope" attribute for scoped slots have been deprecated and ` +
|
4574 | `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
|
4575 | `can also be used on plain elements in addition to <template> to ` +
|
4576 | `denote scoped slots.`, el.rawAttrsMap['scope'], true);
|
4577 | }
|
4578 | el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
|
4579 | }
|
4580 | else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
|
4581 |
|
4582 | if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
|
4583 | warn$1(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
|
4584 | `(v-for takes higher priority). Use a wrapper <template> for the ` +
|
4585 | `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
|
4586 | }
|
4587 | el.slotScope = slotScope;
|
4588 | }
|
4589 |
|
4590 | const slotTarget = getBindingAttr(el, 'slot');
|
4591 | if (slotTarget) {
|
4592 | el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
|
4593 | el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
|
4594 |
|
4595 |
|
4596 | if (el.tag !== 'template' && !el.slotScope) {
|
4597 | addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
|
4598 | }
|
4599 | }
|
4600 |
|
4601 | {
|
4602 | if (el.tag === 'template') {
|
4603 |
|
4604 | const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
|
4605 | if (slotBinding) {
|
4606 | if (process.env.NODE_ENV !== 'production') {
|
4607 | if (el.slotTarget || el.slotScope) {
|
4608 | warn$1(`Unexpected mixed usage of different slot syntaxes.`, el);
|
4609 | }
|
4610 | if (el.parent && !maybeComponent(el.parent)) {
|
4611 | warn$1(`<template v-slot> can only appear at the root level inside ` +
|
4612 | `the receiving component`, el);
|
4613 | }
|
4614 | }
|
4615 | const { name, dynamic } = getSlotName(slotBinding);
|
4616 | el.slotTarget = name;
|
4617 | el.slotTargetDynamic = dynamic;
|
4618 | el.slotScope = slotBinding.value || emptySlotScopeToken;
|
4619 | }
|
4620 | }
|
4621 | else {
|
4622 |
|
4623 | const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
|
4624 | if (slotBinding) {
|
4625 | if (process.env.NODE_ENV !== 'production') {
|
4626 | if (!maybeComponent(el)) {
|
4627 | warn$1(`v-slot can only be used on components or <template>.`, slotBinding);
|
4628 | }
|
4629 | if (el.slotScope || el.slotTarget) {
|
4630 | warn$1(`Unexpected mixed usage of different slot syntaxes.`, el);
|
4631 | }
|
4632 | if (el.scopedSlots) {
|
4633 | warn$1(`To avoid scope ambiguity, the default slot should also use ` +
|
4634 | `<template> syntax when there are other named slots.`, slotBinding);
|
4635 | }
|
4636 | }
|
4637 |
|
4638 | const slots = el.scopedSlots || (el.scopedSlots = {});
|
4639 | const { name, dynamic } = getSlotName(slotBinding);
|
4640 | const slotContainer = (slots[name] = createASTElement('template', [], el));
|
4641 | slotContainer.slotTarget = name;
|
4642 | slotContainer.slotTargetDynamic = dynamic;
|
4643 | slotContainer.children = el.children.filter((c) => {
|
4644 | if (!c.slotScope) {
|
4645 | c.parent = slotContainer;
|
4646 | return true;
|
4647 | }
|
4648 | });
|
4649 | slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
|
4650 |
|
4651 | el.children = [];
|
4652 |
|
4653 | el.plain = false;
|
4654 | }
|
4655 | }
|
4656 | }
|
4657 | }
|
4658 | function getSlotName(binding) {
|
4659 | let name = binding.name.replace(slotRE, '');
|
4660 | if (!name) {
|
4661 | if (binding.name[0] !== '#') {
|
4662 | name = 'default';
|
4663 | }
|
4664 | else if (process.env.NODE_ENV !== 'production') {
|
4665 | warn$1(`v-slot shorthand syntax requires a slot name.`, binding);
|
4666 | }
|
4667 | }
|
4668 | return dynamicArgRE.test(name)
|
4669 | ?
|
4670 | { name: name.slice(1, -1), dynamic: true }
|
4671 | :
|
4672 | { name: `"${name}"`, dynamic: false };
|
4673 | }
|
4674 |
|
4675 | function processSlotOutlet(el) {
|
4676 | if (el.tag === 'slot') {
|
4677 | el.slotName = getBindingAttr(el, 'name');
|
4678 | if (process.env.NODE_ENV !== 'production' && el.key) {
|
4679 | warn$1(`\`key\` does not work on <slot> because slots are abstract outlets ` +
|
4680 | `and can possibly expand into multiple elements. ` +
|
4681 | `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
|
4682 | }
|
4683 | }
|
4684 | }
|
4685 | function processComponent(el) {
|
4686 | let binding;
|
4687 | if ((binding = getBindingAttr(el, 'is'))) {
|
4688 | el.component = binding;
|
4689 | }
|
4690 | if (getAndRemoveAttr(el, 'inline-template') != null) {
|
4691 | el.inlineTemplate = true;
|
4692 | }
|
4693 | }
|
4694 | function processAttrs(el) {
|
4695 | const list = el.attrsList;
|
4696 | let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
|
4697 | for (i = 0, l = list.length; i < l; i++) {
|
4698 | name = rawName = list[i].name;
|
4699 | value = list[i].value;
|
4700 | if (dirRE.test(name)) {
|
4701 |
|
4702 | el.hasBindings = true;
|
4703 |
|
4704 | modifiers = parseModifiers(name.replace(dirRE, ''));
|
4705 |
|
4706 | if (modifiers) {
|
4707 | name = name.replace(modifierRE, '');
|
4708 | }
|
4709 | if (bindRE.test(name)) {
|
4710 |
|
4711 | name = name.replace(bindRE, '');
|
4712 | value = parseFilters(value);
|
4713 | isDynamic = dynamicArgRE.test(name);
|
4714 | if (isDynamic) {
|
4715 | name = name.slice(1, -1);
|
4716 | }
|
4717 | if (process.env.NODE_ENV !== 'production' && value.trim().length === 0) {
|
4718 | warn$1(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
|
4719 | }
|
4720 | if (modifiers) {
|
4721 | if (modifiers.prop && !isDynamic) {
|
4722 | name = camelize(name);
|
4723 | if (name === 'innerHtml')
|
4724 | name = 'innerHTML';
|
4725 | }
|
4726 | if (modifiers.camel && !isDynamic) {
|
4727 | name = camelize(name);
|
4728 | }
|
4729 | if (modifiers.sync) {
|
4730 | syncGen = genAssignmentCode(value, `$event`);
|
4731 | if (!isDynamic) {
|
4732 | addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn$1, list[i]);
|
4733 | if (hyphenate(name) !== camelize(name)) {
|
4734 | addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn$1, list[i]);
|
4735 | }
|
4736 | }
|
4737 | else {
|
4738 |
|
4739 | addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn$1, list[i], true
|
4740 | );
|
4741 | }
|
4742 | }
|
4743 | }
|
4744 | if ((modifiers && modifiers.prop) ||
|
4745 | (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
|
4746 | addProp(el, name, value, list[i], isDynamic);
|
4747 | }
|
4748 | else {
|
4749 | addAttr(el, name, value, list[i], isDynamic);
|
4750 | }
|
4751 | }
|
4752 | else if (onRE.test(name)) {
|
4753 |
|
4754 | name = name.replace(onRE, '');
|
4755 | isDynamic = dynamicArgRE.test(name);
|
4756 | if (isDynamic) {
|
4757 | name = name.slice(1, -1);
|
4758 | }
|
4759 | addHandler(el, name, value, modifiers, false, warn$1, list[i], isDynamic);
|
4760 | }
|
4761 | else {
|
4762 |
|
4763 | name = name.replace(dirRE, '');
|
4764 |
|
4765 | const argMatch = name.match(argRE);
|
4766 | let arg = argMatch && argMatch[1];
|
4767 | isDynamic = false;
|
4768 | if (arg) {
|
4769 | name = name.slice(0, -(arg.length + 1));
|
4770 | if (dynamicArgRE.test(arg)) {
|
4771 | arg = arg.slice(1, -1);
|
4772 | isDynamic = true;
|
4773 | }
|
4774 | }
|
4775 | addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
|
4776 | if (process.env.NODE_ENV !== 'production' && name === 'model') {
|
4777 | checkForAliasModel(el, value);
|
4778 | }
|
4779 | }
|
4780 | }
|
4781 | else {
|
4782 |
|
4783 | if (process.env.NODE_ENV !== 'production') {
|
4784 | const res = parseText(value, delimiters);
|
4785 | if (res) {
|
4786 | warn$1(`${name}="${value}": ` +
|
4787 | 'Interpolation inside attributes has been removed. ' +
|
4788 | 'Use v-bind or the colon shorthand instead. For example, ' +
|
4789 | 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
|
4790 | }
|
4791 | }
|
4792 | addAttr(el, name, JSON.stringify(value), list[i]);
|
4793 |
|
4794 |
|
4795 | if (!el.component &&
|
4796 | name === 'muted' &&
|
4797 | platformMustUseProp(el.tag, el.attrsMap.type, name)) {
|
4798 | addProp(el, name, 'true', list[i]);
|
4799 | }
|
4800 | }
|
4801 | }
|
4802 | }
|
4803 | function checkInFor(el) {
|
4804 | let parent = el;
|
4805 | while (parent) {
|
4806 | if (parent.for !== undefined) {
|
4807 | return true;
|
4808 | }
|
4809 | parent = parent.parent;
|
4810 | }
|
4811 | return false;
|
4812 | }
|
4813 | function parseModifiers(name) {
|
4814 | const match = name.match(modifierRE);
|
4815 | if (match) {
|
4816 | const ret = {};
|
4817 | match.forEach(m => {
|
4818 | ret[m.slice(1)] = true;
|
4819 | });
|
4820 | return ret;
|
4821 | }
|
4822 | }
|
4823 | function makeAttrsMap(attrs) {
|
4824 | const map = {};
|
4825 | for (let i = 0, l = attrs.length; i < l; i++) {
|
4826 | if (process.env.NODE_ENV !== 'production' && map[attrs[i].name] && !isIE && !isEdge) {
|
4827 | warn$1('duplicate attribute: ' + attrs[i].name, attrs[i]);
|
4828 | }
|
4829 | map[attrs[i].name] = attrs[i].value;
|
4830 | }
|
4831 | return map;
|
4832 | }
|
4833 |
|
4834 | function isTextTag(el) {
|
4835 | return el.tag === 'script' || el.tag === 'style';
|
4836 | }
|
4837 | function isForbiddenTag(el) {
|
4838 | return (el.tag === 'style' ||
|
4839 | (el.tag === 'script' &&
|
4840 | (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
|
4841 | }
|
4842 | const ieNSBug = /^xmlns:NS\d+/;
|
4843 | const ieNSPrefix = /^NS\d+:/;
|
4844 |
|
4845 | function guardIESVGBug(attrs) {
|
4846 | const res = [];
|
4847 | for (let i = 0; i < attrs.length; i++) {
|
4848 | const attr = attrs[i];
|
4849 | if (!ieNSBug.test(attr.name)) {
|
4850 | attr.name = attr.name.replace(ieNSPrefix, '');
|
4851 | res.push(attr);
|
4852 | }
|
4853 | }
|
4854 | return res;
|
4855 | }
|
4856 | function checkForAliasModel(el, value) {
|
4857 | let _el = el;
|
4858 | while (_el) {
|
4859 | if (_el.for && _el.alias === value) {
|
4860 | warn$1(`<${el.tag} v-model="${value}">: ` +
|
4861 | `You are binding v-model directly to a v-for iteration alias. ` +
|
4862 | `This will not be able to modify the v-for source array because ` +
|
4863 | `writing to the alias is like modifying a function local variable. ` +
|
4864 | `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
|
4865 | }
|
4866 | _el = _el.parent;
|
4867 | }
|
4868 | }
|
4869 |
|
4870 |
|
4871 |
|
4872 |
|
4873 |
|
4874 |
|
4875 |
|
4876 |
|
4877 |
|
4878 |
|
4879 | function preTransformNode(el, options) {
|
4880 | if (el.tag === 'input') {
|
4881 | const map = el.attrsMap;
|
4882 | if (!map['v-model']) {
|
4883 | return;
|
4884 | }
|
4885 | let typeBinding;
|
4886 | if (map[':type'] || map['v-bind:type']) {
|
4887 | typeBinding = getBindingAttr(el, 'type');
|
4888 | }
|
4889 | if (!map.type && !typeBinding && map['v-bind']) {
|
4890 | typeBinding = `(${map['v-bind']}).type`;
|
4891 | }
|
4892 | if (typeBinding) {
|
4893 | const ifCondition = getAndRemoveAttr(el, 'v-if', true);
|
4894 | const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
|
4895 | const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
|
4896 | const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
|
4897 |
|
4898 | const branch0 = cloneASTElement(el);
|
4899 |
|
4900 | processFor(branch0);
|
4901 | addRawAttr(branch0, 'type', 'checkbox');
|
4902 | processElement(branch0, options);
|
4903 | branch0.processed = true;
|
4904 | branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
|
4905 | addIfCondition(branch0, {
|
4906 | exp: branch0.if,
|
4907 | block: branch0
|
4908 | });
|
4909 |
|
4910 | const branch1 = cloneASTElement(el);
|
4911 | getAndRemoveAttr(branch1, 'v-for', true);
|
4912 | addRawAttr(branch1, 'type', 'radio');
|
4913 | processElement(branch1, options);
|
4914 | addIfCondition(branch0, {
|
4915 | exp: `(${typeBinding})==='radio'` + ifConditionExtra,
|
4916 | block: branch1
|
4917 | });
|
4918 |
|
4919 | const branch2 = cloneASTElement(el);
|
4920 | getAndRemoveAttr(branch2, 'v-for', true);
|
4921 | addRawAttr(branch2, ':type', typeBinding);
|
4922 | processElement(branch2, options);
|
4923 | addIfCondition(branch0, {
|
4924 | exp: ifCondition,
|
4925 | block: branch2
|
4926 | });
|
4927 | if (hasElse) {
|
4928 | branch0.else = true;
|
4929 | }
|
4930 | else if (elseIfCondition) {
|
4931 | branch0.elseif = elseIfCondition;
|
4932 | }
|
4933 | return branch0;
|
4934 | }
|
4935 | }
|
4936 | }
|
4937 | function cloneASTElement(el) {
|
4938 | return createASTElement(el.tag, el.attrsList.slice(), el.parent);
|
4939 | }
|
4940 | var model$1 = {
|
4941 | preTransformNode
|
4942 | };
|
4943 |
|
4944 | var modules = [klass, style, model$1];
|
4945 |
|
4946 | let warn;
|
4947 |
|
4948 |
|
4949 | const RANGE_TOKEN = '__r';
|
4950 | function model(el, dir, _warn) {
|
4951 | warn = _warn;
|
4952 | const value = dir.value;
|
4953 | const modifiers = dir.modifiers;
|
4954 | const tag = el.tag;
|
4955 | const type = el.attrsMap.type;
|
4956 | if (process.env.NODE_ENV !== 'production') {
|
4957 |
|
4958 |
|
4959 | if (tag === 'input' && type === 'file') {
|
4960 | warn(`<${el.tag} v-model="${value}" type="file">:\n` +
|
4961 | `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
|
4962 | }
|
4963 | }
|
4964 | if (el.component) {
|
4965 | genComponentModel(el, value, modifiers);
|
4966 |
|
4967 | return false;
|
4968 | }
|
4969 | else if (tag === 'select') {
|
4970 | genSelect(el, value, modifiers);
|
4971 | }
|
4972 | else if (tag === 'input' && type === 'checkbox') {
|
4973 | genCheckboxModel(el, value, modifiers);
|
4974 | }
|
4975 | else if (tag === 'input' && type === 'radio') {
|
4976 | genRadioModel(el, value, modifiers);
|
4977 | }
|
4978 | else if (tag === 'input' || tag === 'textarea') {
|
4979 | genDefaultModel(el, value, modifiers);
|
4980 | }
|
4981 | else {
|
4982 | genComponentModel(el, value, modifiers);
|
4983 |
|
4984 | return false;
|
4985 | }
|
4986 |
|
4987 | return true;
|
4988 | }
|
4989 | function genCheckboxModel(el, value, modifiers) {
|
4990 | const number = modifiers && modifiers.number;
|
4991 | const valueBinding = getBindingAttr(el, 'value') || 'null';
|
4992 | const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
|
4993 | const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
|
4994 | addProp(el, 'checked', `Array.isArray(${value})` +
|
4995 | `?_i(${value},${valueBinding})>-1` +
|
4996 | (trueValueBinding === 'true'
|
4997 | ? `:(${value})`
|
4998 | : `:_q(${value},${trueValueBinding})`));
|
4999 | addHandler(el, 'change', `var $$a=${value},` +
|
5000 | '$$el=$event.target,' +
|
5001 | `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
|
5002 | 'if(Array.isArray($$a)){' +
|
5003 | `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
|
5004 | '$$i=_i($$a,$$v);' +
|
5005 | `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
|
5006 | `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
|
5007 | `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
|
5008 | }
|
5009 | function genRadioModel(el, value, modifiers) {
|
5010 | const number = modifiers && modifiers.number;
|
5011 | let valueBinding = getBindingAttr(el, 'value') || 'null';
|
5012 | valueBinding = number ? `_n(${valueBinding})` : valueBinding;
|
5013 | addProp(el, 'checked', `_q(${value},${valueBinding})`);
|
5014 | addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
|
5015 | }
|
5016 | function genSelect(el, value, modifiers) {
|
5017 | const number = modifiers && modifiers.number;
|
5018 | const selectedVal = `Array.prototype.filter` +
|
5019 | `.call($event.target.options,function(o){return o.selected})` +
|
5020 | `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
|
5021 | `return ${number ? '_n(val)' : 'val'}})`;
|
5022 | const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
|
5023 | let code = `var $$selectedVal = ${selectedVal};`;
|
5024 | code = `${code} ${genAssignmentCode(value, assignment)}`;
|
5025 | addHandler(el, 'change', code, null, true);
|
5026 | }
|
5027 | function genDefaultModel(el, value, modifiers) {
|
5028 | const type = el.attrsMap.type;
|
5029 |
|
5030 |
|
5031 | if (process.env.NODE_ENV !== 'production') {
|
5032 | const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
|
5033 | const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
|
5034 | if (value && !typeBinding) {
|
5035 | const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
|
5036 | warn(`${binding}="${value}" conflicts with v-model on the same element ` +
|
5037 | 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
|
5038 | }
|
5039 | }
|
5040 | const { lazy, number, trim } = modifiers || {};
|
5041 | const needCompositionGuard = !lazy && type !== 'range';
|
5042 | const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
|
5043 | let valueExpression = '$event.target.value';
|
5044 | if (trim) {
|
5045 | valueExpression = `$event.target.value.trim()`;
|
5046 | }
|
5047 | if (number) {
|
5048 | valueExpression = `_n(${valueExpression})`;
|
5049 | }
|
5050 | let code = genAssignmentCode(value, valueExpression);
|
5051 | if (needCompositionGuard) {
|
5052 | code = `if($event.target.composing)return;${code}`;
|
5053 | }
|
5054 | addProp(el, 'value', `(${value})`);
|
5055 | addHandler(el, event, code, null, true);
|
5056 | if (trim || number) {
|
5057 | addHandler(el, 'blur', '$forceUpdate()');
|
5058 | }
|
5059 | }
|
5060 |
|
5061 | function text(el, dir) {
|
5062 | if (dir.value) {
|
5063 | addProp(el, 'textContent', `_s(${dir.value})`, dir);
|
5064 | }
|
5065 | }
|
5066 |
|
5067 | function html(el, dir) {
|
5068 | if (dir.value) {
|
5069 | addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
|
5070 | }
|
5071 | }
|
5072 |
|
5073 | var directives = {
|
5074 | model,
|
5075 | text,
|
5076 | html
|
5077 | };
|
5078 |
|
5079 | const baseOptions = {
|
5080 | expectHTML: true,
|
5081 | modules,
|
5082 | directives,
|
5083 | isPreTag,
|
5084 | isUnaryTag,
|
5085 | mustUseProp,
|
5086 | canBeLeftOpenTag,
|
5087 | isReservedTag,
|
5088 | getTagNamespace,
|
5089 | staticKeys: genStaticKeys$1(modules)
|
5090 | };
|
5091 |
|
5092 | let isStaticKey;
|
5093 | let isPlatformReservedTag$1;
|
5094 | const genStaticKeysCached = cached(genStaticKeys);
|
5095 |
|
5096 |
|
5097 |
|
5098 |
|
5099 |
|
5100 |
|
5101 |
|
5102 |
|
5103 |
|
5104 |
|
5105 |
|
5106 | function optimize$1(root, options) {
|
5107 | if (!root)
|
5108 | return;
|
5109 | isStaticKey = genStaticKeysCached(options.staticKeys || '');
|
5110 | isPlatformReservedTag$1 = options.isReservedTag || no;
|
5111 |
|
5112 | markStatic(root);
|
5113 |
|
5114 | markStaticRoots(root, false);
|
5115 | }
|
5116 | function genStaticKeys(keys) {
|
5117 | return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
|
5118 | (keys ? ',' + keys : ''));
|
5119 | }
|
5120 | function markStatic(node) {
|
5121 | node.static = isStatic(node);
|
5122 | if (node.type === 1) {
|
5123 |
|
5124 |
|
5125 |
|
5126 | if (!isPlatformReservedTag$1(node.tag) &&
|
5127 | node.tag !== 'slot' &&
|
5128 | node.attrsMap['inline-template'] == null) {
|
5129 | return;
|
5130 | }
|
5131 | for (let i = 0, l = node.children.length; i < l; i++) {
|
5132 | const child = node.children[i];
|
5133 | markStatic(child);
|
5134 | if (!child.static) {
|
5135 | node.static = false;
|
5136 | }
|
5137 | }
|
5138 | if (node.ifConditions) {
|
5139 | for (let i = 1, l = node.ifConditions.length; i < l; i++) {
|
5140 | const block = node.ifConditions[i].block;
|
5141 | markStatic(block);
|
5142 | if (!block.static) {
|
5143 | node.static = false;
|
5144 | }
|
5145 | }
|
5146 | }
|
5147 | }
|
5148 | }
|
5149 | function markStaticRoots(node, isInFor) {
|
5150 | if (node.type === 1) {
|
5151 | if (node.static || node.once) {
|
5152 | node.staticInFor = isInFor;
|
5153 | }
|
5154 |
|
5155 |
|
5156 |
|
5157 | if (node.static &&
|
5158 | node.children.length &&
|
5159 | !(node.children.length === 1 && node.children[0].type === 3)) {
|
5160 | node.staticRoot = true;
|
5161 | return;
|
5162 | }
|
5163 | else {
|
5164 | node.staticRoot = false;
|
5165 | }
|
5166 | if (node.children) {
|
5167 | for (let i = 0, l = node.children.length; i < l; i++) {
|
5168 | markStaticRoots(node.children[i], isInFor || !!node.for);
|
5169 | }
|
5170 | }
|
5171 | if (node.ifConditions) {
|
5172 | for (let i = 1, l = node.ifConditions.length; i < l; i++) {
|
5173 | markStaticRoots(node.ifConditions[i].block, isInFor);
|
5174 | }
|
5175 | }
|
5176 | }
|
5177 | }
|
5178 | function isStatic(node) {
|
5179 | if (node.type === 2) {
|
5180 |
|
5181 | return false;
|
5182 | }
|
5183 | if (node.type === 3) {
|
5184 |
|
5185 | return true;
|
5186 | }
|
5187 | return !!(node.pre ||
|
5188 | (!node.hasBindings &&
|
5189 | !node.if &&
|
5190 | !node.for &&
|
5191 | !isBuiltInTag(node.tag) &&
|
5192 | isPlatformReservedTag$1(node.tag) &&
|
5193 | !isDirectChildOfTemplateFor(node) &&
|
5194 | Object.keys(node).every(isStaticKey)));
|
5195 | }
|
5196 | function isDirectChildOfTemplateFor(node) {
|
5197 | while (node.parent) {
|
5198 | node = node.parent;
|
5199 | if (node.tag !== 'template') {
|
5200 | return false;
|
5201 | }
|
5202 | if (node.for) {
|
5203 | return true;
|
5204 | }
|
5205 | }
|
5206 | return false;
|
5207 | }
|
5208 |
|
5209 | const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
|
5210 | const fnInvokeRE = /\([^)]*?\);*$/;
|
5211 | const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
5212 |
|
5213 | const keyCodes = {
|
5214 | esc: 27,
|
5215 | tab: 9,
|
5216 | enter: 13,
|
5217 | space: 32,
|
5218 | up: 38,
|
5219 | left: 37,
|
5220 | right: 39,
|
5221 | down: 40,
|
5222 | delete: [8, 46]
|
5223 | };
|
5224 |
|
5225 | const keyNames = {
|
5226 |
|
5227 | esc: ['Esc', 'Escape'],
|
5228 | tab: 'Tab',
|
5229 | enter: 'Enter',
|
5230 |
|
5231 | space: [' ', 'Spacebar'],
|
5232 |
|
5233 | up: ['Up', 'ArrowUp'],
|
5234 | left: ['Left', 'ArrowLeft'],
|
5235 | right: ['Right', 'ArrowRight'],
|
5236 | down: ['Down', 'ArrowDown'],
|
5237 |
|
5238 | delete: ['Backspace', 'Delete', 'Del']
|
5239 | };
|
5240 |
|
5241 |
|
5242 |
|
5243 | const genGuard = condition => `if(${condition})return null;`;
|
5244 | const modifierCode = {
|
5245 | stop: '$event.stopPropagation();',
|
5246 | prevent: '$event.preventDefault();',
|
5247 | self: genGuard(`$event.target !== $event.currentTarget`),
|
5248 | ctrl: genGuard(`!$event.ctrlKey`),
|
5249 | shift: genGuard(`!$event.shiftKey`),
|
5250 | alt: genGuard(`!$event.altKey`),
|
5251 | meta: genGuard(`!$event.metaKey`),
|
5252 | left: genGuard(`'button' in $event && $event.button !== 0`),
|
5253 | middle: genGuard(`'button' in $event && $event.button !== 1`),
|
5254 | right: genGuard(`'button' in $event && $event.button !== 2`)
|
5255 | };
|
5256 | function genHandlers(events, isNative) {
|
5257 | const prefix = isNative ? 'nativeOn:' : 'on:';
|
5258 | let staticHandlers = ``;
|
5259 | let dynamicHandlers = ``;
|
5260 | for (const name in events) {
|
5261 | const handlerCode = genHandler(events[name]);
|
5262 |
|
5263 | if (events[name] && events[name].dynamic) {
|
5264 | dynamicHandlers += `${name},${handlerCode},`;
|
5265 | }
|
5266 | else {
|
5267 | staticHandlers += `"${name}":${handlerCode},`;
|
5268 | }
|
5269 | }
|
5270 | staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
|
5271 | if (dynamicHandlers) {
|
5272 | return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
|
5273 | }
|
5274 | else {
|
5275 | return prefix + staticHandlers;
|
5276 | }
|
5277 | }
|
5278 | function genHandler(handler) {
|
5279 | if (!handler) {
|
5280 | return 'function(){}';
|
5281 | }
|
5282 | if (Array.isArray(handler)) {
|
5283 | return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
|
5284 | }
|
5285 | const isMethodPath = simplePathRE.test(handler.value);
|
5286 | const isFunctionExpression = fnExpRE.test(handler.value);
|
5287 | const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
|
5288 | if (!handler.modifiers) {
|
5289 | if (isMethodPath || isFunctionExpression) {
|
5290 | return handler.value;
|
5291 | }
|
5292 | return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`;
|
5293 | }
|
5294 | else {
|
5295 | let code = '';
|
5296 | let genModifierCode = '';
|
5297 | const keys = [];
|
5298 | for (const key in handler.modifiers) {
|
5299 | if (modifierCode[key]) {
|
5300 | genModifierCode += modifierCode[key];
|
5301 |
|
5302 | if (keyCodes[key]) {
|
5303 | keys.push(key);
|
5304 | }
|
5305 | }
|
5306 | else if (key === 'exact') {
|
5307 | const modifiers = handler.modifiers;
|
5308 | genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
|
5309 | .filter(keyModifier => !modifiers[keyModifier])
|
5310 | .map(keyModifier => `$event.${keyModifier}Key`)
|
5311 | .join('||'));
|
5312 | }
|
5313 | else {
|
5314 | keys.push(key);
|
5315 | }
|
5316 | }
|
5317 | if (keys.length) {
|
5318 | code += genKeyFilter(keys);
|
5319 | }
|
5320 |
|
5321 | if (genModifierCode) {
|
5322 | code += genModifierCode;
|
5323 | }
|
5324 | const handlerCode = isMethodPath
|
5325 | ? `return ${handler.value}.apply(null, arguments)`
|
5326 | : isFunctionExpression
|
5327 | ? `return (${handler.value}).apply(null, arguments)`
|
5328 | : isFunctionInvocation
|
5329 | ? `return ${handler.value}`
|
5330 | : handler.value;
|
5331 | return `function($event){${code}${handlerCode}}`;
|
5332 | }
|
5333 | }
|
5334 | function genKeyFilter(keys) {
|
5335 | return (
|
5336 |
|
5337 |
|
5338 |
|
5339 | `if(!$event.type.indexOf('key')&&` +
|
5340 | `${keys.map(genFilterCode).join('&&')})return null;`);
|
5341 | }
|
5342 | function genFilterCode(key) {
|
5343 | const keyVal = parseInt(key, 10);
|
5344 | if (keyVal) {
|
5345 | return `$event.keyCode!==${keyVal}`;
|
5346 | }
|
5347 | const keyCode = keyCodes[key];
|
5348 | const keyName = keyNames[key];
|
5349 | return (`_k($event.keyCode,` +
|
5350 | `${JSON.stringify(key)},` +
|
5351 | `${JSON.stringify(keyCode)},` +
|
5352 | `$event.key,` +
|
5353 | `${JSON.stringify(keyName)}` +
|
5354 | `)`);
|
5355 | }
|
5356 |
|
5357 | function on(el, dir) {
|
5358 | if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
|
5359 | warn$2(`v-on without argument does not support modifiers.`);
|
5360 | }
|
5361 | el.wrapListeners = (code) => `_g(${code},${dir.value})`;
|
5362 | }
|
5363 |
|
5364 | function bind(el, dir) {
|
5365 | el.wrapData = (code) => {
|
5366 | return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
|
5367 | };
|
5368 | }
|
5369 |
|
5370 | var baseDirectives = {
|
5371 | on,
|
5372 | bind,
|
5373 | cloak: noop
|
5374 | };
|
5375 |
|
5376 | class CodegenState {
|
5377 | constructor(options) {
|
5378 | this.options = options;
|
5379 | this.warn = options.warn || baseWarn;
|
5380 | this.transforms = pluckModuleFunction(options.modules, 'transformCode');
|
5381 | this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
|
5382 | this.directives = extend(extend({}, baseDirectives), options.directives);
|
5383 | const isReservedTag = options.isReservedTag || no;
|
5384 | this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
|
5385 | this.onceId = 0;
|
5386 | this.staticRenderFns = [];
|
5387 | this.pre = false;
|
5388 | }
|
5389 | }
|
5390 | function generate$1(ast, options) {
|
5391 | const state = new CodegenState(options);
|
5392 |
|
5393 | const code = ast
|
5394 | ? ast.tag === 'script'
|
5395 | ? 'null'
|
5396 | : genElement(ast, state)
|
5397 | : '_c("div")';
|
5398 | return {
|
5399 | render: `with(this){return ${code}}`,
|
5400 | staticRenderFns: state.staticRenderFns
|
5401 | };
|
5402 | }
|
5403 | function genElement(el, state) {
|
5404 | if (el.parent) {
|
5405 | el.pre = el.pre || el.parent.pre;
|
5406 | }
|
5407 | if (el.staticRoot && !el.staticProcessed) {
|
5408 | return genStatic(el, state);
|
5409 | }
|
5410 | else if (el.once && !el.onceProcessed) {
|
5411 | return genOnce(el, state);
|
5412 | }
|
5413 | else if (el.for && !el.forProcessed) {
|
5414 | return genFor(el, state);
|
5415 | }
|
5416 | else if (el.if && !el.ifProcessed) {
|
5417 | return genIf(el, state);
|
5418 | }
|
5419 | else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
|
5420 | return genChildren(el, state) || 'void 0';
|
5421 | }
|
5422 | else if (el.tag === 'slot') {
|
5423 | return genSlot(el, state);
|
5424 | }
|
5425 | else {
|
5426 |
|
5427 | let code;
|
5428 | if (el.component) {
|
5429 | code = genComponent(el.component, el, state);
|
5430 | }
|
5431 | else {
|
5432 | let data;
|
5433 | const maybeComponent = state.maybeComponent(el);
|
5434 | if (!el.plain || (el.pre && maybeComponent)) {
|
5435 | data = genData(el, state);
|
5436 | }
|
5437 | let tag;
|
5438 |
|
5439 | const bindings = state.options.bindings;
|
5440 | if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
|
5441 | tag = checkBindingType(bindings, el.tag);
|
5442 | }
|
5443 | if (!tag)
|
5444 | tag = `'${el.tag}'`;
|
5445 | const children = el.inlineTemplate ? null : genChildren(el, state, true);
|
5446 | code = `_c(${tag}${data ? `,${data}` : '' // data
|
5447 | }${children ? `,${children}` : '' // children
|
5448 | })`;
|
5449 | }
|
5450 |
|
5451 | for (let i = 0; i < state.transforms.length; i++) {
|
5452 | code = state.transforms[i](el, code);
|
5453 | }
|
5454 | return code;
|
5455 | }
|
5456 | }
|
5457 | function checkBindingType(bindings, key) {
|
5458 | const camelName = camelize(key);
|
5459 | const PascalName = capitalize(camelName);
|
5460 | const checkType = (type) => {
|
5461 | if (bindings[key] === type) {
|
5462 | return key;
|
5463 | }
|
5464 | if (bindings[camelName] === type) {
|
5465 | return camelName;
|
5466 | }
|
5467 | if (bindings[PascalName] === type) {
|
5468 | return PascalName;
|
5469 | }
|
5470 | };
|
5471 | const fromConst = checkType("setup-const" ) ||
|
5472 | checkType("setup-reactive-const" );
|
5473 | if (fromConst) {
|
5474 | return fromConst;
|
5475 | }
|
5476 | const fromMaybeRef = checkType("setup-let" ) ||
|
5477 | checkType("setup-ref" ) ||
|
5478 | checkType("setup-maybe-ref" );
|
5479 | if (fromMaybeRef) {
|
5480 | return fromMaybeRef;
|
5481 | }
|
5482 | }
|
5483 |
|
5484 | function genStatic(el, state) {
|
5485 | el.staticProcessed = true;
|
5486 |
|
5487 |
|
5488 |
|
5489 | const originalPreState = state.pre;
|
5490 | if (el.pre) {
|
5491 | state.pre = el.pre;
|
5492 | }
|
5493 | state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
|
5494 | state.pre = originalPreState;
|
5495 | return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
|
5496 | }
|
5497 |
|
5498 | function genOnce(el, state) {
|
5499 | el.onceProcessed = true;
|
5500 | if (el.if && !el.ifProcessed) {
|
5501 | return genIf(el, state);
|
5502 | }
|
5503 | else if (el.staticInFor) {
|
5504 | let key = '';
|
5505 | let parent = el.parent;
|
5506 | while (parent) {
|
5507 | if (parent.for) {
|
5508 | key = parent.key;
|
5509 | break;
|
5510 | }
|
5511 | parent = parent.parent;
|
5512 | }
|
5513 | if (!key) {
|
5514 | process.env.NODE_ENV !== 'production' &&
|
5515 | state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
|
5516 | return genElement(el, state);
|
5517 | }
|
5518 | return `_o(${genElement(el, state)},${state.onceId++},${key})`;
|
5519 | }
|
5520 | else {
|
5521 | return genStatic(el, state);
|
5522 | }
|
5523 | }
|
5524 | function genIf(el, state, altGen, altEmpty) {
|
5525 | el.ifProcessed = true;
|
5526 | return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
|
5527 | }
|
5528 | function genIfConditions(conditions, state, altGen, altEmpty) {
|
5529 | if (!conditions.length) {
|
5530 | return altEmpty || '_e()';
|
5531 | }
|
5532 | const condition = conditions.shift();
|
5533 | if (condition.exp) {
|
5534 | return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
|
5535 | }
|
5536 | else {
|
5537 | return `${genTernaryExp(condition.block)}`;
|
5538 | }
|
5539 |
|
5540 | function genTernaryExp(el) {
|
5541 | return altGen
|
5542 | ? altGen(el, state)
|
5543 | : el.once
|
5544 | ? genOnce(el, state)
|
5545 | : genElement(el, state);
|
5546 | }
|
5547 | }
|
5548 | function genFor(el, state, altGen, altHelper) {
|
5549 | const exp = el.for;
|
5550 | const alias = el.alias;
|
5551 | const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
|
5552 | const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
|
5553 | if (process.env.NODE_ENV !== 'production' &&
|
5554 | state.maybeComponent(el) &&
|
5555 | el.tag !== 'slot' &&
|
5556 | el.tag !== 'template' &&
|
5557 | !el.key) {
|
5558 | state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
|
5559 | `v-for should have explicit keys. ` +
|
5560 | `See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true );
|
5561 | }
|
5562 | el.forProcessed = true;
|
5563 | return (`${altHelper || '_l'}((${exp}),` +
|
5564 | `function(${alias}${iterator1}${iterator2}){` +
|
5565 | `return ${(altGen || genElement)(el, state)}` +
|
5566 | '})');
|
5567 | }
|
5568 | function genData(el, state) {
|
5569 | let data = '{';
|
5570 |
|
5571 |
|
5572 | const dirs = genDirectives(el, state);
|
5573 | if (dirs)
|
5574 | data += dirs + ',';
|
5575 |
|
5576 | if (el.key) {
|
5577 | data += `key:${el.key},`;
|
5578 | }
|
5579 |
|
5580 | if (el.ref) {
|
5581 | data += `ref:${el.ref},`;
|
5582 | }
|
5583 | if (el.refInFor) {
|
5584 | data += `refInFor:true,`;
|
5585 | }
|
5586 |
|
5587 | if (el.pre) {
|
5588 | data += `pre:true,`;
|
5589 | }
|
5590 |
|
5591 | if (el.component) {
|
5592 | data += `tag:"${el.tag}",`;
|
5593 | }
|
5594 |
|
5595 | for (let i = 0; i < state.dataGenFns.length; i++) {
|
5596 | data += state.dataGenFns[i](el);
|
5597 | }
|
5598 |
|
5599 | if (el.attrs) {
|
5600 | data += `attrs:${genProps(el.attrs)},`;
|
5601 | }
|
5602 |
|
5603 | if (el.props) {
|
5604 | data += `domProps:${genProps(el.props)},`;
|
5605 | }
|
5606 |
|
5607 | if (el.events) {
|
5608 | data += `${genHandlers(el.events, false)},`;
|
5609 | }
|
5610 | if (el.nativeEvents) {
|
5611 | data += `${genHandlers(el.nativeEvents, true)},`;
|
5612 | }
|
5613 |
|
5614 |
|
5615 | if (el.slotTarget && !el.slotScope) {
|
5616 | data += `slot:${el.slotTarget},`;
|
5617 | }
|
5618 |
|
5619 | if (el.scopedSlots) {
|
5620 | data += `${genScopedSlots(el, el.scopedSlots, state)},`;
|
5621 | }
|
5622 |
|
5623 | if (el.model) {
|
5624 | data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
|
5625 | }
|
5626 |
|
5627 | if (el.inlineTemplate) {
|
5628 | const inlineTemplate = genInlineTemplate(el, state);
|
5629 | if (inlineTemplate) {
|
5630 | data += `${inlineTemplate},`;
|
5631 | }
|
5632 | }
|
5633 | data = data.replace(/,$/, '') + '}';
|
5634 |
|
5635 |
|
5636 |
|
5637 | if (el.dynamicAttrs) {
|
5638 | data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
|
5639 | }
|
5640 |
|
5641 | if (el.wrapData) {
|
5642 | data = el.wrapData(data);
|
5643 | }
|
5644 |
|
5645 | if (el.wrapListeners) {
|
5646 | data = el.wrapListeners(data);
|
5647 | }
|
5648 | return data;
|
5649 | }
|
5650 | function genDirectives(el, state) {
|
5651 | const dirs = el.directives;
|
5652 | if (!dirs)
|
5653 | return;
|
5654 | let res = 'directives:[';
|
5655 | let hasRuntime = false;
|
5656 | let i, l, dir, needRuntime;
|
5657 | for (i = 0, l = dirs.length; i < l; i++) {
|
5658 | dir = dirs[i];
|
5659 | needRuntime = true;
|
5660 | const gen = state.directives[dir.name];
|
5661 | if (gen) {
|
5662 |
|
5663 |
|
5664 | needRuntime = !!gen(el, dir, state.warn);
|
5665 | }
|
5666 | if (needRuntime) {
|
5667 | hasRuntime = true;
|
5668 | res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
|
5669 | ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
|
5670 | : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
|
5671 | }
|
5672 | }
|
5673 | if (hasRuntime) {
|
5674 | return res.slice(0, -1) + ']';
|
5675 | }
|
5676 | }
|
5677 | function genInlineTemplate(el, state) {
|
5678 | const ast = el.children[0];
|
5679 | if (process.env.NODE_ENV !== 'production' && (el.children.length !== 1 || ast.type !== 1)) {
|
5680 | state.warn('Inline-template components must have exactly one child element.', { start: el.start });
|
5681 | }
|
5682 | if (ast && ast.type === 1) {
|
5683 | const inlineRenderFns = generate$1(ast, state.options);
|
5684 | return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
|
5685 | .map(code => `function(){${code}}`)
|
5686 | .join(',')}]}`;
|
5687 | }
|
5688 | }
|
5689 | function genScopedSlots(el, slots, state) {
|
5690 |
|
5691 |
|
5692 |
|
5693 |
|
5694 | let needsForceUpdate = el.for ||
|
5695 | Object.keys(slots).some(key => {
|
5696 | const slot = slots[key];
|
5697 | return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot)
|
5698 | );
|
5699 | });
|
5700 |
|
5701 |
|
5702 |
|
5703 |
|
5704 | let needsKey = !!el.if;
|
5705 |
|
5706 |
|
5707 |
|
5708 |
|
5709 |
|
5710 | if (!needsForceUpdate) {
|
5711 | let parent = el.parent;
|
5712 | while (parent) {
|
5713 | if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
|
5714 | parent.for) {
|
5715 | needsForceUpdate = true;
|
5716 | break;
|
5717 | }
|
5718 | if (parent.if) {
|
5719 | needsKey = true;
|
5720 | }
|
5721 | parent = parent.parent;
|
5722 | }
|
5723 | }
|
5724 | const generatedSlots = Object.keys(slots)
|
5725 | .map(key => genScopedSlot(slots[key], state))
|
5726 | .join(',');
|
5727 | return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
|
5728 | }
|
5729 | function hash(str) {
|
5730 | let hash = 5381;
|
5731 | let i = str.length;
|
5732 | while (i) {
|
5733 | hash = (hash * 33) ^ str.charCodeAt(--i);
|
5734 | }
|
5735 | return hash >>> 0;
|
5736 | }
|
5737 | function containsSlotChild(el) {
|
5738 | if (el.type === 1) {
|
5739 | if (el.tag === 'slot') {
|
5740 | return true;
|
5741 | }
|
5742 | return el.children.some(containsSlotChild);
|
5743 | }
|
5744 | return false;
|
5745 | }
|
5746 | function genScopedSlot(el, state) {
|
5747 | const isLegacySyntax = el.attrsMap['slot-scope'];
|
5748 | if (el.if && !el.ifProcessed && !isLegacySyntax) {
|
5749 | return genIf(el, state, genScopedSlot, `null`);
|
5750 | }
|
5751 | if (el.for && !el.forProcessed) {
|
5752 | return genFor(el, state, genScopedSlot);
|
5753 | }
|
5754 | const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
|
5755 | const fn = `function(${slotScope}){` +
|
5756 | `return ${el.tag === 'template'
|
5757 | ? el.if && isLegacySyntax
|
5758 | ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
|
5759 | : genChildren(el, state) || 'undefined'
|
5760 | : genElement(el, state)}}`;
|
5761 |
|
5762 | const reverseProxy = slotScope ? `` : `,proxy:true`;
|
5763 | return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
|
5764 | }
|
5765 | function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
|
5766 | const children = el.children;
|
5767 | if (children.length) {
|
5768 | const el = children[0];
|
5769 |
|
5770 | if (children.length === 1 &&
|
5771 | el.for &&
|
5772 | el.tag !== 'template' &&
|
5773 | el.tag !== 'slot') {
|
5774 | const normalizationType = checkSkip
|
5775 | ? state.maybeComponent(el)
|
5776 | ? `,1`
|
5777 | : `,0`
|
5778 | : ``;
|
5779 | return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
|
5780 | }
|
5781 | const normalizationType = checkSkip
|
5782 | ? getNormalizationType(children, state.maybeComponent)
|
5783 | : 0;
|
5784 | const gen = altGenNode || genNode;
|
5785 | return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
|
5786 | }
|
5787 | }
|
5788 |
|
5789 |
|
5790 |
|
5791 |
|
5792 | function getNormalizationType(children, maybeComponent) {
|
5793 | let res = 0;
|
5794 | for (let i = 0; i < children.length; i++) {
|
5795 | const el = children[i];
|
5796 | if (el.type !== 1) {
|
5797 | continue;
|
5798 | }
|
5799 | if (needsNormalization(el) ||
|
5800 | (el.ifConditions &&
|
5801 | el.ifConditions.some(c => needsNormalization(c.block)))) {
|
5802 | res = 2;
|
5803 | break;
|
5804 | }
|
5805 | if (maybeComponent(el) ||
|
5806 | (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
|
5807 | res = 1;
|
5808 | }
|
5809 | }
|
5810 | return res;
|
5811 | }
|
5812 | function needsNormalization(el) {
|
5813 | return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
|
5814 | }
|
5815 | function genNode(node, state) {
|
5816 | if (node.type === 1) {
|
5817 | return genElement(node, state);
|
5818 | }
|
5819 | else if (node.type === 3 && node.isComment) {
|
5820 | return genComment(node);
|
5821 | }
|
5822 | else {
|
5823 | return genText(node);
|
5824 | }
|
5825 | }
|
5826 | function genText(text) {
|
5827 | return `_v(${text.type === 2
|
5828 | ? text.expression // no need for () because already wrapped in _s()
|
5829 | : transformSpecialNewlines(JSON.stringify(text.text))})`;
|
5830 | }
|
5831 | function genComment(comment) {
|
5832 | return `_e(${JSON.stringify(comment.text)})`;
|
5833 | }
|
5834 | function genSlot(el, state) {
|
5835 | const slotName = el.slotName || '"default"';
|
5836 | const children = genChildren(el, state);
|
5837 | let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
|
5838 | const attrs = el.attrs || el.dynamicAttrs
|
5839 | ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
|
5840 |
|
5841 | name: camelize(attr.name),
|
5842 | value: attr.value,
|
5843 | dynamic: attr.dynamic
|
5844 | })))
|
5845 | : null;
|
5846 | const bind = el.attrsMap['v-bind'];
|
5847 | if ((attrs || bind) && !children) {
|
5848 | res += `,null`;
|
5849 | }
|
5850 | if (attrs) {
|
5851 | res += `,${attrs}`;
|
5852 | }
|
5853 | if (bind) {
|
5854 | res += `${attrs ? '' : ',null'},${bind}`;
|
5855 | }
|
5856 | return res + ')';
|
5857 | }
|
5858 |
|
5859 | function genComponent(componentName, el, state) {
|
5860 | const children = el.inlineTemplate ? null : genChildren(el, state, true);
|
5861 | return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
|
5862 | }
|
5863 | function genProps(props) {
|
5864 | let staticProps = ``;
|
5865 | let dynamicProps = ``;
|
5866 | for (let i = 0; i < props.length; i++) {
|
5867 | const prop = props[i];
|
5868 | const value = transformSpecialNewlines(prop.value);
|
5869 | if (prop.dynamic) {
|
5870 | dynamicProps += `${prop.name},${value},`;
|
5871 | }
|
5872 | else {
|
5873 | staticProps += `"${prop.name}":${value},`;
|
5874 | }
|
5875 | }
|
5876 | staticProps = `{${staticProps.slice(0, -1)}}`;
|
5877 | if (dynamicProps) {
|
5878 | return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
|
5879 | }
|
5880 | else {
|
5881 | return staticProps;
|
5882 | }
|
5883 | }
|
5884 |
|
5885 | function transformSpecialNewlines(text) {
|
5886 | return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
5887 | }
|
5888 |
|
5889 |
|
5890 |
|
5891 | const prohibitedKeywordRE = new RegExp('\\b' +
|
5892 | ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
|
5893 | 'super,throw,while,yield,delete,export,import,return,switch,default,' +
|
5894 | 'extends,finally,continue,debugger,function,arguments')
|
5895 | .split(',')
|
5896 | .join('\\b|\\b') +
|
5897 | '\\b');
|
5898 |
|
5899 | const unaryOperatorsRE = new RegExp('\\b' +
|
5900 | 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
|
5901 | '\\s*\\([^\\)]*\\)');
|
5902 |
|
5903 | const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
5904 |
|
5905 | function detectErrors(ast, warn) {
|
5906 | if (ast) {
|
5907 | checkNode(ast, warn);
|
5908 | }
|
5909 | }
|
5910 | function checkNode(node, warn) {
|
5911 | if (node.type === 1) {
|
5912 | for (const name in node.attrsMap) {
|
5913 | if (dirRE.test(name)) {
|
5914 | const value = node.attrsMap[name];
|
5915 | if (value) {
|
5916 | const range = node.rawAttrsMap[name];
|
5917 | if (name === 'v-for') {
|
5918 | checkFor(node, `v-for="${value}"`, warn, range);
|
5919 | }
|
5920 | else if (name === 'v-slot' || name[0] === '#') {
|
5921 | checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
|
5922 | }
|
5923 | else if (onRE.test(name)) {
|
5924 | checkEvent(value, `${name}="${value}"`, warn, range);
|
5925 | }
|
5926 | else {
|
5927 | checkExpression(value, `${name}="${value}"`, warn, range);
|
5928 | }
|
5929 | }
|
5930 | }
|
5931 | }
|
5932 | if (node.children) {
|
5933 | for (let i = 0; i < node.children.length; i++) {
|
5934 | checkNode(node.children[i], warn);
|
5935 | }
|
5936 | }
|
5937 | }
|
5938 | else if (node.type === 2) {
|
5939 | checkExpression(node.expression, node.text, warn, node);
|
5940 | }
|
5941 | }
|
5942 | function checkEvent(exp, text, warn, range) {
|
5943 | const stripped = exp.replace(stripStringRE, '');
|
5944 | const keywordMatch = stripped.match(unaryOperatorsRE);
|
5945 | if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
|
5946 | warn(`avoid using JavaScript unary operator as property name: ` +
|
5947 | `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
|
5948 | }
|
5949 | checkExpression(exp, text, warn, range);
|
5950 | }
|
5951 | function checkFor(node, text, warn, range) {
|
5952 | checkExpression(node.for || '', text, warn, range);
|
5953 | checkIdentifier(node.alias, 'v-for alias', text, warn, range);
|
5954 | checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
|
5955 | checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
|
5956 | }
|
5957 | function checkIdentifier(ident, type, text, warn, range) {
|
5958 | if (typeof ident === 'string') {
|
5959 | try {
|
5960 | new Function(`var ${ident}=_`);
|
5961 | }
|
5962 | catch (e) {
|
5963 | warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
|
5964 | }
|
5965 | }
|
5966 | }
|
5967 | function checkExpression(exp, text, warn, range) {
|
5968 | try {
|
5969 | new Function(`return ${exp}`);
|
5970 | }
|
5971 | catch (e) {
|
5972 | const keywordMatch = exp
|
5973 | .replace(stripStringRE, '')
|
5974 | .match(prohibitedKeywordRE);
|
5975 | if (keywordMatch) {
|
5976 | warn(`avoid using JavaScript keyword as property name: ` +
|
5977 | `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
|
5978 | }
|
5979 | else {
|
5980 | warn(`invalid expression: ${e.message} in\n\n` +
|
5981 | ` ${exp}\n\n` +
|
5982 | ` Raw expression: ${text.trim()}\n`, range);
|
5983 | }
|
5984 | }
|
5985 | }
|
5986 | function checkFunctionParameterExpression(exp, text, warn, range) {
|
5987 | try {
|
5988 | new Function(exp, '');
|
5989 | }
|
5990 | catch (e) {
|
5991 | warn(`invalid function parameter expression: ${e.message} in\n\n` +
|
5992 | ` ${exp}\n\n` +
|
5993 | ` Raw expression: ${text.trim()}\n`, range);
|
5994 | }
|
5995 | }
|
5996 |
|
5997 | const range = 2;
|
5998 | function generateCodeFrame(source, start = 0, end = source.length) {
|
5999 | const lines = source.split(/\r?\n/);
|
6000 | let count = 0;
|
6001 | const res = [];
|
6002 | for (let i = 0; i < lines.length; i++) {
|
6003 | count += lines[i].length + 1;
|
6004 | if (count >= start) {
|
6005 | for (let j = i - range; j <= i + range || end > count; j++) {
|
6006 | if (j < 0 || j >= lines.length)
|
6007 | continue;
|
6008 | res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
|
6009 | const lineLength = lines[j].length;
|
6010 | if (j === i) {
|
6011 |
|
6012 | const pad = start - (count - lineLength) + 1;
|
6013 | const length = end > count ? lineLength - pad : end - start;
|
6014 | res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
|
6015 | }
|
6016 | else if (j > i) {
|
6017 | if (end > count) {
|
6018 | const length = Math.min(end - count, lineLength);
|
6019 | res.push(` | ` + repeat(`^`, length));
|
6020 | }
|
6021 | count += lineLength + 1;
|
6022 | }
|
6023 | }
|
6024 | break;
|
6025 | }
|
6026 | }
|
6027 | return res.join('\n');
|
6028 | }
|
6029 | function repeat(str, n) {
|
6030 | let result = '';
|
6031 | if (n > 0) {
|
6032 |
|
6033 | while (true) {
|
6034 |
|
6035 | if (n & 1)
|
6036 | result += str;
|
6037 | n >>>= 1;
|
6038 | if (n <= 0)
|
6039 | break;
|
6040 | str += str;
|
6041 | }
|
6042 | }
|
6043 | return result;
|
6044 | }
|
6045 |
|
6046 | function createFunction(code, errors) {
|
6047 | try {
|
6048 | return new Function(code);
|
6049 | }
|
6050 | catch (err) {
|
6051 | errors.push({ err, code });
|
6052 | return noop;
|
6053 | }
|
6054 | }
|
6055 | function createCompileToFunctionFn(compile) {
|
6056 | const cache = Object.create(null);
|
6057 | return function compileToFunctions(template, options, vm) {
|
6058 | options = extend({}, options);
|
6059 | const warn = options.warn || warn$2;
|
6060 | delete options.warn;
|
6061 |
|
6062 | if (process.env.NODE_ENV !== 'production') {
|
6063 |
|
6064 | try {
|
6065 | new Function('return 1');
|
6066 | }
|
6067 | catch (e) {
|
6068 | if (e.toString().match(/unsafe-eval|CSP/)) {
|
6069 | warn('It seems you are using the standalone build of Vue.js in an ' +
|
6070 | 'environment with Content Security Policy that prohibits unsafe-eval. ' +
|
6071 | 'The template compiler cannot work in this environment. Consider ' +
|
6072 | 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
|
6073 | 'templates into render functions.');
|
6074 | }
|
6075 | }
|
6076 | }
|
6077 |
|
6078 | const key = options.delimiters
|
6079 | ? String(options.delimiters) + template
|
6080 | : template;
|
6081 | if (cache[key]) {
|
6082 | return cache[key];
|
6083 | }
|
6084 |
|
6085 | const compiled = compile(template, options);
|
6086 |
|
6087 | if (process.env.NODE_ENV !== 'production') {
|
6088 | if (compiled.errors && compiled.errors.length) {
|
6089 | if (options.outputSourceRange) {
|
6090 | compiled.errors.forEach(e => {
|
6091 | warn(`Error compiling template:\n\n${e.msg}\n\n` +
|
6092 | generateCodeFrame(template, e.start, e.end), vm);
|
6093 | });
|
6094 | }
|
6095 | else {
|
6096 | warn(`Error compiling template:\n\n${template}\n\n` +
|
6097 | compiled.errors.map(e => `- ${e}`).join('\n') +
|
6098 | '\n', vm);
|
6099 | }
|
6100 | }
|
6101 | if (compiled.tips && compiled.tips.length) {
|
6102 | if (options.outputSourceRange) {
|
6103 | compiled.tips.forEach(e => tip(e.msg, vm));
|
6104 | }
|
6105 | else {
|
6106 | compiled.tips.forEach(msg => tip(msg, vm));
|
6107 | }
|
6108 | }
|
6109 | }
|
6110 |
|
6111 | const res = {};
|
6112 | const fnGenErrors = [];
|
6113 | res.render = createFunction(compiled.render, fnGenErrors);
|
6114 | res.staticRenderFns = compiled.staticRenderFns.map(code => {
|
6115 | return createFunction(code, fnGenErrors);
|
6116 | });
|
6117 |
|
6118 |
|
6119 |
|
6120 |
|
6121 | if (process.env.NODE_ENV !== 'production') {
|
6122 | if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
|
6123 | warn(`Failed to generate render function:\n\n` +
|
6124 | fnGenErrors
|
6125 | .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
|
6126 | .join('\n'), vm);
|
6127 | }
|
6128 | }
|
6129 | return (cache[key] = res);
|
6130 | };
|
6131 | }
|
6132 |
|
6133 | function createCompilerCreator(baseCompile) {
|
6134 | return function createCompiler(baseOptions) {
|
6135 | function compile(template, options) {
|
6136 | const finalOptions = Object.create(baseOptions);
|
6137 | const errors = [];
|
6138 | const tips = [];
|
6139 | let warn = (msg, range, tip) => {
|
6140 | (tip ? tips : errors).push(msg);
|
6141 | };
|
6142 | if (options) {
|
6143 | if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
6144 |
|
6145 | const leadingSpaceLength = template.match(/^\s*/)[0].length;
|
6146 | warn = (msg, range, tip) => {
|
6147 | const data = typeof msg === 'string' ? { msg } : msg;
|
6148 | if (range) {
|
6149 | if (range.start != null) {
|
6150 | data.start = range.start + leadingSpaceLength;
|
6151 | }
|
6152 | if (range.end != null) {
|
6153 | data.end = range.end + leadingSpaceLength;
|
6154 | }
|
6155 | }
|
6156 | (tip ? tips : errors).push(data);
|
6157 | };
|
6158 | }
|
6159 |
|
6160 | if (options.modules) {
|
6161 | finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
|
6162 | }
|
6163 |
|
6164 | if (options.directives) {
|
6165 | finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
|
6166 | }
|
6167 |
|
6168 | for (const key in options) {
|
6169 | if (key !== 'modules' && key !== 'directives') {
|
6170 | finalOptions[key] = options[key];
|
6171 | }
|
6172 | }
|
6173 | }
|
6174 | finalOptions.warn = warn;
|
6175 | const compiled = baseCompile(template.trim(), finalOptions);
|
6176 | if (process.env.NODE_ENV !== 'production') {
|
6177 | detectErrors(compiled.ast, warn);
|
6178 | }
|
6179 | compiled.errors = errors;
|
6180 | compiled.tips = tips;
|
6181 | return compiled;
|
6182 | }
|
6183 | return {
|
6184 | compile,
|
6185 | compileToFunctions: createCompileToFunctionFn(compile)
|
6186 | };
|
6187 | };
|
6188 | }
|
6189 |
|
6190 |
|
6191 |
|
6192 |
|
6193 | const createCompiler$1 = createCompilerCreator(function baseCompile(template, options) {
|
6194 | const ast = parse(template.trim(), options);
|
6195 | if (options.optimize !== false) {
|
6196 | optimize$1(ast, options);
|
6197 | }
|
6198 | const code = generate$1(ast, options);
|
6199 | return {
|
6200 | ast,
|
6201 | render: code.render,
|
6202 | staticRenderFns: code.staticRenderFns
|
6203 | };
|
6204 | });
|
6205 |
|
6206 | const { compile: compile$1, compileToFunctions: compileToFunctions$1 } = createCompiler$1(baseOptions);
|
6207 |
|
6208 | const isAttr = makeMap('accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
|
6209 | 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
|
6210 | 'checked,cite,class,code,codebase,color,cols,colspan,content,' +
|
6211 | 'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
|
6212 | 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
|
6213 | 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
|
6214 | 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
|
6215 | 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
|
6216 | 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
|
6217 | 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
|
6218 | 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
|
6219 | 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
|
6220 | 'target,title,usemap,value,width,wrap');
|
6221 |
|
6222 | const isRenderableAttr = (name) => {
|
6223 | return (isAttr(name) || name.indexOf('data-') === 0 || name.indexOf('aria-') === 0);
|
6224 | };
|
6225 | const propsToAttrMap = {
|
6226 | acceptCharset: 'accept-charset',
|
6227 | className: 'class',
|
6228 | htmlFor: 'for',
|
6229 | httpEquiv: 'http-equiv'
|
6230 | };
|
6231 | const ESC = {
|
6232 | '<': '<',
|
6233 | '>': '>',
|
6234 | '"': '"',
|
6235 | '&': '&'
|
6236 | };
|
6237 | function escape(s) {
|
6238 | return s.replace(/[<>"&]/g, escapeChar);
|
6239 | }
|
6240 | function escapeChar(a) {
|
6241 | return ESC[a] || a;
|
6242 | }
|
6243 |
|
6244 | const plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
|
6245 |
|
6246 |
|
6247 | function applyModelTransform(el, state) {
|
6248 | if (el.directives) {
|
6249 | for (let i = 0; i < el.directives.length; i++) {
|
6250 | const dir = el.directives[i];
|
6251 | if (dir.name === 'model') {
|
6252 | state.directives.model(el, dir, state.warn);
|
6253 |
|
6254 | if (el.tag === 'textarea' && el.props) {
|
6255 | el.props = el.props.filter(p => p.name !== 'value');
|
6256 | }
|
6257 | break;
|
6258 | }
|
6259 | }
|
6260 | }
|
6261 | }
|
6262 | function genAttrSegments(attrs) {
|
6263 | return attrs.map(({ name, value }) => genAttrSegment(name, value));
|
6264 | }
|
6265 | function genDOMPropSegments(props, attrs) {
|
6266 | const segments = [];
|
6267 | props.forEach(({ name, value }) => {
|
6268 | name = propsToAttrMap[name] || name.toLowerCase();
|
6269 | if (isRenderableAttr(name) &&
|
6270 | !(attrs && attrs.some(a => a.name === name))) {
|
6271 | segments.push(genAttrSegment(name, value));
|
6272 | }
|
6273 | });
|
6274 | return segments;
|
6275 | }
|
6276 | function genAttrSegment(name, value) {
|
6277 | if (plainStringRE.test(value)) {
|
6278 |
|
6279 | value = value.replace(/^'|'$/g, '"');
|
6280 |
|
6281 | if (isEnumeratedAttr(name) && value !== `"false"`) {
|
6282 | value = `"true"`;
|
6283 | }
|
6284 | return {
|
6285 | type: RAW,
|
6286 | value: isBooleanAttr(name)
|
6287 | ? ` ${name}="${name}"`
|
6288 | : value === '""'
|
6289 | ? ` ${name}`
|
6290 | : ` ${name}="${JSON.parse(value)}"`
|
6291 | };
|
6292 | }
|
6293 | else {
|
6294 | return {
|
6295 | type: EXPRESSION,
|
6296 | value: `_ssrAttr(${JSON.stringify(name)},${value})`
|
6297 | };
|
6298 | }
|
6299 | }
|
6300 | function genClassSegments(staticClass, classBinding) {
|
6301 | if (staticClass && !classBinding) {
|
6302 | return [{ type: RAW, value: ` class="${JSON.parse(staticClass)}"` }];
|
6303 | }
|
6304 | else {
|
6305 | return [
|
6306 | {
|
6307 | type: EXPRESSION,
|
6308 | value: `_ssrClass(${staticClass || 'null'},${classBinding || 'null'})`
|
6309 | }
|
6310 | ];
|
6311 | }
|
6312 | }
|
6313 | function genStyleSegments(staticStyle, parsedStaticStyle, styleBinding, vShowExpression) {
|
6314 | if (staticStyle && !styleBinding && !vShowExpression) {
|
6315 | return [{ type: RAW, value: ` style=${JSON.stringify(staticStyle)}` }];
|
6316 | }
|
6317 | else {
|
6318 | return [
|
6319 | {
|
6320 | type: EXPRESSION,
|
6321 | value: `_ssrStyle(${parsedStaticStyle || 'null'},${styleBinding || 'null'}, ${vShowExpression
|
6322 | ? `{ display: (${vShowExpression}) ? '' : 'none' }`
|
6323 | : 'null'})`
|
6324 | }
|
6325 | ];
|
6326 | }
|
6327 | }
|
6328 |
|
6329 |
|
6330 |
|
6331 |
|
6332 |
|
6333 |
|
6334 |
|
6335 |
|
6336 |
|
6337 |
|
6338 |
|
6339 | const optimizability = {
|
6340 | FALSE: 0,
|
6341 | FULL: 1,
|
6342 | SELF: 2,
|
6343 | CHILDREN: 3,
|
6344 | PARTIAL: 4
|
6345 | };
|
6346 | let isPlatformReservedTag;
|
6347 | function optimize(root, options) {
|
6348 | if (!root)
|
6349 | return;
|
6350 | isPlatformReservedTag = options.isReservedTag || no;
|
6351 | walk(root, true);
|
6352 | }
|
6353 | function walk(node, isRoot) {
|
6354 | if (isUnOptimizableTree(node)) {
|
6355 | node.ssrOptimizability = optimizability.FALSE;
|
6356 | return;
|
6357 | }
|
6358 |
|
6359 | const selfUnoptimizable = isRoot || hasCustomDirective(node);
|
6360 | const check = child => {
|
6361 | if (child.ssrOptimizability !== optimizability.FULL) {
|
6362 | node.ssrOptimizability = selfUnoptimizable
|
6363 | ? optimizability.PARTIAL
|
6364 | : optimizability.SELF;
|
6365 | }
|
6366 | };
|
6367 | if (selfUnoptimizable) {
|
6368 | node.ssrOptimizability = optimizability.CHILDREN;
|
6369 | }
|
6370 | if (node.type === 1) {
|
6371 | for (let i = 0, l = node.children.length; i < l; i++) {
|
6372 | const child = node.children[i];
|
6373 | walk(child);
|
6374 | check(child);
|
6375 | }
|
6376 | if (node.ifConditions) {
|
6377 | for (let i = 1, l = node.ifConditions.length; i < l; i++) {
|
6378 | const block = node.ifConditions[i].block;
|
6379 | walk(block, isRoot);
|
6380 | check(block);
|
6381 | }
|
6382 | }
|
6383 | if (node.ssrOptimizability == null ||
|
6384 | (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))) {
|
6385 | node.ssrOptimizability = optimizability.FULL;
|
6386 | }
|
6387 | else {
|
6388 | node.children = optimizeSiblings(node);
|
6389 | }
|
6390 | }
|
6391 | else {
|
6392 | node.ssrOptimizability = optimizability.FULL;
|
6393 | }
|
6394 | }
|
6395 | function optimizeSiblings(el) {
|
6396 | const children = el.children;
|
6397 | const optimizedChildren = [];
|
6398 | let currentOptimizableGroup = [];
|
6399 | const pushGroup = () => {
|
6400 | if (currentOptimizableGroup.length) {
|
6401 | optimizedChildren.push({
|
6402 | type: 1,
|
6403 | parent: el,
|
6404 | tag: 'template',
|
6405 | attrsList: [],
|
6406 | attrsMap: {},
|
6407 | rawAttrsMap: {},
|
6408 | children: currentOptimizableGroup,
|
6409 | ssrOptimizability: optimizability.FULL
|
6410 | });
|
6411 | }
|
6412 | currentOptimizableGroup = [];
|
6413 | };
|
6414 | for (let i = 0; i < children.length; i++) {
|
6415 | const c = children[i];
|
6416 | if (c.ssrOptimizability === optimizability.FULL) {
|
6417 | currentOptimizableGroup.push(c);
|
6418 | }
|
6419 | else {
|
6420 |
|
6421 |
|
6422 | pushGroup();
|
6423 | optimizedChildren.push(c);
|
6424 | }
|
6425 | }
|
6426 | pushGroup();
|
6427 | return optimizedChildren;
|
6428 | }
|
6429 | function isUnOptimizableTree(node) {
|
6430 | if (node.type === 2 || node.type === 3) {
|
6431 |
|
6432 | return false;
|
6433 | }
|
6434 | return (isBuiltInTag(node.tag) ||
|
6435 | !isPlatformReservedTag(node.tag) ||
|
6436 | !!node.component ||
|
6437 | isSelectWithModel(node)
|
6438 | );
|
6439 | }
|
6440 | const isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
|
6441 | function hasCustomDirective(node) {
|
6442 | return (node.type === 1 &&
|
6443 | node.directives &&
|
6444 | node.directives.some(d => !isBuiltInDir(d.name)));
|
6445 | }
|
6446 |
|
6447 |
|
6448 | function isSelectWithModel(node) {
|
6449 | return (node.type === 1 &&
|
6450 | node.tag === 'select' &&
|
6451 | node.directives != null &&
|
6452 | node.directives.some(d => d.name === 'model'));
|
6453 | }
|
6454 |
|
6455 |
|
6456 |
|
6457 | const RAW = 0;
|
6458 | const INTERPOLATION = 1;
|
6459 | const EXPRESSION = 2;
|
6460 | function generate(ast, options) {
|
6461 | const state = new CodegenState(options);
|
6462 | const code = ast ? genSSRElement(ast, state) : '_c("div")';
|
6463 | return {
|
6464 | render: `with(this){return ${code}}`,
|
6465 | staticRenderFns: state.staticRenderFns
|
6466 | };
|
6467 | }
|
6468 | function genSSRElement(el, state) {
|
6469 | if (el.for && !el.forProcessed) {
|
6470 | return genFor(el, state, genSSRElement);
|
6471 | }
|
6472 | else if (el.if && !el.ifProcessed) {
|
6473 | return genIf(el, state, genSSRElement);
|
6474 | }
|
6475 | else if (el.tag === 'template' && !el.slotTarget) {
|
6476 | return el.ssrOptimizability === optimizability.FULL
|
6477 | ? genChildrenAsStringNode(el, state)
|
6478 | : genSSRChildren(el, state) || 'void 0';
|
6479 | }
|
6480 | switch (el.ssrOptimizability) {
|
6481 | case optimizability.FULL:
|
6482 |
|
6483 | return genStringElement(el, state);
|
6484 | case optimizability.SELF:
|
6485 |
|
6486 | return genStringElementWithChildren(el, state);
|
6487 | case optimizability.CHILDREN:
|
6488 |
|
6489 | return genNormalElement(el, state, true);
|
6490 | case optimizability.PARTIAL:
|
6491 |
|
6492 | return genNormalElement(el, state, false);
|
6493 | default:
|
6494 |
|
6495 | return genElement(el, state);
|
6496 | }
|
6497 | }
|
6498 | function genNormalElement(el, state, stringifyChildren) {
|
6499 | const data = el.plain ? undefined : genData(el, state);
|
6500 | const children = stringifyChildren
|
6501 | ? `[${genChildrenAsStringNode(el, state)}]`
|
6502 | : genSSRChildren(el, state, true);
|
6503 | return `_c('${el.tag}'${data ? `,${data}` : ''}${children ? `,${children}` : ''})`;
|
6504 | }
|
6505 | function genSSRChildren(el, state, checkSkip) {
|
6506 | return genChildren(el, state, checkSkip, genSSRElement, genSSRNode);
|
6507 | }
|
6508 | function genSSRNode(el, state) {
|
6509 | return el.type === 1 ? genSSRElement(el, state) : genText(el);
|
6510 | }
|
6511 | function genChildrenAsStringNode(el, state) {
|
6512 | return el.children.length
|
6513 | ? `_ssrNode(${flattenSegments(childrenToSegments(el, state))})`
|
6514 | : '';
|
6515 | }
|
6516 | function genStringElement(el, state) {
|
6517 | return `_ssrNode(${elementToString(el, state)})`;
|
6518 | }
|
6519 | function genStringElementWithChildren(el, state) {
|
6520 | const children = genSSRChildren(el, state, true);
|
6521 | return `_ssrNode(${flattenSegments(elementToOpenTagSegments(el, state))},"</${el.tag}>"${children ? `,${children}` : ''})`;
|
6522 | }
|
6523 | function elementToString(el, state) {
|
6524 | return `(${flattenSegments(elementToSegments(el, state))})`;
|
6525 | }
|
6526 | function elementToSegments(el, state) {
|
6527 |
|
6528 | if (el.for && !el.forProcessed) {
|
6529 | el.forProcessed = true;
|
6530 | return [
|
6531 | {
|
6532 | type: EXPRESSION,
|
6533 | value: genFor(el, state, elementToString, '_ssrList')
|
6534 | }
|
6535 | ];
|
6536 | }
|
6537 | else if (el.if && !el.ifProcessed) {
|
6538 | el.ifProcessed = true;
|
6539 | return [
|
6540 | {
|
6541 | type: EXPRESSION,
|
6542 | value: genIf(el, state, elementToString, '"<!---->"')
|
6543 | }
|
6544 | ];
|
6545 | }
|
6546 | else if (el.tag === 'template') {
|
6547 | return childrenToSegments(el, state);
|
6548 | }
|
6549 | const openSegments = elementToOpenTagSegments(el, state);
|
6550 | const childrenSegments = childrenToSegments(el, state);
|
6551 | const { isUnaryTag } = state.options;
|
6552 | const close = isUnaryTag && isUnaryTag(el.tag)
|
6553 | ? []
|
6554 | : [{ type: RAW, value: `</${el.tag}>` }];
|
6555 | return openSegments.concat(childrenSegments, close);
|
6556 | }
|
6557 | function elementToOpenTagSegments(el, state) {
|
6558 | applyModelTransform(el, state);
|
6559 | let binding;
|
6560 | const segments = [{ type: RAW, value: `<${el.tag}` }];
|
6561 |
|
6562 | if (el.attrs) {
|
6563 | segments.push.apply(segments, genAttrSegments(el.attrs));
|
6564 | }
|
6565 |
|
6566 | if (el.props) {
|
6567 | segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
|
6568 | }
|
6569 |
|
6570 | if ((binding = el.attrsMap['v-bind'])) {
|
6571 | segments.push({ type: EXPRESSION, value: `_ssrAttrs(${binding})` });
|
6572 | }
|
6573 |
|
6574 | if ((binding = el.attrsMap['v-bind.prop'])) {
|
6575 | segments.push({ type: EXPRESSION, value: `_ssrDOMProps(${binding})` });
|
6576 | }
|
6577 |
|
6578 | if (el.staticClass || el.classBinding) {
|
6579 | segments.push.apply(segments, genClassSegments(el.staticClass, el.classBinding));
|
6580 | }
|
6581 |
|
6582 | if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
|
6583 | segments.push.apply(segments, genStyleSegments(el.attrsMap.style, el.staticStyle, el.styleBinding, el.attrsMap['v-show']));
|
6584 | }
|
6585 |
|
6586 | if (state.options.scopeId) {
|
6587 | segments.push({ type: RAW, value: ` ${state.options.scopeId}` });
|
6588 | }
|
6589 | segments.push({ type: RAW, value: `>` });
|
6590 | return segments;
|
6591 | }
|
6592 | function childrenToSegments(el, state) {
|
6593 | let binding;
|
6594 | if ((binding = el.attrsMap['v-html'])) {
|
6595 | return [{ type: EXPRESSION, value: `_s(${binding})` }];
|
6596 | }
|
6597 | if ((binding = el.attrsMap['v-text'])) {
|
6598 | return [{ type: INTERPOLATION, value: `_s(${binding})` }];
|
6599 | }
|
6600 | if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
|
6601 | return [{ type: INTERPOLATION, value: `_s(${binding})` }];
|
6602 | }
|
6603 | return el.children ? nodesToSegments(el.children, state) : [];
|
6604 | }
|
6605 | function nodesToSegments(children, state) {
|
6606 | const segments = [];
|
6607 | for (let i = 0; i < children.length; i++) {
|
6608 | const c = children[i];
|
6609 | if (c.type === 1) {
|
6610 | segments.push.apply(segments, elementToSegments(c, state));
|
6611 | }
|
6612 | else if (c.type === 2) {
|
6613 | segments.push({ type: INTERPOLATION, value: c.expression });
|
6614 | }
|
6615 | else if (c.type === 3) {
|
6616 | let text = escape(c.text);
|
6617 | if (c.isComment) {
|
6618 | text = '<!--' + text + '-->';
|
6619 | }
|
6620 | segments.push({ type: RAW, value: text });
|
6621 | }
|
6622 | }
|
6623 | return segments;
|
6624 | }
|
6625 | function flattenSegments(segments) {
|
6626 | const mergedSegments = [];
|
6627 | let textBuffer = '';
|
6628 | const pushBuffer = () => {
|
6629 | if (textBuffer) {
|
6630 | mergedSegments.push(JSON.stringify(textBuffer));
|
6631 | textBuffer = '';
|
6632 | }
|
6633 | };
|
6634 | for (let i = 0; i < segments.length; i++) {
|
6635 | const s = segments[i];
|
6636 | if (s.type === RAW) {
|
6637 | textBuffer += s.value;
|
6638 | }
|
6639 | else if (s.type === INTERPOLATION) {
|
6640 | pushBuffer();
|
6641 | mergedSegments.push(`_ssrEscape(${s.value})`);
|
6642 | }
|
6643 | else if (s.type === EXPRESSION) {
|
6644 | pushBuffer();
|
6645 | mergedSegments.push(`(${s.value})`);
|
6646 | }
|
6647 | }
|
6648 | pushBuffer();
|
6649 | return mergedSegments.join('+');
|
6650 | }
|
6651 |
|
6652 | const createCompiler = createCompilerCreator(function baseCompile(template, options) {
|
6653 | const ast = parse(template.trim(), options);
|
6654 | optimize(ast, options);
|
6655 | const code = generate(ast, options);
|
6656 | return {
|
6657 | ast,
|
6658 | render: code.render,
|
6659 | staticRenderFns: code.staticRenderFns
|
6660 | };
|
6661 | });
|
6662 |
|
6663 | const { compile, compileToFunctions } = createCompiler(baseOptions);
|
6664 |
|
6665 | exports.compile = compile$1;
|
6666 | exports.compileToFunctions = compileToFunctions$1;
|
6667 | exports.generateCodeFrame = generateCodeFrame;
|
6668 | exports.parseComponent = parseComponent;
|
6669 | exports.ssrCompile = compile;
|
6670 | exports.ssrCompileToFunctions = compileToFunctions;
|