@vue/compiler-dom 3.6.0-beta.1 → 3.6.0-beta.10
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 +656 -848
- package/dist/compiler-dom.cjs.prod.js +635 -810
- package/dist/compiler-dom.d.ts +43 -35
- package/dist/compiler-dom.esm-browser.js +4505 -6248
- package/dist/compiler-dom.esm-browser.prod.js +10 -13
- package/dist/compiler-dom.esm-bundler.js +480 -635
- package/dist/compiler-dom.global.js +5169 -6914
- package/dist/compiler-dom.global.prod.js +10 -13
- package/package.json +3 -3
|
@@ -1,878 +1,698 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-dom v3.6.0-beta.
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var compilerCore = require('@vue/compiler-core');
|
|
11
|
-
var shared = require('@vue/shared');
|
|
12
|
-
|
|
13
|
-
const V_MODEL_RADIO = /* @__PURE__ */ Symbol(``);
|
|
14
|
-
const V_MODEL_CHECKBOX = /* @__PURE__ */ Symbol(
|
|
15
|
-
``
|
|
16
|
-
);
|
|
17
|
-
const V_MODEL_TEXT = /* @__PURE__ */ Symbol(``);
|
|
18
|
-
const V_MODEL_SELECT = /* @__PURE__ */ Symbol(
|
|
19
|
-
``
|
|
20
|
-
);
|
|
21
|
-
const V_MODEL_DYNAMIC = /* @__PURE__ */ Symbol(
|
|
22
|
-
``
|
|
23
|
-
);
|
|
24
|
-
const V_ON_WITH_MODIFIERS = /* @__PURE__ */ Symbol(
|
|
25
|
-
``
|
|
26
|
-
);
|
|
27
|
-
const V_ON_WITH_KEYS = /* @__PURE__ */ Symbol(
|
|
28
|
-
``
|
|
29
|
-
);
|
|
30
|
-
const V_SHOW = /* @__PURE__ */ Symbol(``);
|
|
31
|
-
const TRANSITION = /* @__PURE__ */ Symbol(``);
|
|
32
|
-
const TRANSITION_GROUP = /* @__PURE__ */ Symbol(
|
|
33
|
-
``
|
|
34
|
-
);
|
|
35
|
-
compilerCore.registerRuntimeHelpers({
|
|
36
|
-
[V_MODEL_RADIO]: `vModelRadio`,
|
|
37
|
-
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
|
38
|
-
[V_MODEL_TEXT]: `vModelText`,
|
|
39
|
-
[V_MODEL_SELECT]: `vModelSelect`,
|
|
40
|
-
[V_MODEL_DYNAMIC]: `vModelDynamic`,
|
|
41
|
-
[V_ON_WITH_MODIFIERS]: `withModifiers`,
|
|
42
|
-
[V_ON_WITH_KEYS]: `withKeys`,
|
|
43
|
-
[V_SHOW]: `vShow`,
|
|
44
|
-
[TRANSITION]: `Transition`,
|
|
45
|
-
[TRANSITION_GROUP]: `TransitionGroup`
|
|
2
|
+
* @vue/compiler-dom v3.6.0-beta.10
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
Object.defineProperties(exports, {
|
|
7
|
+
__esModule: { value: true },
|
|
8
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
46
9
|
});
|
|
47
|
-
|
|
10
|
+
let _vue_compiler_core = require("@vue/compiler-core");
|
|
11
|
+
let _vue_shared = require("@vue/shared");
|
|
12
|
+
//#region packages/compiler-dom/src/runtimeHelpers.ts
|
|
13
|
+
const V_MODEL_RADIO = Symbol(``);
|
|
14
|
+
const V_MODEL_CHECKBOX = Symbol(``);
|
|
15
|
+
const V_MODEL_TEXT = Symbol(``);
|
|
16
|
+
const V_MODEL_SELECT = Symbol(``);
|
|
17
|
+
const V_MODEL_DYNAMIC = Symbol(``);
|
|
18
|
+
const V_ON_WITH_MODIFIERS = Symbol(``);
|
|
19
|
+
const V_ON_WITH_KEYS = Symbol(``);
|
|
20
|
+
const V_SHOW = Symbol(``);
|
|
21
|
+
const TRANSITION = Symbol(``);
|
|
22
|
+
const TRANSITION_GROUP = Symbol(``);
|
|
23
|
+
(0, _vue_compiler_core.registerRuntimeHelpers)({
|
|
24
|
+
[V_MODEL_RADIO]: `vModelRadio`,
|
|
25
|
+
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
|
26
|
+
[V_MODEL_TEXT]: `vModelText`,
|
|
27
|
+
[V_MODEL_SELECT]: `vModelSelect`,
|
|
28
|
+
[V_MODEL_DYNAMIC]: `vModelDynamic`,
|
|
29
|
+
[V_ON_WITH_MODIFIERS]: `withModifiers`,
|
|
30
|
+
[V_ON_WITH_KEYS]: `withKeys`,
|
|
31
|
+
[V_SHOW]: `vShow`,
|
|
32
|
+
[TRANSITION]: `Transition`,
|
|
33
|
+
[TRANSITION_GROUP]: `TransitionGroup`
|
|
34
|
+
});
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region packages/compiler-dom/src/parserOptions.ts
|
|
48
37
|
const parserOptions = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
|
76
|
-
ns = 0;
|
|
77
|
-
}
|
|
78
|
-
} else if (parent && ns === 1) {
|
|
79
|
-
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
|
80
|
-
ns = 0;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (ns === 0) {
|
|
84
|
-
if (shared.isSVGTag(tag)) {
|
|
85
|
-
return 1;
|
|
86
|
-
}
|
|
87
|
-
if (shared.isMathMLTag(tag)) {
|
|
88
|
-
return 2;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return ns;
|
|
92
|
-
}
|
|
38
|
+
parseMode: "html",
|
|
39
|
+
isVoidTag: _vue_shared.isVoidTag,
|
|
40
|
+
isNativeTag: (tag) => (0, _vue_shared.isHTMLTag)(tag) || (0, _vue_shared.isSVGTag)(tag) || (0, _vue_shared.isMathMLTag)(tag),
|
|
41
|
+
isPreTag: (tag) => tag === "pre",
|
|
42
|
+
isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
|
|
43
|
+
decodeEntities: void 0,
|
|
44
|
+
isBuiltInComponent: (tag) => {
|
|
45
|
+
if (tag === "Transition" || tag === "transition") return TRANSITION;
|
|
46
|
+
else if (tag === "TransitionGroup" || tag === "transition-group") return TRANSITION_GROUP;
|
|
47
|
+
},
|
|
48
|
+
getNamespace(tag, parent, rootNamespace) {
|
|
49
|
+
let ns = parent ? parent.ns : rootNamespace;
|
|
50
|
+
if (parent && ns === 2) {
|
|
51
|
+
if (parent.tag === "annotation-xml") {
|
|
52
|
+
if ((0, _vue_shared.isSVGTag)(tag)) return 1;
|
|
53
|
+
if (parent.props.some((a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml"))) ns = 0;
|
|
54
|
+
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") ns = 0;
|
|
55
|
+
} else if (parent && ns === 1) {
|
|
56
|
+
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") ns = 0;
|
|
57
|
+
}
|
|
58
|
+
if (ns === 0) {
|
|
59
|
+
if ((0, _vue_shared.isSVGTag)(tag)) return 1;
|
|
60
|
+
if ((0, _vue_shared.isMathMLTag)(tag)) return 2;
|
|
61
|
+
}
|
|
62
|
+
return ns;
|
|
63
|
+
}
|
|
93
64
|
};
|
|
94
|
-
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region packages/compiler-dom/src/transforms/transformStyle.ts
|
|
95
67
|
const transformStyle = (node) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
68
|
+
if (node.type === 1) node.props.forEach((p, i) => {
|
|
69
|
+
if (p.type === 6 && p.name === "style" && p.value) node.props[i] = {
|
|
70
|
+
type: 7,
|
|
71
|
+
name: `bind`,
|
|
72
|
+
arg: (0, _vue_compiler_core.createSimpleExpression)(`style`, true, p.loc),
|
|
73
|
+
exp: parseInlineCSS(p.value.content, p.loc),
|
|
74
|
+
modifiers: [],
|
|
75
|
+
loc: p.loc
|
|
76
|
+
};
|
|
77
|
+
});
|
|
110
78
|
};
|
|
111
79
|
const parseInlineCSS = (cssText, loc) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
JSON.stringify(normalized),
|
|
115
|
-
false,
|
|
116
|
-
loc,
|
|
117
|
-
3
|
|
118
|
-
);
|
|
80
|
+
const normalized = (0, _vue_shared.parseStringStyle)(cssText);
|
|
81
|
+
return (0, _vue_compiler_core.createSimpleExpression)(JSON.stringify(normalized), false, loc, 3);
|
|
119
82
|
};
|
|
120
|
-
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region packages/compiler-dom/src/errors.ts
|
|
121
85
|
function createDOMCompilerError(code, loc) {
|
|
122
|
-
|
|
123
|
-
code,
|
|
124
|
-
loc,
|
|
125
|
-
DOMErrorMessages
|
|
126
|
-
);
|
|
86
|
+
return (0, _vue_compiler_core.createCompilerError)(code, loc, DOMErrorMessages);
|
|
127
87
|
}
|
|
128
88
|
const DOMErrorCodes = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
89
|
+
"X_V_HTML_NO_EXPRESSION": 54,
|
|
90
|
+
"54": "X_V_HTML_NO_EXPRESSION",
|
|
91
|
+
"X_V_HTML_WITH_CHILDREN": 55,
|
|
92
|
+
"55": "X_V_HTML_WITH_CHILDREN",
|
|
93
|
+
"X_V_TEXT_NO_EXPRESSION": 56,
|
|
94
|
+
"56": "X_V_TEXT_NO_EXPRESSION",
|
|
95
|
+
"X_V_TEXT_WITH_CHILDREN": 57,
|
|
96
|
+
"57": "X_V_TEXT_WITH_CHILDREN",
|
|
97
|
+
"X_V_MODEL_ON_INVALID_ELEMENT": 58,
|
|
98
|
+
"58": "X_V_MODEL_ON_INVALID_ELEMENT",
|
|
99
|
+
"X_V_MODEL_ARG_ON_ELEMENT": 59,
|
|
100
|
+
"59": "X_V_MODEL_ARG_ON_ELEMENT",
|
|
101
|
+
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 60,
|
|
102
|
+
"60": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
|
|
103
|
+
"X_V_MODEL_UNNECESSARY_VALUE": 61,
|
|
104
|
+
"61": "X_V_MODEL_UNNECESSARY_VALUE",
|
|
105
|
+
"X_V_SHOW_NO_EXPRESSION": 62,
|
|
106
|
+
"62": "X_V_SHOW_NO_EXPRESSION",
|
|
107
|
+
"X_TRANSITION_INVALID_CHILDREN": 63,
|
|
108
|
+
"63": "X_TRANSITION_INVALID_CHILDREN",
|
|
109
|
+
"X_IGNORED_SIDE_EFFECT_TAG": 64,
|
|
110
|
+
"64": "X_IGNORED_SIDE_EFFECT_TAG",
|
|
111
|
+
"__EXTEND_POINT__": 65,
|
|
112
|
+
"65": "__EXTEND_POINT__"
|
|
153
113
|
};
|
|
154
114
|
const DOMErrorMessages = {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
[65]: ``
|
|
115
|
+
[54]: `v-html is missing expression.`,
|
|
116
|
+
[55]: `v-html will override element children.`,
|
|
117
|
+
[56]: `v-text is missing expression.`,
|
|
118
|
+
[57]: `v-text will override element children.`,
|
|
119
|
+
[58]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
|
120
|
+
[59]: `v-model argument is not supported on plain elements.`,
|
|
121
|
+
[60]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
|
122
|
+
[61]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
|
123
|
+
[62]: `v-show is missing expression.`,
|
|
124
|
+
[63]: `<Transition> expects exactly one child element or component.`,
|
|
125
|
+
[64]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`,
|
|
126
|
+
[65]: ``
|
|
168
127
|
};
|
|
169
|
-
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region packages/compiler-dom/src/transforms/vHtml.ts
|
|
170
130
|
const transformVHtml = (dir, node, context) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
context.onError(
|
|
179
|
-
createDOMCompilerError(55, loc)
|
|
180
|
-
);
|
|
181
|
-
node.children.length = 0;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
props: [
|
|
185
|
-
compilerCore.createObjectProperty(
|
|
186
|
-
compilerCore.createSimpleExpression(`innerHTML`, true, loc),
|
|
187
|
-
exp || compilerCore.createSimpleExpression("", true)
|
|
188
|
-
)
|
|
189
|
-
]
|
|
190
|
-
};
|
|
131
|
+
const { exp, loc } = dir;
|
|
132
|
+
if (!exp) context.onError(createDOMCompilerError(54, loc));
|
|
133
|
+
if (node.children.length) {
|
|
134
|
+
context.onError(createDOMCompilerError(55, loc));
|
|
135
|
+
node.children.length = 0;
|
|
136
|
+
}
|
|
137
|
+
return { props: [(0, _vue_compiler_core.createObjectProperty)((0, _vue_compiler_core.createSimpleExpression)(`innerHTML`, true, loc), exp || (0, _vue_compiler_core.createSimpleExpression)("", true))] };
|
|
191
138
|
};
|
|
192
|
-
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region packages/compiler-dom/src/transforms/vText.ts
|
|
193
141
|
const transformVText = (dir, node, context) => {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
context.onError(
|
|
202
|
-
createDOMCompilerError(57, loc)
|
|
203
|
-
);
|
|
204
|
-
node.children.length = 0;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
props: [
|
|
208
|
-
compilerCore.createObjectProperty(
|
|
209
|
-
compilerCore.createSimpleExpression(`textContent`, true),
|
|
210
|
-
exp ? compilerCore.getConstantType(exp, context) > 0 ? exp : compilerCore.createCallExpression(
|
|
211
|
-
context.helperString(compilerCore.TO_DISPLAY_STRING),
|
|
212
|
-
[exp],
|
|
213
|
-
loc
|
|
214
|
-
) : compilerCore.createSimpleExpression("", true)
|
|
215
|
-
)
|
|
216
|
-
]
|
|
217
|
-
};
|
|
142
|
+
const { exp, loc } = dir;
|
|
143
|
+
if (!exp) context.onError(createDOMCompilerError(56, loc));
|
|
144
|
+
if (node.children.length) {
|
|
145
|
+
context.onError(createDOMCompilerError(57, loc));
|
|
146
|
+
node.children.length = 0;
|
|
147
|
+
}
|
|
148
|
+
return { props: [(0, _vue_compiler_core.createObjectProperty)((0, _vue_compiler_core.createSimpleExpression)(`textContent`, true), exp ? (0, _vue_compiler_core.getConstantType)(exp, context) > 0 ? exp : (0, _vue_compiler_core.createCallExpression)(context.helperString(_vue_compiler_core.TO_DISPLAY_STRING), [exp], loc) : (0, _vue_compiler_core.createSimpleExpression)("", true))] };
|
|
218
149
|
};
|
|
219
|
-
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region packages/compiler-dom/src/transforms/vModel.ts
|
|
220
152
|
const transformModel = (dir, node, context) => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
isInvalidType = true;
|
|
253
|
-
context.onError(
|
|
254
|
-
createDOMCompilerError(
|
|
255
|
-
60,
|
|
256
|
-
dir.loc
|
|
257
|
-
)
|
|
258
|
-
);
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
} else if (compilerCore.hasDynamicKeyVBind(node)) {
|
|
263
|
-
directiveToUse = V_MODEL_DYNAMIC;
|
|
264
|
-
} else ;
|
|
265
|
-
} else if (tag === "select") {
|
|
266
|
-
directiveToUse = V_MODEL_SELECT;
|
|
267
|
-
} else ;
|
|
268
|
-
if (!isInvalidType) {
|
|
269
|
-
baseResult.needRuntime = context.helper(directiveToUse);
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
context.onError(
|
|
273
|
-
createDOMCompilerError(
|
|
274
|
-
58,
|
|
275
|
-
dir.loc
|
|
276
|
-
)
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
baseResult.props = baseResult.props.filter(
|
|
280
|
-
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
|
281
|
-
);
|
|
282
|
-
return baseResult;
|
|
153
|
+
const baseResult = (0, _vue_compiler_core.transformModel)(dir, node, context);
|
|
154
|
+
if (!baseResult.props.length || node.tagType === 1) return baseResult;
|
|
155
|
+
if (dir.arg) context.onError(createDOMCompilerError(59, dir.arg.loc));
|
|
156
|
+
const { tag } = node;
|
|
157
|
+
const isCustomElement = context.isCustomElement(tag);
|
|
158
|
+
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
|
159
|
+
let directiveToUse = V_MODEL_TEXT;
|
|
160
|
+
let isInvalidType = false;
|
|
161
|
+
if (tag === "input" || isCustomElement) {
|
|
162
|
+
const type = (0, _vue_compiler_core.findProp)(node, `type`);
|
|
163
|
+
if (type) {
|
|
164
|
+
if (type.type === 7) directiveToUse = V_MODEL_DYNAMIC;
|
|
165
|
+
else if (type.value) switch (type.value.content) {
|
|
166
|
+
case "radio":
|
|
167
|
+
directiveToUse = V_MODEL_RADIO;
|
|
168
|
+
break;
|
|
169
|
+
case "checkbox":
|
|
170
|
+
directiveToUse = V_MODEL_CHECKBOX;
|
|
171
|
+
break;
|
|
172
|
+
case "file":
|
|
173
|
+
isInvalidType = true;
|
|
174
|
+
context.onError(createDOMCompilerError(60, dir.loc));
|
|
175
|
+
break;
|
|
176
|
+
default: break;
|
|
177
|
+
}
|
|
178
|
+
} else if ((0, _vue_compiler_core.hasDynamicKeyVBind)(node)) directiveToUse = V_MODEL_DYNAMIC;
|
|
179
|
+
} else if (tag === "select") directiveToUse = V_MODEL_SELECT;
|
|
180
|
+
if (!isInvalidType) baseResult.needRuntime = context.helper(directiveToUse);
|
|
181
|
+
} else context.onError(createDOMCompilerError(58, dir.loc));
|
|
182
|
+
baseResult.props = baseResult.props.filter((p) => !(p.key.type === 4 && p.key.content === "modelValue"));
|
|
183
|
+
return baseResult;
|
|
283
184
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
);
|
|
290
|
-
const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
|
|
291
|
-
const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(
|
|
292
|
-
`onkeyup,onkeydown,onkeypress`
|
|
293
|
-
);
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region packages/compiler-dom/src/transforms/vOn.ts
|
|
187
|
+
const isEventOptionModifier = /* @__PURE__ */ (0, _vue_shared.makeMap)(`passive,once,capture`);
|
|
188
|
+
const isNonKeyModifier = /* @__PURE__ */ (0, _vue_shared.makeMap)("stop,prevent,self,ctrl,shift,alt,meta,exact,middle");
|
|
189
|
+
const maybeKeyModifier = /* @__PURE__ */ (0, _vue_shared.makeMap)("left,right");
|
|
190
|
+
const isKeyboardEvent = /* @__PURE__ */ (0, _vue_shared.makeMap)(`onkeyup,onkeydown,onkeypress`);
|
|
294
191
|
const resolveModifiers = (key, modifiers, context, loc) => {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
nonKeyModifiers.push(modifier);
|
|
320
|
-
}
|
|
321
|
-
} else {
|
|
322
|
-
if (isNonKeyModifier(modifier)) {
|
|
323
|
-
nonKeyModifiers.push(modifier);
|
|
324
|
-
} else {
|
|
325
|
-
keyModifiers.push(modifier);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
keyModifiers,
|
|
332
|
-
nonKeyModifiers,
|
|
333
|
-
eventOptionModifiers
|
|
334
|
-
};
|
|
192
|
+
const keyModifiers = [];
|
|
193
|
+
const nonKeyModifiers = [];
|
|
194
|
+
const eventOptionModifiers = [];
|
|
195
|
+
for (let i = 0; i < modifiers.length; i++) {
|
|
196
|
+
const modifier = modifiers[i].content;
|
|
197
|
+
if (modifier === "native" && context && (0, _vue_compiler_core.checkCompatEnabled)("COMPILER_V_ON_NATIVE", context, loc)) eventOptionModifiers.push(modifier);
|
|
198
|
+
else if (isEventOptionModifier(modifier)) eventOptionModifiers.push(modifier);
|
|
199
|
+
else {
|
|
200
|
+
const keyString = (0, _vue_shared.isString)(key) ? key : (0, _vue_compiler_core.isStaticExp)(key) ? key.content : null;
|
|
201
|
+
if (maybeKeyModifier(modifier)) if (keyString) if (isKeyboardEvent(keyString.toLowerCase())) keyModifiers.push(modifier);
|
|
202
|
+
else nonKeyModifiers.push(modifier);
|
|
203
|
+
else {
|
|
204
|
+
keyModifiers.push(modifier);
|
|
205
|
+
nonKeyModifiers.push(modifier);
|
|
206
|
+
}
|
|
207
|
+
else if (isNonKeyModifier(modifier)) nonKeyModifiers.push(modifier);
|
|
208
|
+
else keyModifiers.push(modifier);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
keyModifiers,
|
|
213
|
+
nonKeyModifiers,
|
|
214
|
+
eventOptionModifiers
|
|
215
|
+
};
|
|
335
216
|
};
|
|
336
217
|
const transformClick = (key, event) => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
]) : key;
|
|
218
|
+
return (0, _vue_compiler_core.isStaticExp)(key) && key.content.toLowerCase() === "onclick" ? (0, _vue_compiler_core.createSimpleExpression)(event, true) : key.type !== 4 ? (0, _vue_compiler_core.createCompoundExpression)([
|
|
219
|
+
`(`,
|
|
220
|
+
key,
|
|
221
|
+
`) === "onClick" ? "${event}" : (`,
|
|
222
|
+
key,
|
|
223
|
+
`)`
|
|
224
|
+
]) : key;
|
|
345
225
|
};
|
|
346
226
|
const transformOn = (dir, node, context) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
|
367
|
-
handlerExp,
|
|
368
|
-
JSON.stringify(keyModifiers)
|
|
369
|
-
]);
|
|
370
|
-
}
|
|
371
|
-
if (eventOptionModifiers.length) {
|
|
372
|
-
const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join("");
|
|
373
|
-
key = compilerCore.isStaticExp(key) ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true) : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
|
374
|
-
}
|
|
375
|
-
return {
|
|
376
|
-
props: [compilerCore.createObjectProperty(key, handlerExp)]
|
|
377
|
-
};
|
|
378
|
-
});
|
|
227
|
+
return (0, _vue_compiler_core.transformOn)(dir, node, context, (baseResult) => {
|
|
228
|
+
const { modifiers } = dir;
|
|
229
|
+
if (!modifiers.length) return baseResult;
|
|
230
|
+
let { key, value: handlerExp } = baseResult.props[0];
|
|
231
|
+
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
|
232
|
+
if (nonKeyModifiers.includes("right")) key = transformClick(key, `onContextmenu`);
|
|
233
|
+
if (nonKeyModifiers.includes("middle")) key = transformClick(key, `onMouseup`);
|
|
234
|
+
if (nonKeyModifiers.length) handlerExp = (0, _vue_compiler_core.createCallExpression)(context.helper(V_ON_WITH_MODIFIERS), [handlerExp, JSON.stringify(nonKeyModifiers)]);
|
|
235
|
+
if (keyModifiers.length && (!(0, _vue_compiler_core.isStaticExp)(key) || isKeyboardEvent(key.content.toLowerCase()))) handlerExp = (0, _vue_compiler_core.createCallExpression)(context.helper(V_ON_WITH_KEYS), [handlerExp, JSON.stringify(keyModifiers)]);
|
|
236
|
+
if (eventOptionModifiers.length) {
|
|
237
|
+
const modifierPostfix = eventOptionModifiers.map(_vue_shared.capitalize).join("");
|
|
238
|
+
key = (0, _vue_compiler_core.isStaticExp)(key) ? (0, _vue_compiler_core.createSimpleExpression)(`${key.content}${modifierPostfix}`, true) : (0, _vue_compiler_core.createCompoundExpression)([
|
|
239
|
+
`(`,
|
|
240
|
+
key,
|
|
241
|
+
`) + "${modifierPostfix}"`
|
|
242
|
+
]);
|
|
243
|
+
}
|
|
244
|
+
return { props: [(0, _vue_compiler_core.createObjectProperty)(key, handlerExp)] };
|
|
245
|
+
});
|
|
379
246
|
};
|
|
380
|
-
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region packages/compiler-dom/src/transforms/vShow.ts
|
|
381
249
|
const transformShow = (dir, node, context) => {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
return {
|
|
389
|
-
props: [],
|
|
390
|
-
needRuntime: context.helper(V_SHOW)
|
|
391
|
-
};
|
|
250
|
+
const { exp, loc } = dir;
|
|
251
|
+
if (!exp) context.onError(createDOMCompilerError(62, loc));
|
|
252
|
+
return {
|
|
253
|
+
props: [],
|
|
254
|
+
needRuntime: context.helper(V_SHOW)
|
|
255
|
+
};
|
|
392
256
|
};
|
|
393
|
-
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region packages/compiler-dom/src/transforms/Transition.ts
|
|
394
259
|
function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
type: 6,
|
|
414
|
-
name: "persisted",
|
|
415
|
-
nameLoc: node.loc,
|
|
416
|
-
value: void 0,
|
|
417
|
-
loc: node.loc
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
};
|
|
260
|
+
return () => {
|
|
261
|
+
if (!node.children.length) return;
|
|
262
|
+
if (hasMultipleChildren(node)) onError(createDOMCompilerError(63, {
|
|
263
|
+
start: node.children[0].loc.start,
|
|
264
|
+
end: node.children[node.children.length - 1].loc.end,
|
|
265
|
+
source: ""
|
|
266
|
+
}));
|
|
267
|
+
const child = node.children[0];
|
|
268
|
+
if (child.type === 1) {
|
|
269
|
+
for (const p of child.props) if (p.type === 7 && p.name === "show") node.props.push({
|
|
270
|
+
type: 6,
|
|
271
|
+
name: "persisted",
|
|
272
|
+
nameLoc: node.loc,
|
|
273
|
+
value: void 0,
|
|
274
|
+
loc: node.loc
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
};
|
|
423
278
|
}
|
|
424
279
|
function defaultHasMultipleChildren(node) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const child = children[0];
|
|
429
|
-
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
|
|
280
|
+
const children = node.children = node.children.filter((c) => !(0, _vue_compiler_core.isCommentOrWhitespace)(c));
|
|
281
|
+
const child = children[0];
|
|
282
|
+
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
|
|
430
283
|
}
|
|
431
|
-
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region packages/compiler-dom/src/transforms/stringifyStatic.ts
|
|
286
|
+
/**
|
|
287
|
+
* This module is Node-only.
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* Regex for replacing placeholders for embedded constant variables
|
|
291
|
+
* (e.g. import URL string constants generated by compiler-sfc)
|
|
292
|
+
*/
|
|
432
293
|
const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
|
|
294
|
+
/**
|
|
295
|
+
* Turn eligible hoisted static trees into stringified static nodes, e.g.
|
|
296
|
+
*
|
|
297
|
+
* ```js
|
|
298
|
+
* const _hoisted_1 = createStaticVNode(`<div class="foo">bar</div>`)
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* A single static vnode can contain stringified content for **multiple**
|
|
302
|
+
* consecutive nodes (element and plain text), called a "chunk".
|
|
303
|
+
* `@vue/runtime-dom` will create the content via innerHTML in a hidden
|
|
304
|
+
* container element and insert all the nodes in place. The call must also
|
|
305
|
+
* provide the number of nodes contained in the chunk so that during hydration
|
|
306
|
+
* we can know how many nodes the static vnode should adopt.
|
|
307
|
+
*
|
|
308
|
+
* The optimization scans a children list that contains hoisted nodes, and
|
|
309
|
+
* tries to find the largest chunk of consecutive hoisted nodes before running
|
|
310
|
+
* into a non-hoisted node or the end of the list. A chunk is then converted
|
|
311
|
+
* into a single static vnode and replaces the hoisted expression of the first
|
|
312
|
+
* node in the chunk. Other nodes in the chunk are considered "merged" and
|
|
313
|
+
* therefore removed from both the hoist list and the children array.
|
|
314
|
+
*
|
|
315
|
+
* This optimization is only performed in Node.js.
|
|
316
|
+
*/
|
|
433
317
|
const stringifyStatic = (children, context, parent) => {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
for (; i < children.length; i++) {
|
|
481
|
-
const child = children[i];
|
|
482
|
-
const isCached = isParentCached || getCachedNode(child);
|
|
483
|
-
if (isCached) {
|
|
484
|
-
const result = analyzeNode(child);
|
|
485
|
-
if (result) {
|
|
486
|
-
nc += result[0];
|
|
487
|
-
ec += result[1];
|
|
488
|
-
currentChunk.push(child);
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
i -= stringifyCurrentChunk(i);
|
|
493
|
-
nc = 0;
|
|
494
|
-
ec = 0;
|
|
495
|
-
currentChunk.length = 0;
|
|
496
|
-
}
|
|
497
|
-
stringifyCurrentChunk(i);
|
|
318
|
+
if (context.scopes.vSlot > 0) return;
|
|
319
|
+
const isParentCached = parent.type === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !(0, _vue_shared.isArray)(parent.codegenNode.children) && parent.codegenNode.children.type === 20;
|
|
320
|
+
let nc = 0;
|
|
321
|
+
let ec = 0;
|
|
322
|
+
const currentChunk = [];
|
|
323
|
+
const stringifyCurrentChunk = (currentIndex) => {
|
|
324
|
+
if (nc >= 20 || ec >= 5) {
|
|
325
|
+
const staticCall = (0, _vue_compiler_core.createCallExpression)(context.helper(_vue_compiler_core.CREATE_STATIC), [JSON.stringify(currentChunk.map((node) => stringifyNode(node, context)).join("")).replace(expReplaceRE, `" + $1 + "`), String(currentChunk.length)]);
|
|
326
|
+
const deleteCount = currentChunk.length - 1;
|
|
327
|
+
if (isParentCached) children.splice(currentIndex - currentChunk.length, currentChunk.length, staticCall);
|
|
328
|
+
else {
|
|
329
|
+
currentChunk[0].codegenNode.value = staticCall;
|
|
330
|
+
if (currentChunk.length > 1) {
|
|
331
|
+
children.splice(currentIndex - currentChunk.length + 1, deleteCount);
|
|
332
|
+
const cacheIndex = context.cached.indexOf(currentChunk[currentChunk.length - 1].codegenNode);
|
|
333
|
+
if (cacheIndex > -1) {
|
|
334
|
+
for (let i = cacheIndex; i < context.cached.length; i++) {
|
|
335
|
+
const c = context.cached[i];
|
|
336
|
+
if (c) c.index -= deleteCount;
|
|
337
|
+
}
|
|
338
|
+
context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return deleteCount;
|
|
343
|
+
}
|
|
344
|
+
return 0;
|
|
345
|
+
};
|
|
346
|
+
let i = 0;
|
|
347
|
+
for (; i < children.length; i++) {
|
|
348
|
+
const child = children[i];
|
|
349
|
+
if (isParentCached || getCachedNode(child)) {
|
|
350
|
+
const result = analyzeNode(child);
|
|
351
|
+
if (result) {
|
|
352
|
+
nc += result[0];
|
|
353
|
+
ec += result[1];
|
|
354
|
+
currentChunk.push(child);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
i -= stringifyCurrentChunk(i);
|
|
359
|
+
nc = 0;
|
|
360
|
+
ec = 0;
|
|
361
|
+
currentChunk.length = 0;
|
|
362
|
+
}
|
|
363
|
+
stringifyCurrentChunk(i);
|
|
498
364
|
};
|
|
499
365
|
const getCachedNode = (node) => {
|
|
500
|
-
|
|
501
|
-
return node.codegenNode;
|
|
502
|
-
}
|
|
366
|
+
if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) return node.codegenNode;
|
|
503
367
|
};
|
|
504
368
|
const dataAriaRE = /^(?:data|aria)-/;
|
|
505
369
|
const isStringifiableAttr = (name, ns) => {
|
|
506
|
-
|
|
370
|
+
return (ns === 0 ? (0, _vue_shared.isKnownHtmlAttr)(name) : ns === 1 ? (0, _vue_shared.isKnownSvgAttr)(name) : ns === 2 ? (0, _vue_shared.isKnownMathMLAttr)(name) : false) || dataAriaRE.test(name);
|
|
507
371
|
};
|
|
508
|
-
const isNonStringifiable = /* @__PURE__ */
|
|
509
|
-
|
|
510
|
-
|
|
372
|
+
const isNonStringifiable = /* @__PURE__ */ (0, _vue_shared.makeMap)(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
|
|
373
|
+
/**
|
|
374
|
+
* for a cached node, analyze it and return:
|
|
375
|
+
* - false: bailed (contains non-stringifiable props or runtime constant)
|
|
376
|
+
* - [nc, ec] where
|
|
377
|
+
* - nc is the number of nodes inside
|
|
378
|
+
* - ec is the number of element with bindings inside
|
|
379
|
+
*/
|
|
511
380
|
function analyzeNode(node) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
for (let i = 0; i < node2.children.length; i++) {
|
|
548
|
-
nc++;
|
|
549
|
-
const child = node2.children[i];
|
|
550
|
-
if (child.type === 1) {
|
|
551
|
-
if (child.props.length > 0) {
|
|
552
|
-
ec++;
|
|
553
|
-
}
|
|
554
|
-
walk(child);
|
|
555
|
-
if (bailed) {
|
|
556
|
-
return false;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
return true;
|
|
561
|
-
}
|
|
562
|
-
return walk(node) ? [nc, ec] : false;
|
|
381
|
+
if (node.type === 1 && isNonStringifiable(node.tag)) return false;
|
|
382
|
+
if (node.type === 1 && (0, _vue_compiler_core.findDir)(node, "once", true)) return false;
|
|
383
|
+
if (node.type === 12) return [1, 0];
|
|
384
|
+
let nc = 1;
|
|
385
|
+
let ec = node.props.length > 0 ? 1 : 0;
|
|
386
|
+
let bailed = false;
|
|
387
|
+
const bail = () => {
|
|
388
|
+
bailed = true;
|
|
389
|
+
return false;
|
|
390
|
+
};
|
|
391
|
+
function walk(node) {
|
|
392
|
+
const isOptionTag = node.tag === "option" && node.ns === 0;
|
|
393
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
394
|
+
const p = node.props[i];
|
|
395
|
+
if (p.type === 6 && !isStringifiableAttr(p.name, node.ns)) return bail();
|
|
396
|
+
if (p.type === 7 && p.name === "bind") {
|
|
397
|
+
if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns))) return bail();
|
|
398
|
+
if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) return bail();
|
|
399
|
+
if (isOptionTag && (0, _vue_compiler_core.isStaticArgOf)(p.arg, "value") && p.exp && !p.exp.isStatic) return bail();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
403
|
+
nc++;
|
|
404
|
+
const child = node.children[i];
|
|
405
|
+
if (child.type === 1) {
|
|
406
|
+
if (child.props.length > 0) ec++;
|
|
407
|
+
walk(child);
|
|
408
|
+
if (bailed) return false;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
return walk(node) ? [nc, ec] : false;
|
|
563
414
|
}
|
|
564
415
|
function stringifyNode(node, context) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
case 3:
|
|
577
|
-
return `<!--${shared.escapeHtml(node.content)}-->`;
|
|
578
|
-
case 5:
|
|
579
|
-
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
|
580
|
-
case 8:
|
|
581
|
-
return shared.escapeHtml(evaluateConstant(node));
|
|
582
|
-
case 12:
|
|
583
|
-
return stringifyNode(node.content, context);
|
|
584
|
-
default:
|
|
585
|
-
return "";
|
|
586
|
-
}
|
|
416
|
+
if ((0, _vue_shared.isString)(node)) return node;
|
|
417
|
+
if ((0, _vue_shared.isSymbol)(node)) return ``;
|
|
418
|
+
switch (node.type) {
|
|
419
|
+
case 1: return stringifyElement(node, context);
|
|
420
|
+
case 2: return (0, _vue_shared.escapeHtml)(node.content);
|
|
421
|
+
case 3: return `<!--${(0, _vue_shared.escapeHtml)(node.content)}-->`;
|
|
422
|
+
case 5: return (0, _vue_shared.escapeHtml)((0, _vue_shared.toDisplayString)(evaluateConstant(node.content)));
|
|
423
|
+
case 8: return (0, _vue_shared.escapeHtml)(evaluateConstant(node));
|
|
424
|
+
case 12: return stringifyNode(node.content, context);
|
|
425
|
+
default: return "";
|
|
426
|
+
}
|
|
587
427
|
}
|
|
588
428
|
function stringifyElement(node, context) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
innerHTML = evaluateConstant(p.exp);
|
|
622
|
-
} else if (p.name === "text") {
|
|
623
|
-
innerHTML = shared.escapeHtml(
|
|
624
|
-
shared.toDisplayString(evaluateConstant(p.exp))
|
|
625
|
-
);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
if (context.scopeId) {
|
|
630
|
-
res += ` ${context.scopeId}`;
|
|
631
|
-
}
|
|
632
|
-
res += `>`;
|
|
633
|
-
if (innerHTML) {
|
|
634
|
-
res += innerHTML;
|
|
635
|
-
} else {
|
|
636
|
-
for (let i = 0; i < node.children.length; i++) {
|
|
637
|
-
res += stringifyNode(node.children[i], context);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
if (!shared.isVoidTag(node.tag)) {
|
|
641
|
-
res += `</${node.tag}>`;
|
|
642
|
-
}
|
|
643
|
-
return res;
|
|
429
|
+
let res = `<${node.tag}`;
|
|
430
|
+
let innerHTML = "";
|
|
431
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
432
|
+
const p = node.props[i];
|
|
433
|
+
if (p.type === 6) {
|
|
434
|
+
res += ` ${p.name}`;
|
|
435
|
+
if (p.value) res += `="${(0, _vue_shared.escapeHtml)(p.value.content)}"`;
|
|
436
|
+
} else if (p.type === 7) {
|
|
437
|
+
if (p.name === "bind") {
|
|
438
|
+
const exp = p.exp;
|
|
439
|
+
if (exp.content[0] === "_") {
|
|
440
|
+
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if ((0, _vue_shared.isBooleanAttr)(p.arg.content) && exp.content === "false") continue;
|
|
444
|
+
let evaluated = evaluateConstant(exp);
|
|
445
|
+
if (evaluated != null) {
|
|
446
|
+
const arg = p.arg && p.arg.content;
|
|
447
|
+
if (arg === "class") evaluated = (0, _vue_shared.normalizeClass)(evaluated);
|
|
448
|
+
else if (arg === "style") evaluated = (0, _vue_shared.stringifyStyle)((0, _vue_shared.normalizeStyle)(evaluated));
|
|
449
|
+
res += ` ${p.arg.content}="${(0, _vue_shared.escapeHtml)(evaluated)}"`;
|
|
450
|
+
}
|
|
451
|
+
} else if (p.name === "html") innerHTML = evaluateConstant(p.exp);
|
|
452
|
+
else if (p.name === "text") innerHTML = (0, _vue_shared.escapeHtml)((0, _vue_shared.toDisplayString)(evaluateConstant(p.exp)));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (context.scopeId) res += ` ${context.scopeId}`;
|
|
456
|
+
res += `>`;
|
|
457
|
+
if (innerHTML) res += innerHTML;
|
|
458
|
+
else for (let i = 0; i < node.children.length; i++) res += stringifyNode(node.children[i], context);
|
|
459
|
+
if (!(0, _vue_shared.isVoidTag)(node.tag)) res += `</${node.tag}>`;
|
|
460
|
+
return res;
|
|
644
461
|
}
|
|
645
462
|
function evaluateConstant(exp) {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
res += shared.toDisplayString(evaluateConstant(c.content));
|
|
658
|
-
} else {
|
|
659
|
-
res += evaluateConstant(c);
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
return res;
|
|
663
|
-
}
|
|
463
|
+
if (exp.type === 4) return new Function(`return (${exp.content})`)();
|
|
464
|
+
else {
|
|
465
|
+
let res = ``;
|
|
466
|
+
exp.children.forEach((c) => {
|
|
467
|
+
if ((0, _vue_shared.isString)(c) || (0, _vue_shared.isSymbol)(c)) return;
|
|
468
|
+
if (c.type === 2) res += c.content;
|
|
469
|
+
else if (c.type === 5) res += (0, _vue_shared.toDisplayString)(evaluateConstant(c.content));
|
|
470
|
+
else res += evaluateConstant(c);
|
|
471
|
+
});
|
|
472
|
+
return res;
|
|
473
|
+
}
|
|
664
474
|
}
|
|
665
|
-
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region packages/compiler-dom/src/transforms/ignoreSideEffectTags.ts
|
|
666
477
|
const ignoreSideEffectTags = (node, context) => {
|
|
667
|
-
|
|
668
|
-
context.removeNode();
|
|
669
|
-
}
|
|
478
|
+
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) context.removeNode();
|
|
670
479
|
};
|
|
671
|
-
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region packages/compiler-dom/src/htmlNesting.ts
|
|
482
|
+
/**
|
|
483
|
+
* Copied from https://github.com/MananTank/validate-html-nesting
|
|
484
|
+
* with ISC license
|
|
485
|
+
*
|
|
486
|
+
* To avoid runtime dependency on validate-html-nesting
|
|
487
|
+
* This file should not change very often in the original repo
|
|
488
|
+
* but we may need to keep it up-to-date from time to time.
|
|
489
|
+
*/
|
|
490
|
+
/**
|
|
491
|
+
* returns true if given parent-child nesting is valid HTML
|
|
492
|
+
*/
|
|
672
493
|
function isValidHTMLNesting(parent, child) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if (knownInvalidChildren[parent].has(child)) return false;
|
|
684
|
-
}
|
|
685
|
-
if (child in knownInvalidParents) {
|
|
686
|
-
if (knownInvalidParents[child].has(parent)) return false;
|
|
687
|
-
}
|
|
688
|
-
return true;
|
|
494
|
+
if (parent === "template") return true;
|
|
495
|
+
if (parent in onlyValidChildren) return onlyValidChildren[parent].has(child);
|
|
496
|
+
if (child in onlyValidParents) return onlyValidParents[child].has(parent);
|
|
497
|
+
if (parent in knownInvalidChildren) {
|
|
498
|
+
if (knownInvalidChildren[parent].has(child)) return false;
|
|
499
|
+
}
|
|
500
|
+
if (child in knownInvalidParents) {
|
|
501
|
+
if (knownInvalidParents[child].has(parent)) return false;
|
|
502
|
+
}
|
|
503
|
+
return true;
|
|
689
504
|
}
|
|
690
|
-
const headings =
|
|
505
|
+
const headings = new Set([
|
|
506
|
+
"h1",
|
|
507
|
+
"h2",
|
|
508
|
+
"h3",
|
|
509
|
+
"h4",
|
|
510
|
+
"h5",
|
|
511
|
+
"h6"
|
|
512
|
+
]);
|
|
691
513
|
const emptySet = /* @__PURE__ */ new Set([]);
|
|
514
|
+
/**
|
|
515
|
+
* maps element to set of elements that can be it's children, no other */
|
|
692
516
|
const onlyValidChildren = {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
517
|
+
head: new Set([
|
|
518
|
+
"base",
|
|
519
|
+
"basefront",
|
|
520
|
+
"bgsound",
|
|
521
|
+
"link",
|
|
522
|
+
"meta",
|
|
523
|
+
"title",
|
|
524
|
+
"noscript",
|
|
525
|
+
"noframes",
|
|
526
|
+
"style",
|
|
527
|
+
"script",
|
|
528
|
+
"template"
|
|
529
|
+
]),
|
|
530
|
+
optgroup: new Set(["option"]),
|
|
531
|
+
select: new Set([
|
|
532
|
+
"optgroup",
|
|
533
|
+
"option",
|
|
534
|
+
"hr"
|
|
535
|
+
]),
|
|
536
|
+
table: new Set([
|
|
537
|
+
"caption",
|
|
538
|
+
"colgroup",
|
|
539
|
+
"tbody",
|
|
540
|
+
"tfoot",
|
|
541
|
+
"thead"
|
|
542
|
+
]),
|
|
543
|
+
tr: new Set(["td", "th"]),
|
|
544
|
+
colgroup: new Set(["col"]),
|
|
545
|
+
tbody: new Set(["tr"]),
|
|
546
|
+
thead: new Set(["tr"]),
|
|
547
|
+
tfoot: new Set(["tr"]),
|
|
548
|
+
script: emptySet,
|
|
549
|
+
iframe: emptySet,
|
|
550
|
+
option: emptySet,
|
|
551
|
+
textarea: emptySet,
|
|
552
|
+
style: emptySet,
|
|
553
|
+
title: emptySet
|
|
722
554
|
};
|
|
555
|
+
/** maps elements to set of elements which can be it's parent, no other */
|
|
723
556
|
const onlyValidParents = {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
area: /* @__PURE__ */ new Set(["map"])
|
|
557
|
+
html: emptySet,
|
|
558
|
+
body: new Set(["html"]),
|
|
559
|
+
head: new Set(["html"]),
|
|
560
|
+
td: new Set(["tr"]),
|
|
561
|
+
colgroup: new Set(["table"]),
|
|
562
|
+
caption: new Set(["table"]),
|
|
563
|
+
tbody: new Set(["table"]),
|
|
564
|
+
tfoot: new Set(["table"]),
|
|
565
|
+
col: new Set(["colgroup"]),
|
|
566
|
+
th: new Set(["tr"]),
|
|
567
|
+
thead: new Set(["table"]),
|
|
568
|
+
tr: new Set([
|
|
569
|
+
"tbody",
|
|
570
|
+
"thead",
|
|
571
|
+
"tfoot"
|
|
572
|
+
]),
|
|
573
|
+
dd: new Set(["dl", "div"]),
|
|
574
|
+
dt: new Set(["dl", "div"]),
|
|
575
|
+
figcaption: new Set(["figure"]),
|
|
576
|
+
summary: new Set(["details"]),
|
|
577
|
+
area: new Set(["map"])
|
|
746
578
|
};
|
|
579
|
+
/** maps element to set of elements that can not be it's children, others can */
|
|
747
580
|
const knownInvalidChildren = {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
581
|
+
p: new Set([
|
|
582
|
+
"address",
|
|
583
|
+
"article",
|
|
584
|
+
"aside",
|
|
585
|
+
"blockquote",
|
|
586
|
+
"center",
|
|
587
|
+
"details",
|
|
588
|
+
"dialog",
|
|
589
|
+
"dir",
|
|
590
|
+
"div",
|
|
591
|
+
"dl",
|
|
592
|
+
"fieldset",
|
|
593
|
+
"figure",
|
|
594
|
+
"footer",
|
|
595
|
+
"form",
|
|
596
|
+
"h1",
|
|
597
|
+
"h2",
|
|
598
|
+
"h3",
|
|
599
|
+
"h4",
|
|
600
|
+
"h5",
|
|
601
|
+
"h6",
|
|
602
|
+
"header",
|
|
603
|
+
"hgroup",
|
|
604
|
+
"hr",
|
|
605
|
+
"li",
|
|
606
|
+
"main",
|
|
607
|
+
"nav",
|
|
608
|
+
"menu",
|
|
609
|
+
"ol",
|
|
610
|
+
"p",
|
|
611
|
+
"pre",
|
|
612
|
+
"section",
|
|
613
|
+
"table",
|
|
614
|
+
"ul"
|
|
615
|
+
]),
|
|
616
|
+
svg: new Set([
|
|
617
|
+
"b",
|
|
618
|
+
"blockquote",
|
|
619
|
+
"br",
|
|
620
|
+
"code",
|
|
621
|
+
"dd",
|
|
622
|
+
"div",
|
|
623
|
+
"dl",
|
|
624
|
+
"dt",
|
|
625
|
+
"em",
|
|
626
|
+
"embed",
|
|
627
|
+
"h1",
|
|
628
|
+
"h2",
|
|
629
|
+
"h3",
|
|
630
|
+
"h4",
|
|
631
|
+
"h5",
|
|
632
|
+
"h6",
|
|
633
|
+
"hr",
|
|
634
|
+
"i",
|
|
635
|
+
"img",
|
|
636
|
+
"li",
|
|
637
|
+
"menu",
|
|
638
|
+
"meta",
|
|
639
|
+
"ol",
|
|
640
|
+
"p",
|
|
641
|
+
"pre",
|
|
642
|
+
"ruby",
|
|
643
|
+
"s",
|
|
644
|
+
"small",
|
|
645
|
+
"span",
|
|
646
|
+
"strong",
|
|
647
|
+
"sub",
|
|
648
|
+
"sup",
|
|
649
|
+
"table",
|
|
650
|
+
"u",
|
|
651
|
+
"ul",
|
|
652
|
+
"var"
|
|
653
|
+
])
|
|
821
654
|
};
|
|
655
|
+
/** maps element to set of elements that can not be it's parent, others can */
|
|
822
656
|
const knownInvalidParents = {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
657
|
+
a: new Set(["a"]),
|
|
658
|
+
button: new Set(["button"]),
|
|
659
|
+
dd: new Set(["dd", "dt"]),
|
|
660
|
+
dt: new Set(["dd", "dt"]),
|
|
661
|
+
form: new Set(["form"]),
|
|
662
|
+
li: new Set(["li"]),
|
|
663
|
+
h1: headings,
|
|
664
|
+
h2: headings,
|
|
665
|
+
h3: headings,
|
|
666
|
+
h4: headings,
|
|
667
|
+
h5: headings,
|
|
668
|
+
h6: headings
|
|
835
669
|
};
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
...[]
|
|
840
|
-
];
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region packages/compiler-dom/src/index.ts
|
|
672
|
+
const DOMNodeTransforms = [transformStyle, ...[]];
|
|
841
673
|
const DOMDirectiveTransforms = {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
// override compiler-core
|
|
849
|
-
show: transformShow
|
|
674
|
+
cloak: _vue_compiler_core.noopDirectiveTransform,
|
|
675
|
+
html: transformVHtml,
|
|
676
|
+
text: transformVText,
|
|
677
|
+
model: transformModel,
|
|
678
|
+
on: transformOn,
|
|
679
|
+
show: transformShow
|
|
850
680
|
};
|
|
851
681
|
function compile(src, options = {}) {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
...options.nodeTransforms || []
|
|
862
|
-
],
|
|
863
|
-
directiveTransforms: shared.extend(
|
|
864
|
-
{},
|
|
865
|
-
DOMDirectiveTransforms,
|
|
866
|
-
options.directiveTransforms || {}
|
|
867
|
-
),
|
|
868
|
-
transformHoist: stringifyStatic
|
|
869
|
-
})
|
|
870
|
-
);
|
|
682
|
+
return (0, _vue_compiler_core.baseCompile)(src, (0, _vue_shared.extend)({}, parserOptions, options, {
|
|
683
|
+
nodeTransforms: [
|
|
684
|
+
ignoreSideEffectTags,
|
|
685
|
+
...DOMNodeTransforms,
|
|
686
|
+
...options.nodeTransforms || []
|
|
687
|
+
],
|
|
688
|
+
directiveTransforms: (0, _vue_shared.extend)({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
|
|
689
|
+
transformHoist: stringifyStatic
|
|
690
|
+
}));
|
|
871
691
|
}
|
|
872
692
|
function parse(template, options = {}) {
|
|
873
|
-
|
|
693
|
+
return (0, _vue_compiler_core.baseParse)(template, (0, _vue_shared.extend)({}, parserOptions, options));
|
|
874
694
|
}
|
|
875
|
-
|
|
695
|
+
//#endregion
|
|
876
696
|
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
|
|
877
697
|
exports.DOMErrorCodes = DOMErrorCodes;
|
|
878
698
|
exports.DOMErrorMessages = DOMErrorMessages;
|
|
@@ -896,6 +716,11 @@ exports.parserOptions = parserOptions;
|
|
|
896
716
|
exports.postTransformTransition = postTransformTransition;
|
|
897
717
|
exports.resolveModifiers = resolveModifiers;
|
|
898
718
|
exports.transformStyle = transformStyle;
|
|
899
|
-
Object.keys(
|
|
900
|
-
|
|
719
|
+
Object.keys(_vue_compiler_core).forEach(function(k) {
|
|
720
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
721
|
+
enumerable: true,
|
|
722
|
+
get: function() {
|
|
723
|
+
return _vue_compiler_core[k];
|
|
724
|
+
}
|
|
725
|
+
});
|
|
901
726
|
});
|