@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.
@@ -1,920 +1,723 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-beta.1
3
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
- * @license MIT
5
- **/
6
- 'use strict';
7
-
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`
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(`vModelRadio`);
14
+ const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox`);
15
+ const V_MODEL_TEXT = Symbol(`vModelText`);
16
+ const V_MODEL_SELECT = Symbol(`vModelSelect`);
17
+ const V_MODEL_DYNAMIC = Symbol(`vModelDynamic`);
18
+ const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard`);
19
+ const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard`);
20
+ const V_SHOW = Symbol(`vShow`);
21
+ const TRANSITION = Symbol(`Transition`);
22
+ const TRANSITION_GROUP = Symbol(`TransitionGroup`);
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
- 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
- }
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
- 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
+ //#endregion
84
+ //#region packages/compiler-dom/src/errors.ts
121
85
  function createDOMCompilerError(code, loc) {
122
- return compilerCore.createCompilerError(
123
- code,
124
- loc,
125
- DOMErrorMessages
126
- );
86
+ return (0, _vue_compiler_core.createCompilerError)(code, loc, DOMErrorMessages);
127
87
  }
128
88
  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__"
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
- [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]: ``
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
- 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
- };
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
- 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
- };
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
- 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;
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
+ function checkDuplicatedValue() {
157
+ const value = (0, _vue_compiler_core.findDir)(node, "bind");
158
+ if (value && (0, _vue_compiler_core.isStaticArgOf)(value.arg, "value")) context.onError(createDOMCompilerError(61, value.loc));
159
+ }
160
+ const { tag } = node;
161
+ const isCustomElement = context.isCustomElement(tag);
162
+ if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
163
+ let directiveToUse = V_MODEL_TEXT;
164
+ let isInvalidType = false;
165
+ if (tag === "input" || isCustomElement) {
166
+ const type = (0, _vue_compiler_core.findProp)(node, `type`);
167
+ if (type) {
168
+ if (type.type === 7) directiveToUse = V_MODEL_DYNAMIC;
169
+ else if (type.value) switch (type.value.content) {
170
+ case "radio":
171
+ directiveToUse = V_MODEL_RADIO;
172
+ break;
173
+ case "checkbox":
174
+ directiveToUse = V_MODEL_CHECKBOX;
175
+ break;
176
+ case "file":
177
+ isInvalidType = true;
178
+ context.onError(createDOMCompilerError(60, dir.loc));
179
+ break;
180
+ default:
181
+ checkDuplicatedValue();
182
+ break;
183
+ }
184
+ } else if ((0, _vue_compiler_core.hasDynamicKeyVBind)(node)) directiveToUse = V_MODEL_DYNAMIC;
185
+ else checkDuplicatedValue();
186
+ } else if (tag === "select") directiveToUse = V_MODEL_SELECT;
187
+ else checkDuplicatedValue();
188
+ if (!isInvalidType) baseResult.needRuntime = context.helper(directiveToUse);
189
+ } else context.onError(createDOMCompilerError(58, dir.loc));
190
+ baseResult.props = baseResult.props.filter((p) => !(p.key.type === 4 && p.key.content === "modelValue"));
191
+ return baseResult;
301
192
  };
302
-
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
- );
193
+ //#endregion
194
+ //#region packages/compiler-dom/src/transforms/vOn.ts
195
+ const isEventOptionModifier = /* @__PURE__ */ (0, _vue_shared.makeMap)(`passive,once,capture`);
196
+ const isNonKeyModifier = /* @__PURE__ */ (0, _vue_shared.makeMap)("stop,prevent,self,ctrl,shift,alt,meta,exact,middle");
197
+ const maybeKeyModifier = /* @__PURE__ */ (0, _vue_shared.makeMap)("left,right");
198
+ const isKeyboardEvent = /* @__PURE__ */ (0, _vue_shared.makeMap)(`onkeyup,onkeydown,onkeypress`);
312
199
  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
