@vue/compiler-dom 3.6.0-beta.4 → 3.6.0-beta.6

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