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