- };
200
+ const keyModifiers = [];
201
+ const nonKeyModifiers = [];
202
+ const eventOptionModifiers = [];
203
+ for (let i = 0; i < modifiers.length; i++) {
204
+ const modifier = modifiers[i].content;
205
+ if (modifier === "native" && context && (0, _vue_compiler_core.checkCompatEnabled)("COMPILER_V_ON_NATIVE", context, loc)) eventOptionModifiers.push(modifier);
206
+ else if (isEventOptionModifier(modifier)) eventOptionModifiers.push(modifier);
207
+ else {
208
+ const keyString = (0, _vue_shared.isString)(key) ? key : (0, _vue_compiler_core.isStaticExp)(key) ? key.content : null;
209
+ if (maybeKeyModifier(modifier)) if (keyString) if (isKeyboardEvent(keyString.toLowerCase())) keyModifiers.push(modifier);
210
+ else nonKeyModifiers.push(modifier);
211
+ else {
212
+ keyModifiers.push(modifier);
213
+ nonKeyModifiers.push(modifier);
214
+ }
215
+ else if (isNonKeyModifier(modifier)) nonKeyModifiers.push(modifier);
216
+ else keyModifiers.push(modifier);
217
+ }
218
+ }
219
+ return {
220
+ keyModifiers,
221
+ nonKeyModifiers,
222
+ eventOptionModifiers
223
+ };
353
224
  };
354
225
  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;
226
+ 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)([
227
+ `(`,
228
+ key,
229
+ `) === "onClick" ? "${event}" : (`,
230
+ key,
231
+ `)`
232
+ ]) : key;
363
233
  };
364
234
  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
- });
235
+ return (0, _vue_compiler_core.transformOn)(dir, node, context, (baseResult) => {
236
+ const { modifiers } = dir;
237
+ if (!modifiers.length) return baseResult;
238
+ let { key, value: handlerExp } = baseResult.props[0];
239
+ const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
240
+ if (nonKeyModifiers.includes("right")) key = transformClick(key, `onContextmenu`);
241
+ if (nonKeyModifiers.includes("middle")) key = transformClick(key, `onMouseup`);
242
+ if (nonKeyModifiers.length) handlerExp = (0, _vue_compiler_core.createCallExpression)(context.helper(V_ON_WITH_MODIFIERS), [handlerExp, JSON.stringify(nonKeyModifiers)]);
243
+ 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)]);
244
+ if (eventOptionModifiers.length) {
245
+ const modifierPostfix = eventOptionModifiers.map(_vue_shared.capitalize).join("");
246
+ key = (0, _vue_compiler_core.isStaticExp)(key) ? (0, _vue_compiler_core.createSimpleExpression)(`${key.content}${modifierPostfix}`, true) : (0, _vue_compiler_core.createCompoundExpression)([
247
+ `(`,
248
+ key,
249
+ `) + "${modifierPostfix}"`
250
+ ]);
251
+ }
252
+ return { props: [(0, _vue_compiler_core.createObjectProperty)(key, handlerExp)] };
253
+ });
397
254
  };
398
-
255
+ //#endregion
256
+ //#region packages/compiler-dom/src/transforms/vShow.ts
399
257
  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
- };
258
+ const { exp, loc } = dir;
259
+ if (!exp) context.onError(createDOMCompilerError(62, loc));
260
+ return {
261
+ props: [],
262
+ needRuntime: context.helper(V_SHOW)
263
+ };
410
264
  };
411
-
265
+ //#endregion
266
+ //#region packages/compiler-dom/src/transforms/Transition.ts
412
267
  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
- }
268
+ if (node.type === 1 && node.tagType === 1) {
269
+ if (context.isBuiltInComponent(node.tag) === TRANSITION) return postTransformTransition(node, context.onError);
270
+ }
419
271
  };
420
272
  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
- };
273
+ return () => {
274
+ if (!node.children.length) return;
275
+ if (hasMultipleChildren(node)) onError(createDOMCompilerError(63, {
276
+ start: node.children[0].loc.start,
277
+ end: node.children[node.children.length - 1].loc.end,
278
+ source: ""
279
+ }));
280
+ const child = node.children[0];
281
+ if (child.type === 1) {
282
+ for (const p of child.props) if (p.type === 7 && p.name === "show") node.props.push({
283
+ type: 6,
284
+ name: "persisted",
285
+ nameLoc: node.loc,
286
+ value: void 0,
287
+ loc: node.loc
288
+ });
289
+ }
290
+ };
449
291
  }
450
292
  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);
293
+ const children = node.children = node.children.filter((c) => !(0, _vue_compiler_core.isCommentOrWhitespace)(c));
294
+ const child = children[0];
295
+ return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
456
296
  }
