@vue/compiler-dom 3.5.0-alpha.1 → 3.5.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-dom.cjs.js +36 -24
- package/dist/compiler-dom.cjs.prod.js +34 -20
- package/dist/compiler-dom.esm-browser.js +258 -233
- package/dist/compiler-dom.esm-browser.prod.js +8 -4
- package/dist/compiler-dom.esm-bundler.js +4 -7
- package/dist/compiler-dom.global.js +258 -233
- package/dist/compiler-dom.global.prod.js +8 -4
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-dom v3.5.0-alpha.
|
|
2
|
+
* @vue/compiler-dom v3.5.0-alpha.3
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -75,6 +75,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
75
75
|
|
|
76
76
|
const range = 2;
|
|
77
77
|
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
78
|
+
start = Math.max(0, Math.min(start, source.length));
|
|
79
|
+
end = Math.max(0, Math.min(end, source.length));
|
|
80
|
+
if (start > end) return "";
|
|
78
81
|
let lines = source.split(/(\r?\n)/);
|
|
79
82
|
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
80
83
|
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
@@ -84,8 +87,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
84
87
|
count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
|
85
88
|
if (count >= start) {
|
|
86
89
|
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
87
|
-
if (j < 0 || j >= lines.length)
|
|
88
|
-
continue;
|
|
90
|
+
if (j < 0 || j >= lines.length) continue;
|
|
89
91
|
const line = j + 1;
|
|
90
92
|
res.push(
|
|
91
93
|
`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
|
|
@@ -303,8 +305,8 @@ var VueCompilerDOM = (function (exports) {
|
|
|
303
305
|
"0": "NOT_CONSTANT",
|
|
304
306
|
"CAN_SKIP_PATCH": 1,
|
|
305
307
|
"1": "CAN_SKIP_PATCH",
|
|
306
|
-
"
|
|
307
|
-
"2": "
|
|
308
|
+
"CAN_CACHE": 2,
|
|
309
|
+
"2": "CAN_CACHE",
|
|
308
310
|
"CAN_STRINGIFY": 3,
|
|
309
311
|
"3": "CAN_STRINGIFY"
|
|
310
312
|
};
|
|
@@ -323,7 +325,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
323
325
|
directives: [],
|
|
324
326
|
hoists: [],
|
|
325
327
|
imports: [],
|
|
326
|
-
cached:
|
|
328
|
+
cached: [],
|
|
327
329
|
temps: 0,
|
|
328
330
|
codegenNode: void 0,
|
|
329
331
|
loc: locStub
|
|
@@ -428,12 +430,13 @@ var VueCompilerDOM = (function (exports) {
|
|
|
428
430
|
loc: locStub
|
|
429
431
|
};
|
|
430
432
|
}
|
|
431
|
-
function createCacheExpression(index, value,
|
|
433
|
+
function createCacheExpression(index, value, needPauseTracking = false) {
|
|
432
434
|
return {
|
|
433
435
|
type: 20,
|
|
434
436
|
index,
|
|
435
437
|
value,
|
|
436
|
-
|
|
438
|
+
needPauseTracking,
|
|
439
|
+
needArraySpread: false,
|
|
437
440
|
loc: locStub
|
|
438
441
|
};
|
|
439
442
|
}
|
|
@@ -1374,8 +1377,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1374
1377
|
Details: ${link}` : ``}`;
|
|
1375
1378
|
const err = new SyntaxError(msg);
|
|
1376
1379
|
err.code = key;
|
|
1377
|
-
if (loc)
|
|
1378
|
-
err.loc = loc;
|
|
1380
|
+
if (loc) err.loc = loc;
|
|
1379
1381
|
context.onWarn(err);
|
|
1380
1382
|
}
|
|
1381
1383
|
|
|
@@ -1611,16 +1613,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1611
1613
|
function walkBlockDeclarations(block, onIdent) {
|
|
1612
1614
|
for (const stmt of block.body) {
|
|
1613
1615
|
if (stmt.type === "VariableDeclaration") {
|
|
1614
|
-
if (stmt.declare)
|
|
1615
|
-
continue;
|
|
1616
|
+
if (stmt.declare) continue;
|
|
1616
1617
|
for (const decl of stmt.declarations) {
|
|
1617
1618
|
for (const id of extractIdentifiers(decl.id)) {
|
|
1618
1619
|
onIdent(id);
|
|
1619
1620
|
}
|
|
1620
1621
|
}
|
|
1621
1622
|
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
1622
|
-
if (stmt.declare || !stmt.id)
|
|
1623
|
-
continue;
|
|
1623
|
+
if (stmt.declare || !stmt.id) continue;
|
|
1624
1624
|
onIdent(stmt.id);
|
|
1625
1625
|
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
1626
1626
|
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
@@ -1657,8 +1657,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1657
1657
|
break;
|
|
1658
1658
|
case "ArrayPattern":
|
|
1659
1659
|
param.elements.forEach((element) => {
|
|
1660
|
-
if (element)
|
|
1661
|
-
extractIdentifiers(element, nodes);
|
|
1660
|
+
if (element) extractIdentifiers(element, nodes);
|
|
1662
1661
|
});
|
|
1663
1662
|
break;
|
|
1664
1663
|
case "RestElement":
|
|
@@ -1712,7 +1711,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1712
1711
|
return BASE_TRANSITION;
|
|
1713
1712
|
}
|
|
1714
1713
|
}
|
|
1715
|
-
const nonIdentifierRE = /^\d|[^\$\w]/;
|
|
1714
|
+
const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
|
|
1716
1715
|
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
|
1717
1716
|
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
|
1718
1717
|
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
|
@@ -1823,8 +1822,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1823
1822
|
for (let i = 0; i < node.props.length; i++) {
|
|
1824
1823
|
const p = node.props[i];
|
|
1825
1824
|
if (p.type === 6) {
|
|
1826
|
-
if (dynamicOnly)
|
|
1827
|
-
continue;
|
|
1825
|
+
if (dynamicOnly) continue;
|
|
1828
1826
|
if (p.name === name && (p.value || allowEmpty)) {
|
|
1829
1827
|
return p;
|
|
1830
1828
|
}
|
|
@@ -1976,6 +1974,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1976
1974
|
return hasScopeRef(node.content, ids);
|
|
1977
1975
|
case 2:
|
|
1978
1976
|
case 3:
|
|
1977
|
+
case 20:
|
|
1979
1978
|
return false;
|
|
1980
1979
|
default:
|
|
1981
1980
|
return false;
|
|
@@ -1988,7 +1987,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1988
1987
|
return node;
|
|
1989
1988
|
}
|
|
1990
1989
|
}
|
|
1991
|
-
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
1990
|
+
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
|
|
1992
1991
|
|
|
1993
1992
|
const defaultParserOptions = {
|
|
1994
1993
|
parseMode: "base",
|
|
@@ -2088,11 +2087,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2088
2087
|
}
|
|
2089
2088
|
},
|
|
2090
2089
|
onselfclosingtag(end) {
|
|
2091
|
-
var _a;
|
|
2092
2090
|
const name = currentOpenTag.tag;
|
|
2093
2091
|
currentOpenTag.isSelfClosing = true;
|
|
2094
2092
|
endOpenTag(end);
|
|
2095
|
-
if (
|
|
2093
|
+
if (stack[0] && stack[0].tag === name) {
|
|
2096
2094
|
onCloseTag(stack.shift(), end);
|
|
2097
2095
|
}
|
|
2098
2096
|
},
|
|
@@ -2142,8 +2140,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2142
2140
|
}
|
|
2143
2141
|
},
|
|
2144
2142
|
ondirarg(start, end) {
|
|
2145
|
-
if (start === end)
|
|
2146
|
-
return;
|
|
2143
|
+
if (start === end) return;
|
|
2147
2144
|
const arg = getSlice(start, end);
|
|
2148
2145
|
if (inVPre) {
|
|
2149
2146
|
currentProp.name += arg;
|
|
@@ -2175,14 +2172,12 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2175
2172
|
},
|
|
2176
2173
|
onattribdata(start, end) {
|
|
2177
2174
|
currentAttrValue += getSlice(start, end);
|
|
2178
|
-
if (currentAttrStartIndex < 0)
|
|
2179
|
-
currentAttrStartIndex = start;
|
|
2175
|
+
if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
|
|
2180
2176
|
currentAttrEndIndex = end;
|
|
2181
2177
|
},
|
|
2182
2178
|
onattribentity(char, start, end) {
|
|
2183
2179
|
currentAttrValue += char;
|
|
2184
|
-
if (currentAttrStartIndex < 0)
|
|
2185
|
-
currentAttrStartIndex = start;
|
|
2180
|
+
if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
|
|
2186
2181
|
currentAttrEndIndex = end;
|
|
2187
2182
|
},
|
|
2188
2183
|
onattribnameend(end) {
|
|
@@ -2329,8 +2324,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2329
2324
|
const loc = input.loc;
|
|
2330
2325
|
const exp = input.content;
|
|
2331
2326
|
const inMatch = exp.match(forAliasRE);
|
|
2332
|
-
if (!inMatch)
|
|
2333
|
-
return;
|
|
2327
|
+
if (!inMatch) return;
|
|
2334
2328
|
const [, LHS, RHS] = inMatch;
|
|
2335
2329
|
const createAliasExpression = (content, offset, asParam = false) => {
|
|
2336
2330
|
const start = loc.start.offset + offset;
|
|
@@ -2403,16 +2397,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2403
2397
|
currentOpenTag = null;
|
|
2404
2398
|
}
|
|
2405
2399
|
function onText(content, start, end) {
|
|
2406
|
-
var _a;
|
|
2407
2400
|
{
|
|
2408
|
-
const tag =
|
|
2401
|
+
const tag = stack[0] && stack[0].tag;
|
|
2409
2402
|
if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
|
2410
2403
|
content = currentOptions.decodeEntities(content, false);
|
|
2411
2404
|
}
|
|
2412
2405
|
}
|
|
2413
2406
|
const parent = stack[0] || currentRoot;
|
|
2414
2407
|
const lastNode = parent.children[parent.children.length - 1];
|
|
2415
|
-
if (
|
|
2408
|
+
if (lastNode && lastNode.type === 2) {
|
|
2416
2409
|
lastNode.content += content;
|
|
2417
2410
|
setLocEnd(lastNode.loc, end);
|
|
2418
2411
|
} else {
|
|
@@ -2524,14 +2517,12 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2524
2517
|
}
|
|
2525
2518
|
function lookAhead(index, c) {
|
|
2526
2519
|
let i = index;
|
|
2527
|
-
while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1)
|
|
2528
|
-
i++;
|
|
2520
|
+
while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
|
|
2529
2521
|
return i;
|
|
2530
2522
|
}
|
|
2531
2523
|
function backTrack(index, c) {
|
|
2532
2524
|
let i = index;
|
|
2533
|
-
while (currentInput.charCodeAt(i) !== c && i >= 0)
|
|
2534
|
-
i--;
|
|
2525
|
+
while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
|
|
2535
2526
|
return i;
|
|
2536
2527
|
}
|
|
2537
2528
|
const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
|
|
@@ -2546,11 +2537,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2546
2537
|
return false;
|
|
2547
2538
|
}
|
|
2548
2539
|
function isComponent({ tag, props }) {
|
|
2549
|
-
var _a;
|
|
2550
2540
|
if (currentOptions.isCustomElement(tag)) {
|
|
2551
2541
|
return false;
|
|
2552
2542
|
}
|
|
2553
|
-
if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) ||
|
|
2543
|
+
if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
|
|
2554
2544
|
return true;
|
|
2555
2545
|
}
|
|
2556
2546
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -2583,7 +2573,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2583
2573
|
}
|
|
2584
2574
|
const windowsNewlineRE = /\r\n/g;
|
|
2585
2575
|
function condenseWhitespace(nodes, tag) {
|
|
2586
|
-
var _a, _b;
|
|
2587
2576
|
const shouldCondense = currentOptions.whitespace !== "preserve";
|
|
2588
2577
|
let removedWhitespace = false;
|
|
2589
2578
|
for (let i = 0; i < nodes.length; i++) {
|
|
@@ -2591,8 +2580,8 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2591
2580
|
if (node.type === 2) {
|
|
2592
2581
|
if (!inPre) {
|
|
2593
2582
|
if (isAllWhitespace(node.content)) {
|
|
2594
|
-
const prev =
|
|
2595
|
-
const next =
|
|
2583
|
+
const prev = nodes[i - 1] && nodes[i - 1].type;
|
|
2584
|
+
const next = nodes[i + 1] && nodes[i + 1].type;
|
|
2596
2585
|
if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
|
2597
2586
|
removedWhitespace = true;
|
|
2598
2587
|
nodes[i] = null;
|
|
@@ -2730,7 +2719,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2730
2719
|
}
|
|
2731
2720
|
tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
2732
2721
|
tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
|
|
2733
|
-
const delimiters = options
|
|
2722
|
+
const delimiters = options && options.delimiters;
|
|
2734
2723
|
if (delimiters) {
|
|
2735
2724
|
tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
|
2736
2725
|
tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
|
@@ -2743,9 +2732,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2743
2732
|
return root;
|
|
2744
2733
|
}
|
|
2745
2734
|
|
|
2746
|
-
function
|
|
2735
|
+
function cacheStatic(root, context) {
|
|
2747
2736
|
walk(
|
|
2748
2737
|
root,
|
|
2738
|
+
void 0,
|
|
2749
2739
|
context,
|
|
2750
2740
|
// Root node is unfortunately non-hoistable due to potential parent
|
|
2751
2741
|
// fallthrough attributes.
|
|
@@ -2756,26 +2746,24 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2756
2746
|
const { children } = root;
|
|
2757
2747
|
return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
|
2758
2748
|
}
|
|
2759
|
-
function walk(node, context, doNotHoistNode = false) {
|
|
2749
|
+
function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
2760
2750
|
const { children } = node;
|
|
2761
|
-
const
|
|
2762
|
-
let hoistedCount = 0;
|
|
2751
|
+
const toCache = [];
|
|
2763
2752
|
for (let i = 0; i < children.length; i++) {
|
|
2764
2753
|
const child = children[i];
|
|
2765
2754
|
if (child.type === 1 && child.tagType === 0) {
|
|
2766
2755
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
2767
2756
|
if (constantType > 0) {
|
|
2768
2757
|
if (constantType >= 2) {
|
|
2769
|
-
child.codegenNode.patchFlag = -1
|
|
2770
|
-
|
|
2771
|
-
hoistedCount++;
|
|
2758
|
+
child.codegenNode.patchFlag = -1;
|
|
2759
|
+
toCache.push(child);
|
|
2772
2760
|
continue;
|
|
2773
2761
|
}
|
|
2774
2762
|
} else {
|
|
2775
2763
|
const codegenNode = child.codegenNode;
|
|
2776
2764
|
if (codegenNode.type === 13) {
|
|
2777
|
-
const flag =
|
|
2778
|
-
if ((
|
|
2765
|
+
const flag = codegenNode.patchFlag;
|
|
2766
|
+
if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
|
|
2779
2767
|
const props = getNodeProps(child);
|
|
2780
2768
|
if (props) {
|
|
2781
2769
|
codegenNode.props = context.hoist(props);
|
|
@@ -2786,39 +2774,84 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2786
2774
|
}
|
|
2787
2775
|
}
|
|
2788
2776
|
}
|
|
2777
|
+
} else if (child.type === 12) {
|
|
2778
|
+
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
2779
|
+
if (constantType >= 2) {
|
|
2780
|
+
toCache.push(child);
|
|
2781
|
+
continue;
|
|
2782
|
+
}
|
|
2789
2783
|
}
|
|
2790
2784
|
if (child.type === 1) {
|
|
2791
2785
|
const isComponent = child.tagType === 1;
|
|
2792
2786
|
if (isComponent) {
|
|
2793
2787
|
context.scopes.vSlot++;
|
|
2794
2788
|
}
|
|
2795
|
-
walk(child, context);
|
|
2789
|
+
walk(child, node, context, false, inFor);
|
|
2796
2790
|
if (isComponent) {
|
|
2797
2791
|
context.scopes.vSlot--;
|
|
2798
2792
|
}
|
|
2799
2793
|
} else if (child.type === 11) {
|
|
2800
|
-
walk(child, context, child.children.length === 1);
|
|
2794
|
+
walk(child, node, context, child.children.length === 1, true);
|
|
2801
2795
|
} else if (child.type === 9) {
|
|
2802
2796
|
for (let i2 = 0; i2 < child.branches.length; i2++) {
|
|
2803
2797
|
walk(
|
|
2804
2798
|
child.branches[i2],
|
|
2799
|
+
node,
|
|
2805
2800
|
context,
|
|
2806
|
-
child.branches[i2].children.length === 1
|
|
2801
|
+
child.branches[i2].children.length === 1,
|
|
2802
|
+
inFor
|
|
2807
2803
|
);
|
|
2808
2804
|
}
|
|
2809
2805
|
}
|
|
2810
2806
|
}
|
|
2811
|
-
|
|
2812
|
-
|
|
2807
|
+
let cachedAsArray = false;
|
|
2808
|
+
if (toCache.length === children.length && node.type === 1) {
|
|
2809
|
+
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
|
|
2810
|
+
node.codegenNode.children = getCacheExpression(
|
|
2811
|
+
createArrayExpression(node.codegenNode.children)
|
|
2812
|
+
);
|
|
2813
|
+
cachedAsArray = true;
|
|
2814
|
+
} else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
2815
|
+
const slot = getSlotNode(node.codegenNode, "default");
|
|
2816
|
+
if (slot) {
|
|
2817
|
+
slot.returns = getCacheExpression(
|
|
2818
|
+
createArrayExpression(slot.returns)
|
|
2819
|
+
);
|
|
2820
|
+
cachedAsArray = true;
|
|
2821
|
+
}
|
|
2822
|
+
} else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
|
|
2823
|
+
const slotName = findDir(node, "slot", true);
|
|
2824
|
+
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
2825
|
+
if (slot) {
|
|
2826
|
+
slot.returns = getCacheExpression(
|
|
2827
|
+
createArrayExpression(slot.returns)
|
|
2828
|
+
);
|
|
2829
|
+
cachedAsArray = true;
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2813
2832
|
}
|
|
2814
|
-
if (
|
|
2815
|
-
const
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2833
|
+
if (!cachedAsArray) {
|
|
2834
|
+
for (const child of toCache) {
|
|
2835
|
+
child.codegenNode = context.cache(child.codegenNode);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
function getCacheExpression(value) {
|
|
2839
|
+
const exp = context.cache(value);
|
|
2840
|
+
if (inFor && context.hmr) {
|
|
2841
|
+
exp.needArraySpread = true;
|
|
2842
|
+
}
|
|
2843
|
+
return exp;
|
|
2844
|
+
}
|
|
2845
|
+
function getSlotNode(node2, name) {
|
|
2846
|
+
if (node2.children && !isArray(node2.children) && node2.children.type === 15) {
|
|
2847
|
+
const slot = node2.children.properties.find(
|
|
2848
|
+
(p) => p.key === name || p.key.content === name
|
|
2849
|
+
);
|
|
2850
|
+
return slot && slot.value;
|
|
2820
2851
|
}
|
|
2821
|
-
|
|
2852
|
+
}
|
|
2853
|
+
if (toCache.length && context.transformHoist) {
|
|
2854
|
+
context.transformHoist(children, context, node);
|
|
2822
2855
|
}
|
|
2823
2856
|
}
|
|
2824
2857
|
function getConstantType(node, context) {
|
|
@@ -2836,11 +2869,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2836
2869
|
if (codegenNode.type !== 13) {
|
|
2837
2870
|
return 0;
|
|
2838
2871
|
}
|
|
2839
|
-
if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
|
|
2872
|
+
if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
|
|
2840
2873
|
return 0;
|
|
2841
2874
|
}
|
|
2842
|
-
|
|
2843
|
-
if (!flag) {
|
|
2875
|
+
if (codegenNode.patchFlag === void 0) {
|
|
2844
2876
|
let returnType2 = 3;
|
|
2845
2877
|
const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
|
2846
2878
|
if (generatedPropsType === 0) {
|
|
@@ -2923,6 +2955,8 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2923
2955
|
}
|
|
2924
2956
|
}
|
|
2925
2957
|
return returnType;
|
|
2958
|
+
case 20:
|
|
2959
|
+
return 2;
|
|
2926
2960
|
default:
|
|
2927
2961
|
return 0;
|
|
2928
2962
|
}
|
|
@@ -2982,15 +3016,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2982
3016
|
return codegenNode.props;
|
|
2983
3017
|
}
|
|
2984
3018
|
}
|
|
2985
|
-
function getPatchFlag(node) {
|
|
2986
|
-
const flag = node.patchFlag;
|
|
2987
|
-
return flag ? parseInt(flag, 10) : void 0;
|
|
2988
|
-
}
|
|
2989
3019
|
|
|
2990
3020
|
function createTransformContext(root, {
|
|
2991
3021
|
filename = "",
|
|
2992
3022
|
prefixIdentifiers = false,
|
|
2993
|
-
hoistStatic
|
|
3023
|
+
hoistStatic = false,
|
|
2994
3024
|
hmr = false,
|
|
2995
3025
|
cacheHandlers = false,
|
|
2996
3026
|
nodeTransforms = [],
|
|
@@ -3017,7 +3047,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3017
3047
|
filename,
|
|
3018
3048
|
selfName: nameMatch && capitalize(camelize(nameMatch[1])),
|
|
3019
3049
|
prefixIdentifiers,
|
|
3020
|
-
hoistStatic
|
|
3050
|
+
hoistStatic,
|
|
3021
3051
|
hmr,
|
|
3022
3052
|
cacheHandlers,
|
|
3023
3053
|
nodeTransforms,
|
|
@@ -3044,9 +3074,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3044
3074
|
directives: /* @__PURE__ */ new Set(),
|
|
3045
3075
|
hoists: [],
|
|
3046
3076
|
imports: [],
|
|
3077
|
+
cached: [],
|
|
3047
3078
|
constantCache: /* @__PURE__ */ new WeakMap(),
|
|
3048
3079
|
temps: 0,
|
|
3049
|
-
cached: 0,
|
|
3050
3080
|
identifiers: /* @__PURE__ */ Object.create(null),
|
|
3051
3081
|
scopes: {
|
|
3052
3082
|
vFor: 0,
|
|
@@ -3116,8 +3146,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3116
3146
|
removeIdentifiers(exp) {
|
|
3117
3147
|
},
|
|
3118
3148
|
hoist(exp) {
|
|
3119
|
-
if (isString(exp))
|
|
3120
|
-
exp = createSimpleExpression(exp);
|
|
3149
|
+
if (isString(exp)) exp = createSimpleExpression(exp);
|
|
3121
3150
|
context.hoists.push(exp);
|
|
3122
3151
|
const identifier = createSimpleExpression(
|
|
3123
3152
|
`_hoisted_${context.hoists.length}`,
|
|
@@ -3129,7 +3158,13 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3129
3158
|
return identifier;
|
|
3130
3159
|
},
|
|
3131
3160
|
cache(exp, isVNode = false) {
|
|
3132
|
-
|
|
3161
|
+
const cacheExp = createCacheExpression(
|
|
3162
|
+
context.cached.length,
|
|
3163
|
+
exp,
|
|
3164
|
+
isVNode
|
|
3165
|
+
);
|
|
3166
|
+
context.cached.push(cacheExp);
|
|
3167
|
+
return cacheExp;
|
|
3133
3168
|
}
|
|
3134
3169
|
};
|
|
3135
3170
|
{
|
|
@@ -3141,7 +3176,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3141
3176
|
const context = createTransformContext(root, options);
|
|
3142
3177
|
traverseNode(root, context);
|
|
3143
3178
|
if (options.hoistStatic) {
|
|
3144
|
-
|
|
3179
|
+
cacheStatic(root, context);
|
|
3145
3180
|
}
|
|
3146
3181
|
if (!options.ssr) {
|
|
3147
3182
|
createRootCodegen(root, context);
|
|
@@ -3184,7 +3219,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3184
3219
|
helper(FRAGMENT),
|
|
3185
3220
|
void 0,
|
|
3186
3221
|
root.children,
|
|
3187
|
-
patchFlag
|
|
3222
|
+
patchFlag,
|
|
3188
3223
|
void 0,
|
|
3189
3224
|
void 0,
|
|
3190
3225
|
true,
|
|
@@ -3200,8 +3235,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3200
3235
|
};
|
|
3201
3236
|
for (; i < parent.children.length; i++) {
|
|
3202
3237
|
const child = parent.children[i];
|
|
3203
|
-
if (isString(child))
|
|
3204
|
-
continue;
|
|
3238
|
+
if (isString(child)) continue;
|
|
3205
3239
|
context.grandParent = context.parent;
|
|
3206
3240
|
context.parent = parent;
|
|
3207
3241
|
context.childIndex = i;
|
|
@@ -3272,8 +3306,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3272
3306
|
props.splice(i, 1);
|
|
3273
3307
|
i--;
|
|
3274
3308
|
const onExit = fn(node, prop, context);
|
|
3275
|
-
if (onExit)
|
|
3276
|
-
exitFns.push(onExit);
|
|
3309
|
+
if (onExit) exitFns.push(onExit);
|
|
3277
3310
|
}
|
|
3278
3311
|
}
|
|
3279
3312
|
return exitFns;
|
|
@@ -3345,8 +3378,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3345
3378
|
}
|
|
3346
3379
|
function generate(ast, options = {}) {
|
|
3347
3380
|
const context = createCodegenContext(ast, options);
|
|
3348
|
-
if (options.onContextCreated)
|
|
3349
|
-
options.onContextCreated(context);
|
|
3381
|
+
if (options.onContextCreated) options.onContextCreated(context);
|
|
3350
3382
|
const {
|
|
3351
3383
|
mode,
|
|
3352
3384
|
push,
|
|
@@ -3488,14 +3520,12 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3488
3520
|
return;
|
|
3489
3521
|
}
|
|
3490
3522
|
context.pure = true;
|
|
3491
|
-
const { push, newline
|
|
3523
|
+
const { push, newline } = context;
|
|
3492
3524
|
newline();
|
|
3493
3525
|
for (let i = 0; i < hoists.length; i++) {
|
|
3494
3526
|
const exp = hoists[i];
|
|
3495
3527
|
if (exp) {
|
|
3496
|
-
push(
|
|
3497
|
-
`const _hoisted_${i + 1} = ${``}`
|
|
3498
|
-
);
|
|
3528
|
+
push(`const _hoisted_${i + 1} = `);
|
|
3499
3529
|
genNode(exp, context);
|
|
3500
3530
|
newline();
|
|
3501
3531
|
}
|
|
@@ -3628,8 +3658,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3628
3658
|
}
|
|
3629
3659
|
function genInterpolation(node, context) {
|
|
3630
3660
|
const { push, helper, pure } = context;
|
|
3631
|
-
if (pure)
|
|
3632
|
-
push(PURE_ANNOTATION);
|
|
3661
|
+
if (pure) push(PURE_ANNOTATION);
|
|
3633
3662
|
push(`${helper(TO_DISPLAY_STRING)}(`);
|
|
3634
3663
|
genNode(node.content, context);
|
|
3635
3664
|
push(`)`);
|
|
@@ -3681,6 +3710,17 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3681
3710
|
disableTracking,
|
|
3682
3711
|
isComponent
|
|
3683
3712
|
} = node;
|
|
3713
|
+
let patchFlagString;
|
|
3714
|
+
if (patchFlag) {
|
|
3715
|
+
{
|
|
3716
|
+
if (patchFlag < 0) {
|
|
3717
|
+
patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
|
3718
|
+
} else {
|
|
3719
|
+
const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
|
|
3720
|
+
patchFlagString = patchFlag + ` /* ${flagNames} */`;
|
|
3721
|
+
}
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3684
3724
|
if (directives) {
|
|
3685
3725
|
push(helper(WITH_DIRECTIVES) + `(`);
|
|
3686
3726
|
}
|
|
@@ -3693,7 +3733,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3693
3733
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
3694
3734
|
push(helper(callHelper) + `(`, -2 /* None */, node);
|
|
3695
3735
|
genNodeList(
|
|
3696
|
-
genNullableArgs([tag, props, children,
|
|
3736
|
+
genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
|
|
3697
3737
|
context
|
|
3698
3738
|
);
|
|
3699
3739
|
push(`)`);
|
|
@@ -3709,8 +3749,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3709
3749
|
function genNullableArgs(args) {
|
|
3710
3750
|
let i = args.length;
|
|
3711
3751
|
while (i--) {
|
|
3712
|
-
if (args[i] != null)
|
|
3713
|
-
break;
|
|
3752
|
+
if (args[i] != null) break;
|
|
3714
3753
|
}
|
|
3715
3754
|
return args.slice(0, i + 1).map((arg) => arg || `null`);
|
|
3716
3755
|
}
|
|
@@ -3827,16 +3866,21 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3827
3866
|
}
|
|
3828
3867
|
function genCacheExpression(node, context) {
|
|
3829
3868
|
const { push, helper, indent, deindent, newline } = context;
|
|
3869
|
+
const { needPauseTracking, needArraySpread } = node;
|
|
3870
|
+
if (needArraySpread) {
|
|
3871
|
+
push(`[...(`);
|
|
3872
|
+
}
|
|
3830
3873
|
push(`_cache[${node.index}] || (`);
|
|
3831
|
-
if (
|
|
3874
|
+
if (needPauseTracking) {
|
|
3832
3875
|
indent();
|
|
3833
3876
|
push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
|
|
3834
3877
|
newline();
|
|
3878
|
+
push(`(`);
|
|
3835
3879
|
}
|
|
3836
3880
|
push(`_cache[${node.index}] = `);
|
|
3837
3881
|
genNode(node.value, context);
|
|
3838
|
-
if (
|
|
3839
|
-
push(
|
|
3882
|
+
if (needPauseTracking) {
|
|
3883
|
+
push(`).cacheIndex = ${node.index},`);
|
|
3840
3884
|
newline();
|
|
3841
3885
|
push(`${helper(SET_BLOCK_TRACKING)}(1),`);
|
|
3842
3886
|
newline();
|
|
@@ -3844,6 +3888,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3844
3888
|
deindent();
|
|
3845
3889
|
}
|
|
3846
3890
|
push(`)`);
|
|
3891
|
+
if (needArraySpread) {
|
|
3892
|
+
push(`)]`);
|
|
3893
|
+
}
|
|
3847
3894
|
}
|
|
3848
3895
|
|
|
3849
3896
|
const prohibitedKeywordRE = new RegExp(
|
|
@@ -4020,8 +4067,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4020
4067
|
sibling.branches.push(branch);
|
|
4021
4068
|
const onExit = processCodegen && processCodegen(sibling, branch, false);
|
|
4022
4069
|
traverseNode(branch, context);
|
|
4023
|
-
if (onExit)
|
|
4024
|
-
onExit();
|
|
4070
|
+
if (onExit) onExit();
|
|
4025
4071
|
context.currentNode = null;
|
|
4026
4072
|
} else {
|
|
4027
4073
|
context.onError(
|
|
@@ -4090,7 +4136,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4090
4136
|
helper(FRAGMENT),
|
|
4091
4137
|
createObjectExpression([keyProperty]),
|
|
4092
4138
|
children,
|
|
4093
|
-
patchFlag
|
|
4139
|
+
patchFlag,
|
|
4094
4140
|
void 0,
|
|
4095
4141
|
void 0,
|
|
4096
4142
|
true,
|
|
@@ -4143,6 +4189,80 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4143
4189
|
}
|
|
4144
4190
|
}
|
|
4145
4191
|
|
|
4192
|
+
const transformBind = (dir, _node, context) => {
|
|
4193
|
+
const { modifiers, loc } = dir;
|
|
4194
|
+
const arg = dir.arg;
|
|
4195
|
+
let { exp } = dir;
|
|
4196
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4197
|
+
{
|
|
4198
|
+
exp = void 0;
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
if (!exp) {
|
|
4202
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
4203
|
+
context.onError(
|
|
4204
|
+
createCompilerError(
|
|
4205
|
+
52,
|
|
4206
|
+
arg.loc
|
|
4207
|
+
)
|
|
4208
|
+
);
|
|
4209
|
+
return {
|
|
4210
|
+
props: [
|
|
4211
|
+
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4212
|
+
]
|
|
4213
|
+
};
|
|
4214
|
+
}
|
|
4215
|
+
transformBindShorthand(dir);
|
|
4216
|
+
exp = dir.exp;
|
|
4217
|
+
}
|
|
4218
|
+
if (arg.type !== 4) {
|
|
4219
|
+
arg.children.unshift(`(`);
|
|
4220
|
+
arg.children.push(`) || ""`);
|
|
4221
|
+
} else if (!arg.isStatic) {
|
|
4222
|
+
arg.content = `${arg.content} || ""`;
|
|
4223
|
+
}
|
|
4224
|
+
if (modifiers.includes("camel")) {
|
|
4225
|
+
if (arg.type === 4) {
|
|
4226
|
+
if (arg.isStatic) {
|
|
4227
|
+
arg.content = camelize(arg.content);
|
|
4228
|
+
} else {
|
|
4229
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4230
|
+
}
|
|
4231
|
+
} else {
|
|
4232
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4233
|
+
arg.children.push(`)`);
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
if (!context.inSSR) {
|
|
4237
|
+
if (modifiers.includes("prop")) {
|
|
4238
|
+
injectPrefix(arg, ".");
|
|
4239
|
+
}
|
|
4240
|
+
if (modifiers.includes("attr")) {
|
|
4241
|
+
injectPrefix(arg, "^");
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
return {
|
|
4245
|
+
props: [createObjectProperty(arg, exp)]
|
|
4246
|
+
};
|
|
4247
|
+
};
|
|
4248
|
+
const transformBindShorthand = (dir, context) => {
|
|
4249
|
+
const arg = dir.arg;
|
|
4250
|
+
const propName = camelize(arg.content);
|
|
4251
|
+
dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4252
|
+
};
|
|
4253
|
+
const injectPrefix = (arg, prefix) => {
|
|
4254
|
+
if (arg.type === 4) {
|
|
4255
|
+
if (arg.isStatic) {
|
|
4256
|
+
arg.content = prefix + arg.content;
|
|
4257
|
+
} else {
|
|
4258
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4259
|
+
}
|
|
4260
|
+
} else {
|
|
4261
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
4262
|
+
arg.children.push(`)`);
|
|
4263
|
+
}
|
|
4264
|
+
};
|
|
4265
|
+
|
|
4146
4266
|
const transformFor = createStructuralDirectiveTransform(
|
|
4147
4267
|
"for",
|
|
4148
4268
|
(node, dir, context) => {
|
|
@@ -4153,9 +4273,12 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4153
4273
|
]);
|
|
4154
4274
|
const isTemplate = isTemplateNode(node);
|
|
4155
4275
|
const memo = findDir(node, "memo");
|
|
4156
|
-
const keyProp = findProp(node, `key
|
|
4157
|
-
|
|
4158
|
-
|
|
4276
|
+
const keyProp = findProp(node, `key`, false, true);
|
|
4277
|
+
if (keyProp && keyProp.type === 7 && !keyProp.exp) {
|
|
4278
|
+
transformBindShorthand(keyProp);
|
|
4279
|
+
}
|
|
4280
|
+
const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4281
|
+
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4159
4282
|
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
4160
4283
|
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
4161
4284
|
forNode.codegenNode = createVNodeCall(
|
|
@@ -4163,7 +4286,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4163
4286
|
helper(FRAGMENT),
|
|
4164
4287
|
void 0,
|
|
4165
4288
|
renderExp,
|
|
4166
|
-
fragmentFlag
|
|
4289
|
+
fragmentFlag,
|
|
4167
4290
|
void 0,
|
|
4168
4291
|
void 0,
|
|
4169
4292
|
true,
|
|
@@ -4203,7 +4326,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4203
4326
|
helper(FRAGMENT),
|
|
4204
4327
|
keyProperty ? createObjectExpression([keyProperty]) : void 0,
|
|
4205
4328
|
node.children,
|
|
4206
|
-
64
|
|
4329
|
+
64,
|
|
4207
4330
|
void 0,
|
|
4208
4331
|
void 0,
|
|
4209
4332
|
true,
|
|
@@ -4257,8 +4380,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4257
4380
|
renderExp.arguments.push(
|
|
4258
4381
|
loop,
|
|
4259
4382
|
createSimpleExpression(`_cache`),
|
|
4260
|
-
createSimpleExpression(String(context.cached
|
|
4383
|
+
createSimpleExpression(String(context.cached.length))
|
|
4261
4384
|
);
|
|
4385
|
+
context.cached.push(null);
|
|
4262
4386
|
} else {
|
|
4263
4387
|
renderExp.arguments.push(
|
|
4264
4388
|
createFunctionExpression(
|
|
@@ -4304,13 +4428,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4304
4428
|
const onExit = processCodegen && processCodegen(forNode);
|
|
4305
4429
|
return () => {
|
|
4306
4430
|
scopes.vFor--;
|
|
4307
|
-
if (onExit)
|
|
4308
|
-
onExit();
|
|
4431
|
+
if (onExit) onExit();
|
|
4309
4432
|
};
|
|
4310
4433
|
}
|
|
4311
4434
|
function finalizeForParseResult(result, context) {
|
|
4312
|
-
if (result.finalized)
|
|
4313
|
-
return;
|
|
4435
|
+
if (result.finalized) return;
|
|
4314
4436
|
{
|
|
4315
4437
|
validateBrowserExpression(result.source, context);
|
|
4316
4438
|
if (result.key) {
|
|
@@ -4343,8 +4465,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4343
4465
|
function createParamsList(args) {
|
|
4344
4466
|
let i = args.length;
|
|
4345
4467
|
while (i--) {
|
|
4346
|
-
if (args[i])
|
|
4347
|
-
break;
|
|
4468
|
+
if (args[i]) break;
|
|
4348
4469
|
}
|
|
4349
4470
|
return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
|
|
4350
4471
|
}
|
|
@@ -4467,9 +4588,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4467
4588
|
break;
|
|
4468
4589
|
}
|
|
4469
4590
|
}
|
|
4470
|
-
if (prev && isTemplateNode(prev) && findDir(prev,
|
|
4471
|
-
children.splice(i, 1);
|
|
4472
|
-
i--;
|
|
4591
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
|
|
4473
4592
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
4474
4593
|
while (conditional.alternate.type === 19) {
|
|
4475
4594
|
conditional = conditional.alternate;
|
|
@@ -4606,13 +4725,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4606
4725
|
}
|
|
4607
4726
|
break;
|
|
4608
4727
|
case 9:
|
|
4609
|
-
if (hasForwardedSlots(child.branches))
|
|
4610
|
-
return true;
|
|
4728
|
+
if (hasForwardedSlots(child.branches)) return true;
|
|
4611
4729
|
break;
|
|
4612
4730
|
case 10:
|
|
4613
4731
|
case 11:
|
|
4614
|
-
if (hasForwardedSlots(child.children))
|
|
4615
|
-
return true;
|
|
4732
|
+
if (hasForwardedSlots(child.children)) return true;
|
|
4616
4733
|
break;
|
|
4617
4734
|
}
|
|
4618
4735
|
}
|
|
@@ -4637,7 +4754,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4637
4754
|
const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
|
4638
4755
|
let vnodeProps;
|
|
4639
4756
|
let vnodeChildren;
|
|
4640
|
-
let vnodePatchFlag;
|
|
4641
4757
|
let patchFlag = 0;
|
|
4642
4758
|
let vnodeDynamicProps;
|
|
4643
4759
|
let dynamicPropNames;
|
|
@@ -4648,7 +4764,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4648
4764
|
// updates inside get proper isSVG flag at runtime. (#639, #643)
|
|
4649
4765
|
// This is technically web-specific, but splitting the logic out of core
|
|
4650
4766
|
// leads to too much unnecessary complexity.
|
|
4651
|
-
(tag === "svg" || tag === "foreignObject")
|
|
4767
|
+
(tag === "svg" || tag === "foreignObject" || tag === "math")
|
|
4652
4768
|
);
|
|
4653
4769
|
if (props.length > 0) {
|
|
4654
4770
|
const propsBuildResult = buildProps(
|
|
@@ -4708,25 +4824,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4708
4824
|
vnodeChildren = node.children;
|
|
4709
4825
|
}
|
|
4710
4826
|
}
|
|
4711
|
-
if (
|
|
4712
|
-
|
|
4713
|
-
if (patchFlag < 0) {
|
|
4714
|
-
vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
|
4715
|
-
} else {
|
|
4716
|
-
const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
|
|
4717
|
-
vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
|
|
4718
|
-
}
|
|
4719
|
-
}
|
|
4720
|
-
if (dynamicPropNames && dynamicPropNames.length) {
|
|
4721
|
-
vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
|
4722
|
-
}
|
|
4827
|
+
if (dynamicPropNames && dynamicPropNames.length) {
|
|
4828
|
+
vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
|
4723
4829
|
}
|
|
4724
4830
|
node.codegenNode = createVNodeCall(
|
|
4725
4831
|
context,
|
|
4726
4832
|
vnodeTag,
|
|
4727
4833
|
vnodeProps,
|
|
4728
4834
|
vnodeChildren,
|
|
4729
|
-
|
|
4835
|
+
patchFlag === 0 ? void 0 : patchFlag,
|
|
4730
4836
|
vnodeDynamicProps,
|
|
4731
4837
|
vnodeDirectives,
|
|
4732
4838
|
!!shouldUseBlock,
|
|
@@ -4771,8 +4877,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4771
4877
|
}
|
|
4772
4878
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
4773
4879
|
if (builtIn) {
|
|
4774
|
-
if (!ssr)
|
|
4775
|
-
context.helper(builtIn);
|
|
4880
|
+
if (!ssr) context.helper(builtIn);
|
|
4776
4881
|
return builtIn;
|
|
4777
4882
|
}
|
|
4778
4883
|
context.helper(RESOLVE_COMPONENT);
|
|
@@ -4801,8 +4906,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4801
4906
|
);
|
|
4802
4907
|
properties = [];
|
|
4803
4908
|
}
|
|
4804
|
-
if (arg)
|
|
4805
|
-
mergeArgs.push(arg);
|
|
4909
|
+
if (arg) mergeArgs.push(arg);
|
|
4806
4910
|
};
|
|
4807
4911
|
const pushRefVForMarker = () => {
|
|
4808
4912
|
if (context.scopes.vFor > 0) {
|
|
@@ -5139,8 +5243,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5139
5243
|
}
|
|
5140
5244
|
}
|
|
5141
5245
|
const { loc } = dir;
|
|
5142
|
-
if (dir.exp)
|
|
5143
|
-
dirArgs.push(dir.exp);
|
|
5246
|
+
if (dir.exp) dirArgs.push(dir.exp);
|
|
5144
5247
|
if (dir.arg) {
|
|
5145
5248
|
if (!dir.exp) {
|
|
5146
5249
|
dirArgs.push(`void 0`);
|
|
@@ -5170,8 +5273,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5170
5273
|
let propsNamesString = `[`;
|
|
5171
5274
|
for (let i = 0, l = props.length; i < l; i++) {
|
|
5172
5275
|
propsNamesString += JSON.stringify(props[i]);
|
|
5173
|
-
if (i < l - 1)
|
|
5174
|
-
propsNamesString += ", ";
|
|
5276
|
+
if (i < l - 1) propsNamesString += ", ";
|
|
5175
5277
|
}
|
|
5176
5278
|
return propsNamesString + `]`;
|
|
5177
5279
|
}
|
|
@@ -5265,7 +5367,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5265
5367
|
};
|
|
5266
5368
|
}
|
|
5267
5369
|
|
|
5268
|
-
const fnExpRE = /^\s*(
|
|
5370
|
+
const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
5269
5371
|
const transformOn$1 = (dir, node, context, augmentor) => {
|
|
5270
5372
|
const { loc, modifiers, arg } = dir;
|
|
5271
5373
|
if (!dir.exp && !modifiers.length) {
|
|
@@ -5346,75 +5448,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5346
5448
|
return ret;
|
|
5347
5449
|
};
|
|
5348
5450
|
|
|
5349
|
-
const transformBind = (dir, _node, context) => {
|
|
5350
|
-
const { modifiers, loc } = dir;
|
|
5351
|
-
const arg = dir.arg;
|
|
5352
|
-
let { exp } = dir;
|
|
5353
|
-
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
5354
|
-
{
|
|
5355
|
-
exp = void 0;
|
|
5356
|
-
}
|
|
5357
|
-
}
|
|
5358
|
-
if (!exp) {
|
|
5359
|
-
if (arg.type !== 4 || !arg.isStatic) {
|
|
5360
|
-
context.onError(
|
|
5361
|
-
createCompilerError(
|
|
5362
|
-
52,
|
|
5363
|
-
arg.loc
|
|
5364
|
-
)
|
|
5365
|
-
);
|
|
5366
|
-
return {
|
|
5367
|
-
props: [
|
|
5368
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
5369
|
-
]
|
|
5370
|
-
};
|
|
5371
|
-
}
|
|
5372
|
-
const propName = camelize(arg.content);
|
|
5373
|
-
exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
5374
|
-
}
|
|
5375
|
-
if (arg.type !== 4) {
|
|
5376
|
-
arg.children.unshift(`(`);
|
|
5377
|
-
arg.children.push(`) || ""`);
|
|
5378
|
-
} else if (!arg.isStatic) {
|
|
5379
|
-
arg.content = `${arg.content} || ""`;
|
|
5380
|
-
}
|
|
5381
|
-
if (modifiers.includes("camel")) {
|
|
5382
|
-
if (arg.type === 4) {
|
|
5383
|
-
if (arg.isStatic) {
|
|
5384
|
-
arg.content = camelize(arg.content);
|
|
5385
|
-
} else {
|
|
5386
|
-
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
5387
|
-
}
|
|
5388
|
-
} else {
|
|
5389
|
-
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
5390
|
-
arg.children.push(`)`);
|
|
5391
|
-
}
|
|
5392
|
-
}
|
|
5393
|
-
if (!context.inSSR) {
|
|
5394
|
-
if (modifiers.includes("prop")) {
|
|
5395
|
-
injectPrefix(arg, ".");
|
|
5396
|
-
}
|
|
5397
|
-
if (modifiers.includes("attr")) {
|
|
5398
|
-
injectPrefix(arg, "^");
|
|
5399
|
-
}
|
|
5400
|
-
}
|
|
5401
|
-
return {
|
|
5402
|
-
props: [createObjectProperty(arg, exp)]
|
|
5403
|
-
};
|
|
5404
|
-
};
|
|
5405
|
-
const injectPrefix = (arg, prefix) => {
|
|
5406
|
-
if (arg.type === 4) {
|
|
5407
|
-
if (arg.isStatic) {
|
|
5408
|
-
arg.content = prefix + arg.content;
|
|
5409
|
-
} else {
|
|
5410
|
-
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
5411
|
-
}
|
|
5412
|
-
} else {
|
|
5413
|
-
arg.children.unshift(`'${prefix}' + (`);
|
|
5414
|
-
arg.children.push(`)`);
|
|
5415
|
-
}
|
|
5416
|
-
};
|
|
5417
|
-
|
|
5418
5451
|
const transformText = (node, context) => {
|
|
5419
5452
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
5420
5453
|
return () => {
|
|
@@ -5578,8 +5611,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5578
5611
|
}
|
|
5579
5612
|
if (node.type === 5) {
|
|
5580
5613
|
rewriteFilter(node.content, context);
|
|
5581
|
-
}
|
|
5582
|
-
if (node.type === 1) {
|
|
5614
|
+
} else if (node.type === 1) {
|
|
5583
5615
|
node.props.forEach((prop) => {
|
|
5584
5616
|
if (prop.type === 7 && prop.name !== "for" && prop.exp) {
|
|
5585
5617
|
rewriteFilter(prop.exp, context);
|
|
@@ -5593,8 +5625,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5593
5625
|
} else {
|
|
5594
5626
|
for (let i = 0; i < node.children.length; i++) {
|
|
5595
5627
|
const child = node.children[i];
|
|
5596
|
-
if (typeof child !== "object")
|
|
5597
|
-
continue;
|
|
5628
|
+
if (typeof child !== "object") continue;
|
|
5598
5629
|
if (child.type === 4) {
|
|
5599
5630
|
parseFilter(child, context);
|
|
5600
5631
|
} else if (child.type === 8) {
|
|
@@ -5620,17 +5651,13 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5620
5651
|
prev = c;
|
|
5621
5652
|
c = exp.charCodeAt(i);
|
|
5622
5653
|
if (inSingle) {
|
|
5623
|
-
if (c === 39 && prev !== 92)
|
|
5624
|
-
inSingle = false;
|
|
5654
|
+
if (c === 39 && prev !== 92) inSingle = false;
|
|
5625
5655
|
} else if (inDouble) {
|
|
5626
|
-
if (c === 34 && prev !== 92)
|
|
5627
|
-
inDouble = false;
|
|
5656
|
+
if (c === 34 && prev !== 92) inDouble = false;
|
|
5628
5657
|
} else if (inTemplateString) {
|
|
5629
|
-
if (c === 96 && prev !== 92)
|
|
5630
|
-
inTemplateString = false;
|
|
5658
|
+
if (c === 96 && prev !== 92) inTemplateString = false;
|
|
5631
5659
|
} else if (inRegex) {
|
|
5632
|
-
if (c === 47 && prev !== 92)
|
|
5633
|
-
inRegex = false;
|
|
5660
|
+
if (c === 47 && prev !== 92) inRegex = false;
|
|
5634
5661
|
} else if (c === 124 && // pipe
|
|
5635
5662
|
exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
|
|
5636
5663
|
if (expression === void 0) {
|
|
@@ -5674,8 +5701,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5674
5701
|
let p;
|
|
5675
5702
|
for (; j >= 0; j--) {
|
|
5676
5703
|
p = exp.charAt(j);
|
|
5677
|
-
if (p !== " ")
|
|
5678
|
-
break;
|
|
5704
|
+
if (p !== " ") break;
|
|
5679
5705
|
}
|
|
5680
5706
|
if (!p || !validDivisionCharRE.test(p)) {
|
|
5681
5707
|
inRegex = true;
|
|
@@ -5702,6 +5728,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5702
5728
|
expression = wrapFilter(expression, filters[i], context);
|
|
5703
5729
|
}
|
|
5704
5730
|
node.content = expression;
|
|
5731
|
+
node.ast = void 0;
|
|
5705
5732
|
}
|
|
5706
5733
|
}
|
|
5707
5734
|
function wrapFilter(exp, filter, context) {
|
|
@@ -5736,8 +5763,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5736
5763
|
dir.exp,
|
|
5737
5764
|
createFunctionExpression(void 0, codegenNode),
|
|
5738
5765
|
`_cache`,
|
|
5739
|
-
String(context.cached
|
|
5766
|
+
String(context.cached.length)
|
|
5740
5767
|
]);
|
|
5768
|
+
context.cached.push(null);
|
|
5741
5769
|
}
|
|
5742
5770
|
};
|
|
5743
5771
|
}
|
|
@@ -6173,8 +6201,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
6173
6201
|
const transformOn = (dir, node, context) => {
|
|
6174
6202
|
return transformOn$1(dir, node, context, (baseResult) => {
|
|
6175
6203
|
const { modifiers } = dir;
|
|
6176
|
-
if (!modifiers.length)
|
|
6177
|
-
return baseResult;
|
|
6204
|
+
if (!modifiers.length) return baseResult;
|
|
6178
6205
|
let { key, value: handlerExp } = baseResult.props[0];
|
|
6179
6206
|
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
|
6180
6207
|
if (nonKeyModifiers.includes("right")) {
|
|
@@ -6285,12 +6312,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
6285
6312
|
return onlyValidParents[child].has(parent);
|
|
6286
6313
|
}
|
|
6287
6314
|
if (parent in knownInvalidChildren) {
|
|
6288
|
-
if (knownInvalidChildren[parent].has(child))
|
|
6289
|
-
return false;
|
|
6315
|
+
if (knownInvalidChildren[parent].has(child)) return false;
|
|
6290
6316
|
}
|
|
6291
6317
|
if (child in knownInvalidParents) {
|
|
6292
|
-
if (knownInvalidParents[child].has(parent))
|
|
6293
|
-
return false;
|
|
6318
|
+
if (knownInvalidParents[child].has(parent)) return false;
|
|
6294
6319
|
}
|
|
6295
6320
|
return true;
|
|
6296
6321
|
}
|