@vue/compiler-dom 3.6.0-rc.1 → 3.6.0-rc.11
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 +60 -51
- package/dist/compiler-dom.cjs.prod.js +59 -50
- package/dist/compiler-dom.d.ts +10 -11
- package/dist/compiler-dom.esm-browser.js +256 -214
- package/dist/compiler-dom.esm-browser.prod.js +6 -6
- package/dist/compiler-dom.esm-bundler.js +57 -49
- package/dist/compiler-dom.global.js +256 -214
- package/dist/compiler-dom.global.prod.js +6 -6
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-dom v3.6.0-rc.
|
|
2
|
+
* @vue/compiler-dom v3.6.0-rc.11
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* \/\*#\_\_PURE\_\_\*\/
|
|
12
12
|
* So that they can be tree-shaken if necessary.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
15
15
|
function makeMap(str) {
|
|
16
16
|
const map = Object.create(null);
|
|
17
17
|
for (const key of str.split(",")) map[key] = 1;
|
|
@@ -32,8 +32,8 @@ const isArray = Array.isArray;
|
|
|
32
32
|
const isString = (val) => typeof val === "string";
|
|
33
33
|
const isSymbol = (val) => typeof val === "symbol";
|
|
34
34
|
const isObject = (val) => val !== null && typeof val === "object";
|
|
35
|
-
const isReservedProp =
|
|
36
|
-
const isBuiltInDirective =
|
|
35
|
+
const isReservedProp = /*@__PURE__*/ makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted");
|
|
36
|
+
const isBuiltInDirective = /*@__PURE__*/ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
|
|
37
37
|
const cacheStringFunction = (fn) => {
|
|
38
38
|
const cache = Object.create(null);
|
|
39
39
|
return ((str) => {
|
|
@@ -140,10 +140,10 @@ function generateCodeFrame(source, start = 0, end = source.length) {
|
|
|
140
140
|
//#region packages/shared/src/normalizeProp.ts
|
|
141
141
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
142
142
|
const propertyDelimiterRE = /:([^]+)/;
|
|
143
|
-
const styleCommentRE =
|
|
143
|
+
const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
|
|
144
144
|
function parseStringStyle(cssText) {
|
|
145
145
|
const ret = {};
|
|
146
|
-
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
|
146
|
+
cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
|
|
147
147
|
if (item) {
|
|
148
148
|
const tmp = item.split(propertyDelimiterRE);
|
|
149
149
|
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
@@ -161,22 +161,22 @@ const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,tr
|
|
|
161
161
|
* Compiler only.
|
|
162
162
|
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
163
163
|
*/
|
|
164
|
-
const isHTMLTag =
|
|
164
|
+
const isHTMLTag = /*@__PURE__*/ makeMap(HTML_TAGS);
|
|
165
165
|
/**
|
|
166
166
|
* Compiler only.
|
|
167
167
|
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
168
168
|
*/
|
|
169
|
-
const isSVGTag =
|
|
169
|
+
const isSVGTag = /*@__PURE__*/ makeMap(SVG_TAGS);
|
|
170
170
|
/**
|
|
171
171
|
* Compiler only.
|
|
172
172
|
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
173
173
|
*/
|
|
174
|
-
const isMathMLTag =
|
|
174
|
+
const isMathMLTag = /*@__PURE__*/ makeMap(MATH_TAGS);
|
|
175
175
|
/**
|
|
176
176
|
* Compiler only.
|
|
177
177
|
* Do NOT use in runtime code paths unless behind `__DEV__` flag.
|
|
178
178
|
*/
|
|
179
|
-
const isVoidTag =
|
|
179
|
+
const isVoidTag = /*@__PURE__*/ makeMap(VOID_TAGS);
|
|
180
180
|
//#endregion
|
|
181
181
|
//#region packages/compiler-core/src/runtimeHelpers.ts
|
|
182
182
|
const FRAGMENT = Symbol(`Fragment`);
|
|
@@ -721,13 +721,14 @@ var Tokenizer = class {
|
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
stateInterpolationOpen(c) {
|
|
724
|
-
if (c === this.delimiterOpen[this.delimiterIndex])
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
724
|
+
if (c === this.delimiterOpen[this.delimiterIndex]) {
|
|
725
|
+
if (this.delimiterIndex === this.delimiterOpen.length - 1) {
|
|
726
|
+
const start = this.index + 1 - this.delimiterOpen.length;
|
|
727
|
+
if (start > this.sectionStart) this.cbs.ontext(this.sectionStart, start);
|
|
728
|
+
this.state = 3;
|
|
729
|
+
this.sectionStart = start;
|
|
730
|
+
} else this.delimiterIndex++;
|
|
731
|
+
} else if (this.inRCDATA) {
|
|
731
732
|
this.state = 32;
|
|
732
733
|
this.stateInRCDATA(c);
|
|
733
734
|
} else {
|
|
@@ -743,13 +744,14 @@ var Tokenizer = class {
|
|
|
743
744
|
}
|
|
744
745
|
}
|
|
745
746
|
stateInterpolationClose(c) {
|
|
746
|
-
if (c === this.delimiterClose[this.delimiterIndex])
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
747
|
+
if (c === this.delimiterClose[this.delimiterIndex]) {
|
|
748
|
+
if (this.delimiterIndex === this.delimiterClose.length - 1) {
|
|
749
|
+
this.cbs.oninterpolation(this.sectionStart, this.index + 1);
|
|
750
|
+
if (this.inRCDATA) this.state = 32;
|
|
751
|
+
else this.state = 1;
|
|
752
|
+
this.sectionStart = this.index + 1;
|
|
753
|
+
} else this.delimiterIndex++;
|
|
754
|
+
} else {
|
|
753
755
|
this.state = 3;
|
|
754
756
|
this.stateInterpolation(c);
|
|
755
757
|
}
|
|
@@ -864,9 +866,10 @@ var Tokenizer = class {
|
|
|
864
866
|
this.sectionStart = this.index;
|
|
865
867
|
if (this.mode === 0) this.state = 6;
|
|
866
868
|
else if (this.inSFCRoot) this.state = 34;
|
|
867
|
-
else if (!this.inXML)
|
|
868
|
-
|
|
869
|
-
|
|
869
|
+
else if (!this.inXML) {
|
|
870
|
+
if (c === 116) this.state = 30;
|
|
871
|
+
else this.state = c === 115 ? 29 : 6;
|
|
872
|
+
} else this.state = 6;
|
|
870
873
|
} else if (c === 47) this.state = 8;
|
|
871
874
|
else {
|
|
872
875
|
this.state = 1;
|
|
@@ -1219,9 +1222,7 @@ var Tokenizer = class {
|
|
|
1219
1222
|
case 24:
|
|
1220
1223
|
this.stateInProcessingInstruction(c);
|
|
1221
1224
|
break;
|
|
1222
|
-
case 33:
|
|
1223
|
-
this.stateInEntity();
|
|
1224
|
-
break;
|
|
1225
|
+
case 33: this.stateInEntity();
|
|
1225
1226
|
}
|
|
1226
1227
|
this.index++;
|
|
1227
1228
|
}
|
|
@@ -1250,9 +1251,10 @@ var Tokenizer = class {
|
|
|
1250
1251
|
handleTrailingData() {
|
|
1251
1252
|
const endIndex = this.buffer.length;
|
|
1252
1253
|
if (this.sectionStart >= endIndex) return;
|
|
1253
|
-
if (this.state === 28)
|
|
1254
|
-
|
|
1255
|
-
|
|
1254
|
+
if (this.state === 28) {
|
|
1255
|
+
if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, endIndex);
|
|
1256
|
+
else this.cbs.oncomment(this.sectionStart, endIndex);
|
|
1257
|
+
} else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) {} else this.cbs.ontext(this.sectionStart, endIndex);
|
|
1256
1258
|
}
|
|
1257
1259
|
emitCodePoint(cp, consumed) {}
|
|
1258
1260
|
};
|
|
@@ -1585,9 +1587,7 @@ function extractIdentifiers(param, nodes = []) {
|
|
|
1585
1587
|
case "RestElement":
|
|
1586
1588
|
extractIdentifiers(param.argument, nodes);
|
|
1587
1589
|
break;
|
|
1588
|
-
case "AssignmentPattern":
|
|
1589
|
-
extractIdentifiers(param.left, nodes);
|
|
1590
|
-
break;
|
|
1590
|
+
case "AssignmentPattern": extractIdentifiers(param.left, nodes);
|
|
1591
1591
|
}
|
|
1592
1592
|
return nodes;
|
|
1593
1593
|
}
|
|
@@ -1723,12 +1723,10 @@ const isMemberExpressionBrowser = (exp) => {
|
|
|
1723
1723
|
if (!--currentOpenParensCount) state = stateStack.pop();
|
|
1724
1724
|
}
|
|
1725
1725
|
break;
|
|
1726
|
-
case 3:
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
}
|
|
1731
|
-
break;
|
|
1726
|
+
case 3: if (char === currentStringType) {
|
|
1727
|
+
state = stateStack.pop();
|
|
1728
|
+
currentStringType = null;
|
|
1729
|
+
}
|
|
1732
1730
|
}
|
|
1733
1731
|
}
|
|
1734
1732
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
@@ -1799,7 +1797,7 @@ function isTemplateNode(node) {
|
|
|
1799
1797
|
function isSlotOutlet(node) {
|
|
1800
1798
|
return node.type === 1 && node.tagType === 2;
|
|
1801
1799
|
}
|
|
1802
|
-
const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
|
1800
|
+
const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
|
1803
1801
|
function getUnnormalizedProps(props, callPath = []) {
|
|
1804
1802
|
if (props && !isString(props) && props.type === 14) {
|
|
1805
1803
|
const callee = props.callee;
|
|
@@ -1842,9 +1840,10 @@ function injectProp(node, prop, context) {
|
|
|
1842
1840
|
propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [createObjectExpression([prop]), props]);
|
|
1843
1841
|
if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) parentCall = callPath[callPath.length - 2];
|
|
1844
1842
|
}
|
|
1845
|
-
if (node.type === 13)
|
|
1846
|
-
|
|
1847
|
-
|
|
1843
|
+
if (node.type === 13) {
|
|
1844
|
+
if (parentCall) parentCall.arguments[0] = propsWithInjection;
|
|
1845
|
+
else node.props = propsWithInjection;
|
|
1846
|
+
} else if (parentCall) parentCall.arguments[0] = propsWithInjection;
|
|
1848
1847
|
else node.arguments[2] = propsWithInjection;
|
|
1849
1848
|
}
|
|
1850
1849
|
function injectSlotKey(node, prop) {
|
|
@@ -2159,10 +2158,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2159
2158
|
case 18:
|
|
2160
2159
|
case 19:
|
|
2161
2160
|
case 20:
|
|
2162
|
-
case 21:
|
|
2163
|
-
emitError(9, end);
|
|
2164
|
-
break;
|
|
2165
|
-
default: break;
|
|
2161
|
+
case 21: emitError(9, end);
|
|
2166
2162
|
}
|
|
2167
2163
|
for (let index = 0; index < stack.length; index++) {
|
|
2168
2164
|
onCloseTag(stack[index], end - 1);
|
|
@@ -2312,7 +2308,7 @@ function backTrack(index, c) {
|
|
|
2312
2308
|
while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
|
|
2313
2309
|
return i;
|
|
2314
2310
|
}
|
|
2315
|
-
const specialTemplateDir = new Set([
|
|
2311
|
+
const specialTemplateDir = /* @__PURE__ */ new Set([
|
|
2316
2312
|
"if",
|
|
2317
2313
|
"else",
|
|
2318
2314
|
"else-if",
|
|
@@ -2348,16 +2344,18 @@ function condenseWhitespace(nodes) {
|
|
|
2348
2344
|
let removedWhitespace = false;
|
|
2349
2345
|
for (let i = 0; i < nodes.length; i++) {
|
|
2350
2346
|
const node = nodes[i];
|
|
2351
|
-
if (node.type === 2)
|
|
2352
|
-
if (
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2347
|
+
if (node.type === 2) {
|
|
2348
|
+
if (!inPre) {
|
|
2349
|
+
if (isAllWhitespace(node.content)) {
|
|
2350
|
+
const prev = nodes[i - 1] && nodes[i - 1].type;
|
|
2351
|
+
const next = nodes[i + 1] && nodes[i + 1].type;
|
|
2352
|
+
if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
|
2353
|
+
removedWhitespace = true;
|
|
2354
|
+
nodes[i] = null;
|
|
2355
|
+
} else node.content = " ";
|
|
2356
|
+
} else if (shouldCondense) node.content = condense(node.content);
|
|
2357
|
+
} else node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
2358
|
+
}
|
|
2361
2359
|
}
|
|
2362
2360
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
2363
2361
|
}
|
|
@@ -2618,7 +2616,7 @@ function getConstantType(node, context) {
|
|
|
2618
2616
|
default: return 0;
|
|
2619
2617
|
}
|
|
2620
2618
|
}
|
|
2621
|
-
const allowHoistedHelperSet = new Set([
|
|
2619
|
+
const allowHoistedHelperSet = /* @__PURE__ */ new Set([
|
|
2622
2620
|
NORMALIZE_CLASS,
|
|
2623
2621
|
NORMALIZE_STYLE,
|
|
2624
2622
|
NORMALIZE_PROPS,
|
|
@@ -2662,7 +2660,7 @@ function getSelfName(filename) {
|
|
|
2662
2660
|
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
2663
2661
|
return nameMatch ? capitalize(camelize(nameMatch[1])) : null;
|
|
2664
2662
|
}
|
|
2665
|
-
function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false,
|
|
2663
|
+
function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
|
|
2666
2664
|
const context = {
|
|
2667
2665
|
filename,
|
|
2668
2666
|
selfName: getSelfName(filename),
|
|
@@ -2684,7 +2682,6 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
2684
2682
|
bindingMetadata,
|
|
2685
2683
|
inline,
|
|
2686
2684
|
isTS,
|
|
2687
|
-
eventDelegation,
|
|
2688
2685
|
onError,
|
|
2689
2686
|
onWarn,
|
|
2690
2687
|
compatConfig,
|
|
@@ -2777,7 +2774,7 @@ function transform(root, options) {
|
|
|
2777
2774
|
traverseNode(root, context);
|
|
2778
2775
|
if (options.hoistStatic) cacheStatic(root, context);
|
|
2779
2776
|
if (!options.ssr) createRootCodegen(root, context);
|
|
2780
|
-
root.helpers = new Set([...context.helpers.keys()]);
|
|
2777
|
+
root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
|
|
2781
2778
|
root.components = [...context.components];
|
|
2782
2779
|
root.directives = [...context.directives];
|
|
2783
2780
|
root.imports = context.imports;
|
|
@@ -2824,8 +2821,10 @@ function traverseNode(node, context) {
|
|
|
2824
2821
|
const exitFns = [];
|
|
2825
2822
|
for (let i = 0; i < nodeTransforms.length; i++) {
|
|
2826
2823
|
const onExit = nodeTransforms[i](node, context);
|
|
2827
|
-
if (onExit)
|
|
2828
|
-
|
|
2824
|
+
if (onExit) {
|
|
2825
|
+
if (isArray(onExit)) exitFns.push(...onExit);
|
|
2826
|
+
else exitFns.push(onExit);
|
|
2827
|
+
}
|
|
2829
2828
|
if (!context.currentNode) return;
|
|
2830
2829
|
else node = context.currentNode;
|
|
2831
2830
|
}
|
|
@@ -2842,9 +2841,7 @@ function traverseNode(node, context) {
|
|
|
2842
2841
|
case 10:
|
|
2843
2842
|
case 11:
|
|
2844
2843
|
case 1:
|
|
2845
|
-
case 0:
|
|
2846
|
-
traverseChildren(node, context);
|
|
2847
|
-
break;
|
|
2844
|
+
case 0: traverseChildren(node, context);
|
|
2848
2845
|
}
|
|
2849
2846
|
context.currentNode = node;
|
|
2850
2847
|
let i = exitFns.length;
|
|
@@ -3050,10 +3047,12 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
3050
3047
|
if (isString(node)) push(node, -3);
|
|
3051
3048
|
else if (isArray(node)) genNodeListAsArray(node, context);
|
|
3052
3049
|
else genNode(node, context);
|
|
3053
|
-
if (i < nodes.length - 1)
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3050
|
+
if (i < nodes.length - 1) {
|
|
3051
|
+
if (multilines) {
|
|
3052
|
+
comma && push(",");
|
|
3053
|
+
newline();
|
|
3054
|
+
} else comma && push(", ");
|
|
3055
|
+
}
|
|
3057
3056
|
}
|
|
3058
3057
|
}
|
|
3059
3058
|
function genNode(node, context) {
|
|
@@ -3165,8 +3164,10 @@ function genVNodeCall(node, context) {
|
|
|
3165
3164
|
const { push, helper, pure } = context;
|
|
3166
3165
|
const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
|
|
3167
3166
|
let patchFlagString;
|
|
3168
|
-
if (patchFlag)
|
|
3169
|
-
|
|
3167
|
+
if (patchFlag) {
|
|
3168
|
+
if (patchFlag < 0) patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
|
3169
|
+
else patchFlagString = patchFlag + ` /* ${Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `)} */`;
|
|
3170
|
+
}
|
|
3170
3171
|
if (directives) push(helper(WITH_DIRECTIVES) + `(`);
|
|
3171
3172
|
if (isBlock) push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
|
|
3172
3173
|
if (pure) push(PURE_ANNOTATION);
|
|
@@ -3328,7 +3329,7 @@ function validateBrowserExpression(node, context, asParams = false, asRawStateme
|
|
|
3328
3329
|
}
|
|
3329
3330
|
//#endregion
|
|
3330
3331
|
//#region packages/compiler-core/src/transforms/transformExpression.ts
|
|
3331
|
-
const isLiteralWhitelisted =
|
|
3332
|
+
const isLiteralWhitelisted = /*@__PURE__*/ makeMap("true,false,null,this");
|
|
3332
3333
|
const transformExpression = (node, context) => {
|
|
3333
3334
|
if (node.type === 5) node.content = processExpression(node.content, context);
|
|
3334
3335
|
else if (node.type === 1) {
|
|
@@ -3441,16 +3442,17 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3441
3442
|
const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2));
|
|
3442
3443
|
const { children } = branch;
|
|
3443
3444
|
const firstChild = children[0];
|
|
3444
|
-
if (children.length !== 1 || firstChild.type !== 1)
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3445
|
+
if (children.length !== 1 || firstChild.type !== 1) {
|
|
3446
|
+
if (children.length === 1 && firstChild.type === 11) {
|
|
3447
|
+
const vnodeCall = firstChild.codegenNode;
|
|
3448
|
+
injectProp(vnodeCall, keyProperty, context);
|
|
3449
|
+
return vnodeCall;
|
|
3450
|
+
} else {
|
|
3451
|
+
let patchFlag = 64;
|
|
3452
|
+
if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) patchFlag |= 2048;
|
|
3453
|
+
return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag, void 0, void 0, true, false, false, branch.loc);
|
|
3454
|
+
}
|
|
3448
3455
|
} else {
|
|
3449
|
-
let patchFlag = 64;
|
|
3450
|
-
if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) patchFlag |= 2048;
|
|
3451
|
-
return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag, void 0, void 0, true, false, false, branch.loc);
|
|
3452
|
-
}
|
|
3453
|
-
else {
|
|
3454
3456
|
const ret = firstChild.codegenNode;
|
|
3455
3457
|
const vnodeCall = getMemoedVNodeCall(ret);
|
|
3456
3458
|
if (vnodeCall.type === 13) convertToBlock(vnodeCall, context);
|
|
@@ -3471,9 +3473,10 @@ function isSameKey(a, b) {
|
|
|
3471
3473
|
return true;
|
|
3472
3474
|
}
|
|
3473
3475
|
function getParentCondition(node) {
|
|
3474
|
-
while (true) if (node.type === 19)
|
|
3475
|
-
|
|
3476
|
-
|
|
3476
|
+
while (true) if (node.type === 19) {
|
|
3477
|
+
if (node.alternate.type === 19) node = node.alternate;
|
|
3478
|
+
else return node;
|
|
3479
|
+
} else if (node.type === 20) node = node.value;
|
|
3477
3480
|
}
|
|
3478
3481
|
//#endregion
|
|
3479
3482
|
//#region packages/compiler-core/src/transforms/vFor.ts
|
|
@@ -3511,15 +3514,24 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
|
|
|
3511
3514
|
else {
|
|
3512
3515
|
childBlock = children[0].codegenNode;
|
|
3513
3516
|
if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3517
|
+
const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
|
|
3518
|
+
if (childBlock.isBlock !== shouldUseBlock) {
|
|
3519
|
+
if (childBlock.isBlock) {
|
|
3520
|
+
removeHelper(OPEN_BLOCK);
|
|
3521
|
+
removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
|
3522
|
+
} else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
|
3523
|
+
}
|
|
3524
|
+
childBlock.isBlock = shouldUseBlock;
|
|
3519
3525
|
if (childBlock.isBlock) {
|
|
3520
3526
|
helper(OPEN_BLOCK);
|
|
3521
3527
|
helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
|
3522
|
-
} else
|
|
3528
|
+
} else {
|
|
3529
|
+
helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
|
3530
|
+
if (childBlock.needsPatch) {
|
|
3531
|
+
var _childBlock$patchFlag;
|
|
3532
|
+
childBlock.patchFlag = ((_childBlock$patchFlag = childBlock.patchFlag) !== null && _childBlock$patchFlag !== void 0 ? _childBlock$patchFlag : 0) | 512;
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3523
3535
|
}
|
|
3524
3536
|
if (memo) {
|
|
3525
3537
|
const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
|
|
@@ -3710,8 +3722,10 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3710
3722
|
return createObjectProperty(`default`, fn);
|
|
3711
3723
|
};
|
|
3712
3724
|
if (!hasTemplateSlots) slotsProperties.push(buildDefaultSlotProperty(void 0, children));
|
|
3713
|
-
else if (implicitDefaultChildren.length && !implicitDefaultChildren.every(isWhitespaceText))
|
|
3714
|
-
|
|
3725
|
+
else if (implicitDefaultChildren.length && !implicitDefaultChildren.every(isWhitespaceText)) {
|
|
3726
|
+
if (hasNamedDefaultSlot) context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
|
|
3727
|
+
else slotsProperties.push(buildDefaultSlotProperty(void 0, implicitDefaultChildren));
|
|
3728
|
+
}
|
|
3715
3729
|
}
|
|
3716
3730
|
const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
|
|
3717
3731
|
let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`, createSimpleExpression(slotFlag + ` /* ${slotFlagsText[slotFlag]} */`, false))), loc);
|
|
@@ -3737,10 +3751,7 @@ function hasForwardedSlots(children) {
|
|
|
3737
3751
|
if (hasForwardedSlots(child.branches)) return true;
|
|
3738
3752
|
break;
|
|
3739
3753
|
case 10:
|
|
3740
|
-
case 11:
|
|
3741
|
-
if (hasForwardedSlots(child.children)) return true;
|
|
3742
|
-
break;
|
|
3743
|
-
default: break;
|
|
3754
|
+
case 11: if (hasForwardedSlots(child.children)) return true;
|
|
3744
3755
|
}
|
|
3745
3756
|
}
|
|
3746
3757
|
return false;
|
|
@@ -3762,12 +3773,16 @@ const transformElement = (node, context) => {
|
|
|
3762
3773
|
let vnodeDynamicProps;
|
|
3763
3774
|
let dynamicPropNames;
|
|
3764
3775
|
let vnodeDirectives;
|
|
3776
|
+
let needsPatch = false;
|
|
3777
|
+
let isBlockRequired = false;
|
|
3765
3778
|
let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && (tag === "svg" || tag === "foreignObject" || tag === "math");
|
|
3766
3779
|
if (props.length > 0) {
|
|
3767
3780
|
const propsBuildResult = buildProps(node, context, void 0, isComponent, isDynamicComponent);
|
|
3768
3781
|
vnodeProps = propsBuildResult.props;
|
|
3769
3782
|
patchFlag = propsBuildResult.patchFlag;
|
|
3770
3783
|
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
3784
|
+
needsPatch = propsBuildResult.needsPatch;
|
|
3785
|
+
isBlockRequired = propsBuildResult.isBlockRequired;
|
|
3771
3786
|
const directives = propsBuildResult.directives;
|
|
3772
3787
|
vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
|
|
3773
3788
|
if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
|
|
@@ -3796,7 +3811,10 @@ const transformElement = (node, context) => {
|
|
|
3796
3811
|
} else vnodeChildren = node.children;
|
|
3797
3812
|
}
|
|
3798
3813
|
if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
|
3799
|
-
node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
|
|
3814
|
+
const vnodeCall = node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
|
|
3815
|
+
needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
|
|
3816
|
+
if (needsPatch) vnodeCall.needsPatch = true;
|
|
3817
|
+
if (isBlockRequired) vnodeCall.isBlockRequired = true;
|
|
3800
3818
|
};
|
|
3801
3819
|
};
|
|
3802
3820
|
function resolveComponentType(node, context, ssr = false) {
|
|
@@ -3830,6 +3848,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3830
3848
|
const runtimeDirectives = [];
|
|
3831
3849
|
const hasChildren = children.length > 0;
|
|
3832
3850
|
let shouldUseBlock = false;
|
|
3851
|
+
let isBlockRequired = false;
|
|
3833
3852
|
let patchFlag = 0;
|
|
3834
3853
|
let hasRef = false;
|
|
3835
3854
|
let hasClassBinding = false;
|
|
@@ -3854,12 +3873,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3854
3873
|
const isEventHandler = isOn(name);
|
|
3855
3874
|
if (isEventHandler && (!isComponent || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp(name)) hasHydrationEventBinding = true;
|
|
3856
3875
|
if (isEventHandler && isReservedProp(name)) hasVnodeHook = true;
|
|
3876
|
+
if (name === "ref") hasRef = true;
|
|
3857
3877
|
if (isEventHandler && value.type === 14) value = value.arguments[0];
|
|
3858
3878
|
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
|
|
3859
|
-
if (name === "
|
|
3860
|
-
else if (name === "class") hasClassBinding = true;
|
|
3879
|
+
if (name === "class") hasClassBinding = true;
|
|
3861
3880
|
else if (name === "style") hasStyleBinding = true;
|
|
3862
|
-
else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
3881
|
+
else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
3863
3882
|
if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
3864
3883
|
} else hasDynamicKeys = true;
|
|
3865
3884
|
};
|
|
@@ -3885,33 +3904,38 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3885
3904
|
if (name === "once" || name === "memo") continue;
|
|
3886
3905
|
if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) continue;
|
|
3887
3906
|
if (isVOn && ssr) continue;
|
|
3888
|
-
if (isVBind && isStaticArgOf(arg, "key")
|
|
3907
|
+
if (isVBind && isStaticArgOf(arg, "key")) shouldUseBlock = true;
|
|
3908
|
+
if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
|
|
3909
|
+
shouldUseBlock = true;
|
|
3910
|
+
isBlockRequired = true;
|
|
3911
|
+
}
|
|
3889
3912
|
if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
|
|
3890
3913
|
if (!arg && (isVBind || isVOn)) {
|
|
3891
3914
|
hasDynamicKeys = true;
|
|
3892
|
-
if (exp)
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
if (
|
|
3896
|
-
if (
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
+
if (exp) {
|
|
3916
|
+
if (isVBind) {
|
|
3917
|
+
pushMergeArg();
|
|
3918
|
+
if (mergeArgs.some((arg) => {
|
|
3919
|
+
if (arg.type === 15) return arg.properties.some(({ key }) => {
|
|
3920
|
+
if (key.type !== 4 || !key.isStatic) return true;
|
|
3921
|
+
return key.content !== "class" && key.content !== "style" && !isOn(key.content);
|
|
3922
|
+
});
|
|
3923
|
+
else return true;
|
|
3924
|
+
})) checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context, loc);
|
|
3925
|
+
if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
|
|
3926
|
+
mergeArgs.unshift(exp);
|
|
3927
|
+
continue;
|
|
3928
|
+
}
|
|
3929
|
+
pushRefVForMarker();
|
|
3930
|
+
pushMergeArg();
|
|
3931
|
+
mergeArgs.push(exp);
|
|
3932
|
+
} else pushMergeArg({
|
|
3933
|
+
type: 14,
|
|
3934
|
+
loc,
|
|
3935
|
+
callee: context.helper(TO_HANDLERS),
|
|
3936
|
+
arguments: isComponent ? [exp] : [exp, `true`]
|
|
3937
|
+
});
|
|
3938
|
+
} else context.onError(createCompilerError(isVBind ? 34 : 35, loc));
|
|
3915
3939
|
continue;
|
|
3916
3940
|
}
|
|
3917
3941
|
if (isVBind && modifiers.some((mod) => mod.content === "prop")) patchFlag |= 32;
|
|
@@ -3927,7 +3951,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3927
3951
|
}
|
|
3928
3952
|
} else if (!isBuiltInDirective(name)) {
|
|
3929
3953
|
runtimeDirectives.push(prop);
|
|
3930
|
-
if (hasChildren)
|
|
3954
|
+
if (hasChildren) {
|
|
3955
|
+
shouldUseBlock = true;
|
|
3956
|
+
isBlockRequired = true;
|
|
3957
|
+
}
|
|
3931
3958
|
}
|
|
3932
3959
|
}
|
|
3933
3960
|
}
|
|
@@ -3944,7 +3971,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3944
3971
|
if (dynamicPropNames.length) patchFlag |= 8;
|
|
3945
3972
|
if (hasHydrationEventBinding) patchFlag |= 32;
|
|
3946
3973
|
}
|
|
3947
|
-
|
|
3974
|
+
const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
|
|
3975
|
+
if (!shouldUseBlock && needsPatch) patchFlag |= 512;
|
|
3948
3976
|
if (!context.inSSR && propsExpression) switch (propsExpression.type) {
|
|
3949
3977
|
case 15:
|
|
3950
3978
|
let classKeyIndex = -1;
|
|
@@ -3965,16 +3993,16 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3965
3993
|
} else propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
|
|
3966
3994
|
break;
|
|
3967
3995
|
case 14: break;
|
|
3968
|
-
default:
|
|
3969
|
-
propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
|
|
3970
|
-
break;
|
|
3996
|
+
default: propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
|
|
3971
3997
|
}
|
|
3972
3998
|
return {
|
|
3973
3999
|
props: propsExpression,
|
|
3974
4000
|
directives: runtimeDirectives,
|
|
3975
4001
|
patchFlag,
|
|
3976
4002
|
dynamicPropNames,
|
|
3977
|
-
shouldUseBlock
|
|
4003
|
+
shouldUseBlock,
|
|
4004
|
+
needsPatch,
|
|
4005
|
+
isBlockRequired
|
|
3978
4006
|
};
|
|
3979
4007
|
}
|
|
3980
4008
|
function dedupeProperties(properties) {
|
|
@@ -4071,10 +4099,12 @@ function processSlotOutlet(node, context) {
|
|
|
4071
4099
|
for (let i = 0; i < node.props.length; i++) {
|
|
4072
4100
|
const p = node.props[i];
|
|
4073
4101
|
if (p.type === 6) {
|
|
4074
|
-
if (p.value)
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4102
|
+
if (p.value) {
|
|
4103
|
+
if (p.name === "name") slotName = JSON.stringify(p.value.content);
|
|
4104
|
+
else {
|
|
4105
|
+
p.name = camelize(p.name);
|
|
4106
|
+
nonNameProps.push(p);
|
|
4107
|
+
}
|
|
4078
4108
|
}
|
|
4079
4109
|
} else if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
|
|
4080
4110
|
if (p.exp) slotName = p.exp;
|
|
@@ -4100,17 +4130,18 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
4100
4130
|
const { loc, modifiers, arg } = dir;
|
|
4101
4131
|
if (!dir.exp && !modifiers.length) context.onError(createCompilerError(35, loc));
|
|
4102
4132
|
let eventName;
|
|
4103
|
-
if (arg.type === 4)
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4133
|
+
if (arg.type === 4) {
|
|
4134
|
+
if (arg.isStatic) {
|
|
4135
|
+
let rawName = arg.content;
|
|
4136
|
+
if (rawName.startsWith("vnode")) context.onError(createCompilerError(52, arg.loc));
|
|
4137
|
+
if (rawName.startsWith("vue:")) rawName = `vnode-${rawName.slice(4)}`;
|
|
4138
|
+
eventName = createSimpleExpression(node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? toHandlerKey(camelize(rawName)) : `on:${rawName}`, true, arg.loc);
|
|
4139
|
+
} else eventName = createCompoundExpression([
|
|
4140
|
+
`${context.helperString(TO_HANDLER_KEY)}(`,
|
|
4141
|
+
arg,
|
|
4142
|
+
`)`
|
|
4143
|
+
]);
|
|
4144
|
+
} else {
|
|
4114
4145
|
eventName = arg;
|
|
4115
4146
|
eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
|
|
4116
4147
|
eventName.children.push(`)`);
|
|
@@ -4146,11 +4177,14 @@ const transformBind = (dir, _node, context) => {
|
|
|
4146
4177
|
arg.children.unshift(`(`);
|
|
4147
4178
|
arg.children.push(`) || ""`);
|
|
4148
4179
|
} else if (!arg.isStatic) arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
4149
|
-
if (modifiers.some((mod) => mod.content === "camel"))
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4180
|
+
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
4181
|
+
if (arg.type === 4) {
|
|
4182
|
+
if (arg.isStatic) arg.content = camelize(arg.content);
|
|
4183
|
+
else arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4184
|
+
} else {
|
|
4185
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4186
|
+
arg.children.push(`)`);
|
|
4187
|
+
}
|
|
4154
4188
|
}
|
|
4155
4189
|
if (!context.inSSR) {
|
|
4156
4190
|
if (modifiers.some((mod) => mod.content === "prop")) injectPrefix(arg, ".");
|
|
@@ -4159,9 +4193,10 @@ const transformBind = (dir, _node, context) => {
|
|
|
4159
4193
|
return { props: [createObjectProperty(arg, exp)] };
|
|
4160
4194
|
};
|
|
4161
4195
|
const injectPrefix = (arg, prefix) => {
|
|
4162
|
-
if (arg.type === 4)
|
|
4163
|
-
|
|
4164
|
-
|
|
4196
|
+
if (arg.type === 4) {
|
|
4197
|
+
if (arg.isStatic) arg.content = prefix + arg.content;
|
|
4198
|
+
else arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4199
|
+
} else {
|
|
4165
4200
|
arg.children.unshift(`'${prefix}' + (`);
|
|
4166
4201
|
arg.children.push(`)`);
|
|
4167
4202
|
}
|
|
@@ -4308,11 +4343,12 @@ function parseFilter(node, context) {
|
|
|
4308
4343
|
if (c === 96 && prev !== 92) inTemplateString = false;
|
|
4309
4344
|
} else if (inRegex) {
|
|
4310
4345
|
if (c === 47 && prev !== 92) inRegex = false;
|
|
4311
|
-
} else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren)
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4346
|
+
} else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
|
|
4347
|
+
if (expression === void 0) {
|
|
4348
|
+
lastFilterIndex = i + 1;
|
|
4349
|
+
expression = exp.slice(0, i).trim();
|
|
4350
|
+
} else pushFilter();
|
|
4351
|
+
} else {
|
|
4316
4352
|
switch (c) {
|
|
4317
4353
|
case 34:
|
|
4318
4354
|
inDouble = true;
|
|
@@ -4338,9 +4374,7 @@ function parseFilter(node, context) {
|
|
|
4338
4374
|
case 123:
|
|
4339
4375
|
curly++;
|
|
4340
4376
|
break;
|
|
4341
|
-
case 125:
|
|
4342
|
-
curly--;
|
|
4343
|
-
break;
|
|
4377
|
+
case 125: curly--;
|
|
4344
4378
|
}
|
|
4345
4379
|
if (c === 47) {
|
|
4346
4380
|
let j = i - 1;
|
|
@@ -4656,9 +4690,7 @@ const transformModel$1 = (dir, node, context) => {
|
|
|
4656
4690
|
isInvalidType = true;
|
|
4657
4691
|
context.onError(createDOMCompilerError(60, dir.loc));
|
|
4658
4692
|
break;
|
|
4659
|
-
default:
|
|
4660
|
-
checkDuplicatedValue();
|
|
4661
|
-
break;
|
|
4693
|
+
default: checkDuplicatedValue();
|
|
4662
4694
|
}
|
|
4663
4695
|
} else if (hasDynamicKeyVBind(node)) directiveToUse = V_MODEL_DYNAMIC;
|
|
4664
4696
|
else checkDuplicatedValue();
|
|
@@ -4671,27 +4703,37 @@ const transformModel$1 = (dir, node, context) => {
|
|
|
4671
4703
|
};
|
|
4672
4704
|
//#endregion
|
|
4673
4705
|
//#region packages/compiler-dom/src/transforms/vOn.ts
|
|
4674
|
-
const isEventOptionModifier =
|
|
4675
|
-
const isNonKeyModifier =
|
|
4676
|
-
const maybeKeyModifier =
|
|
4677
|
-
const isKeyboardEvent =
|
|
4706
|
+
const isEventOptionModifier = /*@__PURE__*/ makeMap(`passive,once,capture`);
|
|
4707
|
+
const isNonKeyModifier = /*@__PURE__*/ makeMap("stop,prevent,self,ctrl,shift,alt,meta,exact,middle");
|
|
4708
|
+
const maybeKeyModifier = /*@__PURE__*/ makeMap("left,right");
|
|
4709
|
+
const isKeyboardEvent = /*@__PURE__*/ makeMap(`onkeyup,onkeydown,onkeypress`);
|
|
4678
4710
|
const resolveModifiers = (key, modifiers, context, loc) => {
|
|
4679
4711
|
const keyModifiers = [];
|
|
4680
4712
|
const nonKeyModifiers = [];
|
|
4681
4713
|
const eventOptionModifiers = [];
|
|
4682
4714
|
for (let i = 0; i < modifiers.length; i++) {
|
|
4683
4715
|
const modifier = modifiers[i].content;
|
|
4716
|
+
if (modifier === "delegate") {
|
|
4717
|
+
if (context) {
|
|
4718
|
+
const error = /* @__PURE__ */ new SyntaxError(`.delegate modifier is only supported in Vapor components.`);
|
|
4719
|
+
error.loc = modifiers[i].loc;
|
|
4720
|
+
context.onWarn(error);
|
|
4721
|
+
}
|
|
4722
|
+
continue;
|
|
4723
|
+
}
|
|
4684
4724
|
if (modifier === "native" && context && checkCompatEnabled("COMPILER_V_ON_NATIVE", context, loc)) eventOptionModifiers.push(modifier);
|
|
4685
4725
|
else if (isEventOptionModifier(modifier)) eventOptionModifiers.push(modifier);
|
|
4686
4726
|
else {
|
|
4687
4727
|
const keyString = isString(key) ? key : isStaticExp(key) ? key.content : null;
|
|
4688
|
-
if (maybeKeyModifier(modifier))
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4728
|
+
if (maybeKeyModifier(modifier)) {
|
|
4729
|
+
if (keyString) {
|
|
4730
|
+
if (isKeyboardEvent(keyString.toLowerCase())) keyModifiers.push(modifier);
|
|
4731
|
+
else nonKeyModifiers.push(modifier);
|
|
4732
|
+
} else {
|
|
4733
|
+
keyModifiers.push(modifier);
|
|
4734
|
+
nonKeyModifiers.push(modifier);
|
|
4735
|
+
}
|
|
4736
|
+
} else if (isNonKeyModifier(modifier)) nonKeyModifiers.push(modifier);
|
|
4695
4737
|
else keyModifiers.push(modifier);
|
|
4696
4738
|
}
|
|
4697
4739
|
}
|
|
@@ -4806,7 +4848,7 @@ function isValidHTMLNesting(parent, child) {
|
|
|
4806
4848
|
}
|
|
4807
4849
|
return true;
|
|
4808
4850
|
}
|
|
4809
|
-
const headings = new Set([
|
|
4851
|
+
const headings = /* @__PURE__ */ new Set([
|
|
4810
4852
|
"h1",
|
|
4811
4853
|
"h2",
|
|
4812
4854
|
"h3",
|
|
@@ -4818,7 +4860,7 @@ const emptySet = /* @__PURE__ */ new Set([]);
|
|
|
4818
4860
|
/**
|
|
4819
4861
|
* maps element to set of elements that can be it's children, no other */
|
|
4820
4862
|
const onlyValidChildren = {
|
|
4821
|
-
head: new Set([
|
|
4863
|
+
head: /* @__PURE__ */ new Set([
|
|
4822
4864
|
"base",
|
|
4823
4865
|
"basefront",
|
|
4824
4866
|
"bgsound",
|
|
@@ -4831,24 +4873,24 @@ const onlyValidChildren = {
|
|
|
4831
4873
|
"script",
|
|
4832
4874
|
"template"
|
|
4833
4875
|
]),
|
|
4834
|
-
optgroup: new Set(["option"]),
|
|
4835
|
-
select: new Set([
|
|
4876
|
+
optgroup: /* @__PURE__ */ new Set(["option"]),
|
|
4877
|
+
select: /* @__PURE__ */ new Set([
|
|
4836
4878
|
"optgroup",
|
|
4837
4879
|
"option",
|
|
4838
4880
|
"hr"
|
|
4839
4881
|
]),
|
|
4840
|
-
table: new Set([
|
|
4882
|
+
table: /* @__PURE__ */ new Set([
|
|
4841
4883
|
"caption",
|
|
4842
4884
|
"colgroup",
|
|
4843
4885
|
"tbody",
|
|
4844
4886
|
"tfoot",
|
|
4845
4887
|
"thead"
|
|
4846
4888
|
]),
|
|
4847
|
-
tr: new Set(["td", "th"]),
|
|
4848
|
-
colgroup: new Set(["col"]),
|
|
4849
|
-
tbody: new Set(["tr"]),
|
|
4850
|
-
thead: new Set(["tr"]),
|
|
4851
|
-
tfoot: new Set(["tr"]),
|
|
4889
|
+
tr: /* @__PURE__ */ new Set(["td", "th"]),
|
|
4890
|
+
colgroup: /* @__PURE__ */ new Set(["col"]),
|
|
4891
|
+
tbody: /* @__PURE__ */ new Set(["tr"]),
|
|
4892
|
+
thead: /* @__PURE__ */ new Set(["tr"]),
|
|
4893
|
+
tfoot: /* @__PURE__ */ new Set(["tr"]),
|
|
4852
4894
|
script: emptySet,
|
|
4853
4895
|
iframe: emptySet,
|
|
4854
4896
|
option: emptySet,
|
|
@@ -4859,30 +4901,30 @@ const onlyValidChildren = {
|
|
|
4859
4901
|
/** maps elements to set of elements which can be it's parent, no other */
|
|
4860
4902
|
const onlyValidParents = {
|
|
4861
4903
|
html: emptySet,
|
|
4862
|
-
body: new Set(["html"]),
|
|
4863
|
-
head: new Set(["html"]),
|
|
4864
|
-
td: new Set(["tr"]),
|
|
4865
|
-
colgroup: new Set(["table"]),
|
|
4866
|
-
caption: new Set(["table"]),
|
|
4867
|
-
tbody: new Set(["table"]),
|
|
4868
|
-
tfoot: new Set(["table"]),
|
|
4869
|
-
col: new Set(["colgroup"]),
|
|
4870
|
-
th: new Set(["tr"]),
|
|
4871
|
-
thead: new Set(["table"]),
|
|
4872
|
-
tr: new Set([
|
|
4904
|
+
body: /* @__PURE__ */ new Set(["html"]),
|
|
4905
|
+
head: /* @__PURE__ */ new Set(["html"]),
|
|
4906
|
+
td: /* @__PURE__ */ new Set(["tr"]),
|
|
4907
|
+
colgroup: /* @__PURE__ */ new Set(["table"]),
|
|
4908
|
+
caption: /* @__PURE__ */ new Set(["table"]),
|
|
4909
|
+
tbody: /* @__PURE__ */ new Set(["table"]),
|
|
4910
|
+
tfoot: /* @__PURE__ */ new Set(["table"]),
|
|
4911
|
+
col: /* @__PURE__ */ new Set(["colgroup"]),
|
|
4912
|
+
th: /* @__PURE__ */ new Set(["tr"]),
|
|
4913
|
+
thead: /* @__PURE__ */ new Set(["table"]),
|
|
4914
|
+
tr: /* @__PURE__ */ new Set([
|
|
4873
4915
|
"tbody",
|
|
4874
4916
|
"thead",
|
|
4875
4917
|
"tfoot"
|
|
4876
4918
|
]),
|
|
4877
|
-
dd: new Set(["dl", "div"]),
|
|
4878
|
-
dt: new Set(["dl", "div"]),
|
|
4879
|
-
figcaption: new Set(["figure"]),
|
|
4880
|
-
summary: new Set(["details"]),
|
|
4881
|
-
area: new Set(["map"])
|
|
4919
|
+
dd: /* @__PURE__ */ new Set(["dl", "div"]),
|
|
4920
|
+
dt: /* @__PURE__ */ new Set(["dl", "div"]),
|
|
4921
|
+
figcaption: /* @__PURE__ */ new Set(["figure"]),
|
|
4922
|
+
summary: /* @__PURE__ */ new Set(["details"]),
|
|
4923
|
+
area: /* @__PURE__ */ new Set(["map"])
|
|
4882
4924
|
};
|
|
4883
4925
|
/** maps element to set of elements that can not be it's children, others can */
|
|
4884
4926
|
const knownInvalidChildren = {
|
|
4885
|
-
p: new Set([
|
|
4927
|
+
p: /* @__PURE__ */ new Set([
|
|
4886
4928
|
"address",
|
|
4887
4929
|
"article",
|
|
4888
4930
|
"aside",
|
|
@@ -4917,7 +4959,7 @@ const knownInvalidChildren = {
|
|
|
4917
4959
|
"table",
|
|
4918
4960
|
"ul"
|
|
4919
4961
|
]),
|
|
4920
|
-
svg: new Set([
|
|
4962
|
+
svg: /* @__PURE__ */ new Set([
|
|
4921
4963
|
"b",
|
|
4922
4964
|
"blockquote",
|
|
4923
4965
|
"br",
|
|
@@ -4958,12 +5000,12 @@ const knownInvalidChildren = {
|
|
|
4958
5000
|
};
|
|
4959
5001
|
/** maps element to set of elements that can not be it's parent, others can */
|
|
4960
5002
|
const knownInvalidParents = {
|
|
4961
|
-
a: new Set(["a"]),
|
|
4962
|
-
button: new Set(["button"]),
|
|
4963
|
-
dd: new Set(["dd", "dt"]),
|
|
4964
|
-
dt: new Set(["dd", "dt"]),
|
|
4965
|
-
form: new Set(["form"]),
|
|
4966
|
-
li: new Set(["li"]),
|
|
5003
|
+
a: /* @__PURE__ */ new Set(["a"]),
|
|
5004
|
+
button: /* @__PURE__ */ new Set(["button"]),
|
|
5005
|
+
dd: /* @__PURE__ */ new Set(["dd", "dt"]),
|
|
5006
|
+
dt: /* @__PURE__ */ new Set(["dd", "dt"]),
|
|
5007
|
+
form: /* @__PURE__ */ new Set(["form"]),
|
|
5008
|
+
li: /* @__PURE__ */ new Set(["li"]),
|
|
4967
5009
|
h1: headings,
|
|
4968
5010
|
h2: headings,
|
|
4969
5011
|
h3: headings,
|