457
-
297
+ //#endregion
298
+ //#region packages/compiler-dom/src/transforms/stringifyStatic.ts
299
+ /**
300
+ * This module is Node-only.
301
+ */
302
+ /**
303
+ * Regex for replacing placeholders for embedded constant variables
304
+ * (e.g. import URL string constants generated by compiler-sfc)
305
+ */
458
306
  const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
307
+ /**
308
+ * Turn eligible hoisted static trees into stringified static nodes, e.g.
309
+ *
310
+ * ```js
311
+ * const _hoisted_1 = createStaticVNode(`<div class="foo">bar</div>`)
312
+ * ```
313
+ *
314
+ * A single static vnode can contain stringified content for **multiple**
315
+ * consecutive nodes (element and plain text), called a "chunk".
316
+ * `@vue/runtime-dom` will create the content via innerHTML in a hidden
317
+ * container element and insert all the nodes in place. The call must also
318
+ * provide the number of nodes contained in the chunk so that during hydration
319
+ * we can know how many nodes the static vnode should adopt.
320
+ *
321
+ * The optimization scans a children list that contains hoisted nodes, and
322
+ * tries to find the largest chunk of consecutive hoisted nodes before running
323
+ * into a non-hoisted node or the end of the list. A chunk is then converted
324
+ * into a single static vnode and replaces the hoisted expression of the first
325
+ * node in the chunk. Other nodes in the chunk are considered "merged" and
326
+ * therefore removed from both the hoist list and the children array.
327
+ *
328
+ * This optimization is only performed in Node.js.
329
+ */
459
330
  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);
331
+ if (context.scopes.vSlot > 0) return;
332
+ 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;
333
+ let nc = 0;
334
+ let ec = 0;
335
+ const currentChunk = [];
336
+ const stringifyCurrentChunk = (currentIndex) => {
337
+ if (nc >= 20 || ec >= 5) {
338
+ 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)]);
339
+ const deleteCount = currentChunk.length - 1;
340
+ if (isParentCached) children.splice(currentIndex - currentChunk.length, currentChunk.length, staticCall);
341
+ else {
342
+ currentChunk[0].codegenNode.value = staticCall;
343
+ if (currentChunk.length > 1) {
344
+ children.splice(currentIndex - currentChunk.length + 1, deleteCount);
345
+ const cacheIndex = context.cached.indexOf(currentChunk[currentChunk.length - 1].codegenNode);
346
+ if (cacheIndex > -1) {
347
+ for (let i = cacheIndex; i < context.cached.length; i++) {
348
+ const c = context.cached[i];
349
+ if (c) c.index -= deleteCount;
350
+ }
351
+ context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
352
+ }
353
+ }
354
+ }
355
+ return deleteCount;
356
+ }
357
+ return 0;
358
+ };
359
+ let i = 0;
360
+ for (; i < children.length; i++) {
361
+ const child = children[i];
362
+ if (isParentCached || getCachedNode(child)) {
363
+ const result = analyzeNode(child);
364
+ if (result) {
365
+ nc += result[0];
366
+ ec += result[1];
367
+ currentChunk.push(child);
368
+ continue;
369
+ }
370
+ }
371
+ i -= stringifyCurrentChunk(i);
372
+ nc = 0;
373
+ ec = 0;
374
+ currentChunk.length = 0;
375
+ }
376
+ stringifyCurrentChunk(i);
524
377
  };
525
378
  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
- }
379
+ if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) return node.codegenNode;
529
380
  };
530
381
  const dataAriaRE = /^(?:data|aria)-/;
531
382
  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);
383
+ 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
384
  };
534
- const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
535
- `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
536
- );
385
+ const isNonStringifiable = /* @__PURE__ */ (0, _vue_shared.makeMap)(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
386
+ /**
387
+ * for a cached node, analyze it and return:
388
+ * - false: bailed (contains non-stringifiable props or runtime constant)
389
+ * - [nc, ec] where
390
+ * - nc is the number of nodes inside
391
+ * - ec is the number of element with bindings inside
392
+ */
537
393
  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;
394
+ if (node.type === 1 && isNonStringifiable(node.tag)) return false;
395
+ if (node.type === 1 && (0, _vue_compiler_core.findDir)(node, "once", true)) return false;
396
+ if (node.type === 12) return [1, 0];
397
+ let nc = 1;
398
+ let ec = node.props.length > 0 ? 1 : 0;
399
+ let bailed = false;
400
+ const bail = () => {
401
+ bailed = true;
402
+ return false;
403
+ };
404
+ function walk(node) {
405
+ const isOptionTag = node.tag === "option" && node.ns === 0;
406
+ for (let i = 0; i < node.props.length; i++) {
407
+ const p = node.props[i];
408
+ if (p.type === 6 && !isStringifiableAttr(p.name, node.ns)) return bail();
409
+ if (p.type === 7 && p.name === "bind") {
410
+ if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns))) return bail();
411
+ if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) return bail();
412
+ if (isOptionTag && (0, _vue_compiler_core.isStaticArgOf)(p.arg, "value") && p.exp && !p.exp.isStatic) return bail();
413
+ }
414
+ }
415
+ for (let i = 0; i < node.children.length; i++) {
416
+ nc++;
417
+ const child = node.children[i];
418
+ if (child.type === 1) {
419
+ if (child.props.length > 0) ec++;
420
+ walk(child);
421
+ if (bailed) return false;
422
+ }
423
+ }
424
+ return true;
425
+ }
426
+ return walk(node) ? [nc, ec] : false;
589
427
  }
590
428
  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
- }
429
+ if ((0, _vue_shared.isString)(node)) return node;
430
+ if ((0, _vue_shared.isSymbol)(node)) return ``;
431
+ switch (node.type) {
432
+ case 1: return stringifyElement(node, context);
433
+ case 2: return (0, _vue_shared.escapeHtml)(node.content);
434
+ case 3: return `<!--${(0, _vue_shared.escapeHtml)(node.content)}-->`;
435
+ case 5: return (0, _vue_shared.escapeHtml)((0, _vue_shared.toDisplayString)(evaluateConstant(node.content)));
436
+ case 8: return (0, _vue_shared.escapeHtml)(evaluateConstant(node));
437
+ case 12: return stringifyNode(node.content, context);
438
+ default: return "";
439
+ }
613
440
  }
614
441
  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;
442
+ let res = `<${node.tag}`;
443
+ let innerHTML = "";
444
+ for (let i = 0; i < node.props.length; i++) {
445
+ const p = node.props[i];
446
+ if (p.type === 6) {
447
+ res += ` ${p.name}`;
448
+ if (p.value) res += `="${(0, _vue_shared.escapeHtml)(p.value.content)}"`;
449
+ } else if (p.type === 7) {
450
+ if (p.name === "bind") {
451
+ const exp = p.exp;
452
+ if (exp.content[0] === "_") {
453
+ res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
454
+ continue;
455
+ }
456
+ if ((0, _vue_shared.isBooleanAttr)(p.arg.content) && exp.content === "false") continue;
457
+ let evaluated = evaluateConstant(exp);
458
+ if (evaluated != null) {
459
+ const arg = p.arg && p.arg.content;
460
+ if (arg === "class") evaluated = (0, _vue_shared.normalizeClass)(evaluated);
461
+ else if (arg === "style") evaluated = (0, _vue_shared.stringifyStyle)((0, _vue_shared.normalizeStyle)(evaluated));
462
+ res += ` ${p.arg.content}="${(0, _vue_shared.escapeHtml)(evaluated)}"`;
463
+ }
464
+ } else if (p.name === "html") innerHTML = evaluateConstant(p.exp);
465
+ else if (p.name === "text") innerHTML = (0, _vue_shared.escapeHtml)((0, _vue_shared.toDisplayString)(evaluateConstant(p.exp)));
466
+ }
467
+ }
468
+ if (context.scopeId) res += ` ${context.scopeId}`;
469
+ res += `>`;
470
+ if (innerHTML) res += innerHTML;
471
+ else for (let i = 0; i < node.children.length; i++) res += stringifyNode(node.children[i], context);
472
+ if (!(0, _vue_shared.isVoidTag)(node.tag)) res += `</${node.tag}>`;
473
+ return res;
670
474
  }
671
475
  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
- }
476
+ if (exp.type === 4) return new Function(`return (${exp.content})`)();
477
+ else {
478
+ let res = ``;
479
+ exp.children.forEach((c) => {
480
+ if ((0, _vue_shared.isString)(c) || (0, _vue_shared.isSymbol)(c)) return;
481
+ if (c.type === 2) res += c.content;
482
+ else if (c.type === 5) res += (0, _vue_shared.toDisplayString)(evaluateConstant(c.content));
483
+ else res += evaluateConstant(c);
484
+ });
485
+ return res;
486
+ }
690
487
  }
691
-
488
+ //#endregion
489
+ //#region packages/compiler-dom/src/transforms/ignoreSideEffectTags.ts
692
490
  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
- }
491
+ if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
492
+ context.onError(createDOMCompilerError(64, node.loc));
493
+ context.removeNode();
494
+ }
702
495
  };
703
-
496
+ //#endregion
497
+ //#region packages/compiler-dom/src/htmlNesting.ts
498
+ /**
499
+ * Copied from https://github.com/MananTank/validate-html-nesting
500
+ * with ISC license
501
+ *
502
+ * To avoid runtime dependency on validate-html-nesting
503
+ * This file should not change very often in the original repo
504
+ * but we may need to keep it up-to-date from time to time.
505
+ */
506
+ /**
507
+ * returns true if given parent-child nesting is valid HTML
508
+ */
704
509
  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;
510
+ if (parent === "template") return true;
511
+ if (parent in onlyValidChildren) return onlyValidChildren[parent].has(child);
512
+ if (child in onlyValidParents) return onlyValidParents[child].has(parent);
513
+ if (parent in knownInvalidChildren) {
514
+ if (knownInvalidChildren[parent].has(child)) return false;
515
+ }
516
+ if (child in knownInvalidParents) {
517
+ if (knownInvalidParents[child].has(parent)) return false;
518
+ }
519
+ return true;
721
520
  }
722
- const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
521
+ const headings = new Set([
522
+ "h1",
523
+ "h2",
524
+ "h3",
525
+ "h4",
526
+ "h5",
527
+ "h6"
528
+ ]);
723
529
  const emptySet = /* @__PURE__ */ new Set([]);
530
+ /**
531
+ * maps element to set of elements that can be it's children, no other */
724
532
  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
533
+ head: new Set([
534
+ "base",
535
+ "basefront",
536
+ "bgsound",
537
+ "link",
538
+ "meta",
539
+ "title",
540
+ "noscript",
541
+ "noframes",
542
+ "style",
543
+ "script",
544
+ "template"
545
+ ]),
546
+ optgroup: new Set(["option"]),
547
+ select: new Set([
548
+ "optgroup",
549
+ "option",
550
+ "hr"
551
+ ]),
552
+ table: new Set([
553
+ "caption",
554
+ "colgroup",
555
+ "tbody",
556
+ "tfoot",
557
+ "thead"
558
+ ]),
559
+ tr: new Set(["td", "th"]),
560
+ colgroup: new Set(["col"]),
561
+ tbody: new Set(["tr"]),
562
+ thead: new Set(["tr"]),
563
+ tfoot: new Set(["tr"]),
564
+ script: emptySet,
565
+ iframe: emptySet,
566
+ option: emptySet,
567
+ textarea: emptySet,
568
+ style: emptySet,
569
+ title: emptySet
754
570
  };
571
+ /** maps elements to set of elements which can be it's parent, no other */
755
572
  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"])
573
+ html: emptySet,
574
+ body: new Set(["html"]),
575
+ head: new Set(["html"]),
576
+ td: new Set(["tr"]),
577
+ colgroup: new Set(["table"]),
578
+ caption: new Set(["table"]),
579
+ tbody: new Set(["table"]),
580
+ tfoot: new Set(["table"]),
581
+ col: new Set(["colgroup"]),
582
+ th: new Set(["tr"]),
583
+ thead: new Set(["table"]),
584
+ tr: new Set([
585
+ "tbody",
586
+ "thead",
587
+ "tfoot"
588
+ ]),
589
+ dd: new Set(["dl", "div"]),
590
+ dt: new Set(["dl", "div"]),
591
+ figcaption: new Set(["figure"]),
592
+ summary: new Set(["details"]),
593
+ area: new Set(["map"])
778
594
  };
595
+ /** maps element to set of elements that can not be it's children, others can */
779
596
  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
- ])
597
+ p: new Set([
598
+ "address",
599
+ "article",
600
+ "aside",
601
+ "blockquote",
602
+ "center",
603
+ "details",
604
+ "dialog",
605
+ "dir",
606
+ "div",
607
+ "dl",
608
+ "fieldset",
609
+ "figure",
610
+ "footer",
611
+ "form",
612
+ "h1",
613
+ "h2",
614
+ "h3",
615
+ "h4",
616
+ "h5",
617
+ "h6",
618
+ "header",
619
+ "hgroup",
620
+ "hr",
621
+ "li",
622
+ "main",
623
+ "nav",
624
+ "menu",
625
+ "ol",
626
+ "p",
627
+ "pre",
628
+ "section",
629
+ "table",
630
+ "ul"
631
+ ]),
632
+ svg: new Set([
633
+ "b",
634
+ "blockquote",
635
+ "br",
636
+ "code",
637
+ "dd",
638
+ "div",
639
+ "dl",
640
+ "dt",
641
+ "em",
642
+ "embed",
643
+ "h1",
644
+ "h2",
645
+ "h3",
646
+ "h4",
647
+ "h5",
648
+ "h6",
649
+ "hr",
650
+ "i",
651
+ "img",
652
+ "li",
653
+ "menu",
654
+ "meta",
655
+ "ol",
656
+ "p",
657
+ "pre",
658
+ "ruby",
659
+ "s",
660
+ "small",
661
+ "span",
662
+ "strong",
663
+ "sub",
664
+ "sup",
665
+ "table",
666
+ "u",
667
+ "ul",
668
+ "var"
669
+ ])
853
670
  };
671
+ /** maps element to set of elements that can not be it's parent, others can */
854
672
  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
673
+ a: new Set(["a"]),
674
+ button: new Set(["button"]),
675
+ dd: new Set(["dd", "dt"]),
676
+ dt: new Set(["dd", "dt"]),
677
+ form: new Set(["form"]),
678
+ li: new Set(["li"]),
679
+ h1: headings,
680
+ h2: headings,
681
+ h3: headings,
682
+ h4: headings,
683
+ h5: headings,
684
+ h6: headings
867
685
  };
868
-
686
+ //#endregion
687
+ //#region packages/compiler-dom/src/transforms/validateHtmlNesting.ts
869
688
  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
- }
689
+ if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
690
+ 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.`);
691
+ error.loc = node.loc;
692
+ context.onWarn(error);
693
+ }
877
694
  };
878
-
879
- const DOMNodeTransforms = [
880
- transformStyle,
881
- ...[transformTransition, validateHtmlNesting]
882
- ];
695
+ //#endregion
696
+ //#region packages/compiler-dom/src/index.ts
697
+ const DOMNodeTransforms = [transformStyle, ...[transformTransition, validateHtmlNesting]];
883
698
  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
699
+ cloak: _vue_compiler_core.noopDirectiveTransform,
700
+ html: transformVHtml,
701
+ text: transformVText,
702
+ model: transformModel,
703
+ on: transformOn,
704
+ show: transformShow
892
705
  };
893
706
  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
- );
707
+ return (0, _vue_compiler_core.baseCompile)(src, (0, _vue_shared.extend)({}, parserOptions, options, {
708
+ nodeTransforms: [
709
+ ignoreSideEffectTags,
710
+ ...DOMNodeTransforms,
711
+ ...options.nodeTransforms || []
712
+ ],
713
+ directiveTransforms: (0, _vue_shared.extend)({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
714
+ transformHoist: stringifyStatic
715
+ }));
913
716
  }
914
717
  function parse(template, options = {}) {
915
- return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
718
+ return (0, _vue_compiler_core.baseParse)(template, (0, _vue_shared.extend)({}, parserOptions, options));
916
719
  }
917
-
720
+ //#endregion
918
721
  exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
919
722
  exports.DOMErrorCodes = DOMErrorCodes;
920
723
  exports.DOMErrorMessages = DOMErrorMessages;
@@ -938,6 +741,11 @@ exports.parserOptions = parserOptions;
938
741
  exports.postTransformTransition = postTransformTransition;
939
742
  exports.resolveModifiers = resolveModifiers;
940
743
  exports.transformStyle = transformStyle;
941
- Object.keys(compilerCore).forEach(function (k) {
942
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = compilerCore[k];
744
+ Object.keys(_vue_compiler_core).forEach(function(k) {
745
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
746
+ enumerable: true,
747
+ get: function() {
748
+ return _vue_compiler_core[k];
749
+ }
750
+ });
943
751
  });