@vue/compiler-dom 3.6.0-alpha.7 → 3.6.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-dom.cjs.js +656 -848
- package/dist/compiler-dom.cjs.prod.js +631 -806
- package/dist/compiler-dom.d.ts +43 -35
- package/dist/compiler-dom.esm-browser.js +4505 -6227
- package/dist/compiler-dom.esm-browser.prod.js +10 -13
- package/dist/compiler-dom.esm-bundler.js +476 -631
- package/dist/compiler-dom.global.js +5169 -6893
- package/dist/compiler-dom.global.prod.js +10 -13
- package/package.json +3 -3
|
@@ -1,695 +1,540 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-dom v3.6.0-
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
* @vue/compiler-dom v3.6.0-beta.10
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
import { TO_DISPLAY_STRING, baseCompile, baseParse, checkCompatEnabled, createCallExpression, createCompilerError, createCompoundExpression, createObjectProperty, createSimpleExpression, findDir, findProp, getConstantType, hasDynamicKeyVBind, isCommentOrWhitespace, isStaticArgOf, isStaticExp, noopDirectiveTransform, registerRuntimeHelpers, transformModel, transformOn } from "@vue/compiler-core";
|
|
7
|
+
import { capitalize, extend, isHTMLTag, isMathMLTag, isSVGTag, isString, isVoidTag, makeMap, parseStringStyle } from "@vue/shared";
|
|
8
|
+
export * from "@vue/compiler-core";
|
|
9
|
+
//#region packages/compiler-dom/src/runtimeHelpers.ts
|
|
10
10
|
const V_MODEL_RADIO = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelRadio` : ``);
|
|
11
|
-
const V_MODEL_CHECKBOX = Symbol(
|
|
12
|
-
!!(process.env.NODE_ENV !== "production") ? `vModelCheckbox` : ``
|
|
13
|
-
);
|
|
11
|
+
const V_MODEL_CHECKBOX = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelCheckbox` : ``);
|
|
14
12
|
const V_MODEL_TEXT = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelText` : ``);
|
|
15
|
-
const V_MODEL_SELECT = Symbol(
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
const
|
|
19
|
-
!!(process.env.NODE_ENV !== "production") ? `vModelDynamic` : ``
|
|
20
|
-
);
|
|
21
|
-
const V_ON_WITH_MODIFIERS = Symbol(
|
|
22
|
-
!!(process.env.NODE_ENV !== "production") ? `vOnModifiersGuard` : ``
|
|
23
|
-
);
|
|
24
|
-
const V_ON_WITH_KEYS = Symbol(
|
|
25
|
-
!!(process.env.NODE_ENV !== "production") ? `vOnKeysGuard` : ``
|
|
26
|
-
);
|
|
13
|
+
const V_MODEL_SELECT = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelSelect` : ``);
|
|
14
|
+
const V_MODEL_DYNAMIC = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelDynamic` : ``);
|
|
15
|
+
const V_ON_WITH_MODIFIERS = Symbol(!!(process.env.NODE_ENV !== "production") ? `vOnModifiersGuard` : ``);
|
|
16
|
+
const V_ON_WITH_KEYS = Symbol(!!(process.env.NODE_ENV !== "production") ? `vOnKeysGuard` : ``);
|
|
27
17
|
const V_SHOW = Symbol(!!(process.env.NODE_ENV !== "production") ? `vShow` : ``);
|
|
28
18
|
const TRANSITION = Symbol(!!(process.env.NODE_ENV !== "production") ? `Transition` : ``);
|
|
29
|
-
const TRANSITION_GROUP = Symbol(
|
|
30
|
-
!!(process.env.NODE_ENV !== "production") ? `TransitionGroup` : ``
|
|
31
|
-
);
|
|
19
|
+
const TRANSITION_GROUP = Symbol(!!(process.env.NODE_ENV !== "production") ? `TransitionGroup` : ``);
|
|
32
20
|
registerRuntimeHelpers({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
[V_MODEL_RADIO]: `vModelRadio`,
|
|
22
|
+
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
|
23
|
+
[V_MODEL_TEXT]: `vModelText`,
|
|
24
|
+
[V_MODEL_SELECT]: `vModelSelect`,
|
|
25
|
+
[V_MODEL_DYNAMIC]: `vModelDynamic`,
|
|
26
|
+
[V_ON_WITH_MODIFIERS]: `withModifiers`,
|
|
27
|
+
[V_ON_WITH_KEYS]: `withKeys`,
|
|
28
|
+
[V_SHOW]: `vShow`,
|
|
29
|
+
[TRANSITION]: `Transition`,
|
|
30
|
+
[TRANSITION_GROUP]: `TransitionGroup`
|
|
43
31
|
});
|
|
44
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region packages/compiler-dom/src/decodeHtmlBrowser.ts
|
|
45
34
|
let decoder;
|
|
46
35
|
function decodeHtmlBrowser(raw, asAttr = false) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return decoder.textContent;
|
|
56
|
-
}
|
|
36
|
+
if (!decoder) decoder = document.createElement("div");
|
|
37
|
+
if (asAttr) {
|
|
38
|
+
decoder.innerHTML = `<div foo="${raw.replace(/"/g, """)}">`;
|
|
39
|
+
return decoder.children[0].getAttribute("foo");
|
|
40
|
+
} else {
|
|
41
|
+
decoder.innerHTML = raw;
|
|
42
|
+
return decoder.textContent;
|
|
43
|
+
}
|
|
57
44
|
}
|
|
58
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region packages/compiler-dom/src/parserOptions.ts
|
|
59
47
|
const parserOptions = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
|
87
|
-
ns = 0;
|
|
88
|
-
}
|
|
89
|
-
} else if (parent && ns === 1) {
|
|
90
|
-
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
|
91
|
-
ns = 0;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (ns === 0) {
|
|
95
|
-
if (isSVGTag(tag)) {
|
|
96
|
-
return 1;
|
|
97
|
-
}
|
|
98
|
-
if (isMathMLTag(tag)) {
|
|
99
|
-
return 2;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return ns;
|
|
103
|
-
}
|
|
48
|
+
parseMode: "html",
|
|
49
|
+
isVoidTag,
|
|
50
|
+
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
|
51
|
+
isPreTag: (tag) => tag === "pre",
|
|
52
|
+
isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
|
|
53
|
+
decodeEntities: decodeHtmlBrowser,
|
|
54
|
+
isBuiltInComponent: (tag) => {
|
|
55
|
+
if (tag === "Transition" || tag === "transition") return TRANSITION;
|
|
56
|
+
else if (tag === "TransitionGroup" || tag === "transition-group") return TRANSITION_GROUP;
|
|
57
|
+
},
|
|
58
|
+
getNamespace(tag, parent, rootNamespace) {
|
|
59
|
+
let ns = parent ? parent.ns : rootNamespace;
|
|
60
|
+
if (parent && ns === 2) {
|
|
61
|
+
if (parent.tag === "annotation-xml") {
|
|
62
|
+
if (isSVGTag(tag)) return 1;
|
|
63
|
+
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;
|
|
64
|
+
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") ns = 0;
|
|
65
|
+
} else if (parent && ns === 1) {
|
|
66
|
+
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") ns = 0;
|
|
67
|
+
}
|
|
68
|
+
if (ns === 0) {
|
|
69
|
+
if (isSVGTag(tag)) return 1;
|
|
70
|
+
if (isMathMLTag(tag)) return 2;
|
|
71
|
+
}
|
|
72
|
+
return ns;
|
|
73
|
+
}
|
|
104
74
|
};
|
|
105
|
-
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region packages/compiler-dom/src/transforms/transformStyle.ts
|
|
106
77
|
const transformStyle = (node) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
78
|
+
if (node.type === 1) node.props.forEach((p, i) => {
|
|
79
|
+
if (p.type === 6 && p.name === "style" && p.value) node.props[i] = {
|
|
80
|
+
type: 7,
|
|
81
|
+
name: `bind`,
|
|
82
|
+
arg: createSimpleExpression(`style`, true, p.loc),
|
|
83
|
+
exp: parseInlineCSS(p.value.content, p.loc),
|
|
84
|
+
modifiers: [],
|
|
85
|
+
loc: p.loc
|
|
86
|
+
};
|
|
87
|
+
});
|
|
121
88
|
};
|
|
122
89
|
const parseInlineCSS = (cssText, loc) => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
JSON.stringify(normalized),
|
|
126
|
-
false,
|
|
127
|
-
loc,
|
|
128
|
-
3
|
|
129
|
-
);
|
|
90
|
+
const normalized = parseStringStyle(cssText);
|
|
91
|
+
return createSimpleExpression(JSON.stringify(normalized), false, loc, 3);
|
|
130
92
|
};
|
|
131
|
-
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region packages/compiler-dom/src/errors.ts
|
|
132
95
|
function createDOMCompilerError(code, loc) {
|
|
133
|
-
|
|
134
|
-
code,
|
|
135
|
-
loc,
|
|
136
|
-
!!(process.env.NODE_ENV !== "production") || false ? DOMErrorMessages : void 0
|
|
137
|
-
);
|
|
96
|
+
return createCompilerError(code, loc, !!(process.env.NODE_ENV !== "production") || false ? DOMErrorMessages : void 0);
|
|
138
97
|
}
|
|
139
98
|
const DOMErrorCodes = {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
99
|
+
"X_V_HTML_NO_EXPRESSION": 54,
|
|
100
|
+
"54": "X_V_HTML_NO_EXPRESSION",
|
|
101
|
+
"X_V_HTML_WITH_CHILDREN": 55,
|
|
102
|
+
"55": "X_V_HTML_WITH_CHILDREN",
|
|
103
|
+
"X_V_TEXT_NO_EXPRESSION": 56,
|
|
104
|
+
"56": "X_V_TEXT_NO_EXPRESSION",
|
|
105
|
+
"X_V_TEXT_WITH_CHILDREN": 57,
|
|
106
|
+
"57": "X_V_TEXT_WITH_CHILDREN",
|
|
107
|
+
"X_V_MODEL_ON_INVALID_ELEMENT": 58,
|
|
108
|
+
"58": "X_V_MODEL_ON_INVALID_ELEMENT",
|
|
109
|
+
"X_V_MODEL_ARG_ON_ELEMENT": 59,
|
|
110
|
+
"59": "X_V_MODEL_ARG_ON_ELEMENT",
|
|
111
|
+
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 60,
|
|
112
|
+
"60": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
|
|
113
|
+
"X_V_MODEL_UNNECESSARY_VALUE": 61,
|
|
114
|
+
"61": "X_V_MODEL_UNNECESSARY_VALUE",
|
|
115
|
+
"X_V_SHOW_NO_EXPRESSION": 62,
|
|
116
|
+
"62": "X_V_SHOW_NO_EXPRESSION",
|
|
117
|
+
"X_TRANSITION_INVALID_CHILDREN": 63,
|
|
118
|
+
"63": "X_TRANSITION_INVALID_CHILDREN",
|
|
119
|
+
"X_IGNORED_SIDE_EFFECT_TAG": 64,
|
|
120
|
+
"64": "X_IGNORED_SIDE_EFFECT_TAG",
|
|
121
|
+
"__EXTEND_POINT__": 65,
|
|
122
|
+
"65": "__EXTEND_POINT__"
|
|
164
123
|
};
|
|
165
124
|
const DOMErrorMessages = {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
[64]: ``
|
|
125
|
+
[54]: `v-html is missing expression.`,
|
|
126
|
+
[55]: `v-html will override element children.`,
|
|
127
|
+
[56]: `v-text is missing expression.`,
|
|
128
|
+
[57]: `v-text will override element children.`,
|
|
129
|
+
[58]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
|
130
|
+
[59]: `v-model argument is not supported on plain elements.`,
|
|
131
|
+
[60]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
|
132
|
+
[61]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
|
133
|
+
[62]: `v-show is missing expression.`,
|
|
134
|
+
[63]: `<Transition> expects exactly one child element or component.`,
|
|
135
|
+
[64]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`,
|
|
136
|
+
[65]: ``
|
|
179
137
|
};
|
|
180
|
-
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region packages/compiler-dom/src/transforms/vHtml.ts
|
|
181
140
|
const transformVHtml = (dir, node, context) => {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
context.onError(
|
|
190
|
-
createDOMCompilerError(54, loc)
|
|
191
|
-
);
|
|
192
|
-
node.children.length = 0;
|
|
193
|
-
}
|
|
194
|
-
return {
|
|
195
|
-
props: [
|
|
196
|
-
createObjectProperty(
|
|
197
|
-
createSimpleExpression(`innerHTML`, true, loc),
|
|
198
|
-
exp || createSimpleExpression("", true)
|
|
199
|
-
)
|
|
200
|
-
]
|
|
201
|
-
};
|
|
141
|
+
const { exp, loc } = dir;
|
|
142
|
+
if (!exp) context.onError(createDOMCompilerError(54, loc));
|
|
143
|
+
if (node.children.length) {
|
|
144
|
+
context.onError(createDOMCompilerError(55, loc));
|
|
145
|
+
node.children.length = 0;
|
|
146
|
+
}
|
|
147
|
+
return { props: [createObjectProperty(createSimpleExpression(`innerHTML`, true, loc), exp || createSimpleExpression("", true))] };
|
|
202
148
|
};
|
|
203
|
-
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region packages/compiler-dom/src/transforms/vText.ts
|
|
204
151
|
const transformVText = (dir, node, context) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
context.onError(
|
|
213
|
-
createDOMCompilerError(56, loc)
|
|
214
|
-
);
|
|
215
|
-
node.children.length = 0;
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
props: [
|
|
219
|
-
createObjectProperty(
|
|
220
|
-
createSimpleExpression(`textContent`, true),
|
|
221
|
-
exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
|
|
222
|
-
context.helperString(TO_DISPLAY_STRING),
|
|
223
|
-
[exp],
|
|
224
|
-
loc
|
|
225
|
-
) : createSimpleExpression("", true)
|
|
226
|
-
)
|
|
227
|
-
]
|
|
228
|
-
};
|
|
152
|
+
const { exp, loc } = dir;
|
|
153
|
+
if (!exp) context.onError(createDOMCompilerError(56, loc));
|
|
154
|
+
if (node.children.length) {
|
|
155
|
+
context.onError(createDOMCompilerError(57, loc));
|
|
156
|
+
node.children.length = 0;
|
|
157
|
+
}
|
|
158
|
+
return { props: [createObjectProperty(createSimpleExpression(`textContent`, true), exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc) : createSimpleExpression("", true))] };
|
|
229
159
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
break;
|
|
273
|
-
case "file":
|
|
274
|
-
isInvalidType = true;
|
|
275
|
-
context.onError(
|
|
276
|
-
createDOMCompilerError(
|
|
277
|
-
59,
|
|
278
|
-
dir.loc
|
|
279
|
-
)
|
|
280
|
-
);
|
|
281
|
-
break;
|
|
282
|
-
default:
|
|
283
|
-
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
} else if (hasDynamicKeyVBind(node)) {
|
|
288
|
-
directiveToUse = V_MODEL_DYNAMIC;
|
|
289
|
-
} else {
|
|
290
|
-
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
|
|
291
|
-
}
|
|
292
|
-
} else if (tag === "select") {
|
|
293
|
-
directiveToUse = V_MODEL_SELECT;
|
|
294
|
-
} else {
|
|
295
|
-
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
|
|
296
|
-
}
|
|
297
|
-
if (!isInvalidType) {
|
|
298
|
-
baseResult.needRuntime = context.helper(directiveToUse);
|
|
299
|
-
}
|
|
300
|
-
} else {
|
|
301
|
-
context.onError(
|
|
302
|
-
createDOMCompilerError(
|
|
303
|
-
57,
|
|
304
|
-
dir.loc
|
|
305
|
-
)
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
baseResult.props = baseResult.props.filter(
|
|
309
|
-
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
|
310
|
-
);
|
|
311
|
-
return baseResult;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region packages/compiler-dom/src/transforms/vModel.ts
|
|
162
|
+
const transformModel$1 = (dir, node, context) => {
|
|
163
|
+
const baseResult = transformModel(dir, node, context);
|
|
164
|
+
if (!baseResult.props.length || node.tagType === 1) return baseResult;
|
|
165
|
+
if (dir.arg) context.onError(createDOMCompilerError(59, dir.arg.loc));
|
|
166
|
+
function checkDuplicatedValue() {
|
|
167
|
+
const value = findDir(node, "bind");
|
|
168
|
+
if (value && isStaticArgOf(value.arg, "value")) context.onError(createDOMCompilerError(61, value.loc));
|
|
169
|
+
}
|
|
170
|
+
const { tag } = node;
|
|
171
|
+
const isCustomElement = context.isCustomElement(tag);
|
|
172
|
+
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
|
173
|
+
let directiveToUse = V_MODEL_TEXT;
|
|
174
|
+
let isInvalidType = false;
|
|
175
|
+
if (tag === "input" || isCustomElement) {
|
|
176
|
+
const type = findProp(node, `type`);
|
|
177
|
+
if (type) {
|
|
178
|
+
if (type.type === 7) directiveToUse = V_MODEL_DYNAMIC;
|
|
179
|
+
else if (type.value) switch (type.value.content) {
|
|
180
|
+
case "radio":
|
|
181
|
+
directiveToUse = V_MODEL_RADIO;
|
|
182
|
+
break;
|
|
183
|
+
case "checkbox":
|
|
184
|
+
directiveToUse = V_MODEL_CHECKBOX;
|
|
185
|
+
break;
|
|
186
|
+
case "file":
|
|
187
|
+
isInvalidType = true;
|
|
188
|
+
context.onError(createDOMCompilerError(60, dir.loc));
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
process.env.NODE_ENV !== "production" && checkDuplicatedValue();
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
} else if (hasDynamicKeyVBind(node)) directiveToUse = V_MODEL_DYNAMIC;
|
|
195
|
+
else process.env.NODE_ENV !== "production" && checkDuplicatedValue();
|
|
196
|
+
} else if (tag === "select") directiveToUse = V_MODEL_SELECT;
|
|
197
|
+
else process.env.NODE_ENV !== "production" && checkDuplicatedValue();
|
|
198
|
+
if (!isInvalidType) baseResult.needRuntime = context.helper(directiveToUse);
|
|
199
|
+
} else context.onError(createDOMCompilerError(58, dir.loc));
|
|
200
|
+
baseResult.props = baseResult.props.filter((p) => !(p.key.type === 4 && p.key.content === "modelValue"));
|
|
201
|
+
return baseResult;
|
|
312
202
|
};
|
|
313
|
-
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region packages/compiler-dom/src/transforms/vOn.ts
|
|
314
205
|
const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
|
|
315
|
-
const isNonKeyModifier = /* @__PURE__ */ makeMap(
|
|
316
|
-
// event propagation management
|
|
317
|
-
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
|
318
|
-
);
|
|
206
|
+
const isNonKeyModifier = /* @__PURE__ */ makeMap("stop,prevent,self,ctrl,shift,alt,meta,exact,middle");
|
|
319
207
|
const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
|
|
320
|
-
const isKeyboardEvent = /* @__PURE__ */ makeMap(
|
|
321
|
-
`onkeyup,onkeydown,onkeypress`
|
|
322
|
-
);
|
|
208
|
+
const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
|
|
323
209
|
const resolveModifiers = (key, modifiers, context, loc) => {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
nonKeyModifiers.push(modifier);
|
|
349
|
-
}
|
|
350
|
-
} else {
|
|
351
|
-
if (isNonKeyModifier(modifier)) {
|
|
352
|
-
nonKeyModifiers.push(modifier);
|
|
353
|
-
} else {
|
|
354
|
-
keyModifiers.push(modifier);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return {
|
|
360
|
-
keyModifiers,
|
|
361
|
-
nonKeyModifiers,
|
|
362
|
-
eventOptionModifiers
|
|
363
|
-
};
|
|
210
|
+
const keyModifiers = [];
|
|
211
|
+
const nonKeyModifiers = [];
|
|
212
|
+
const eventOptionModifiers = [];
|
|
213
|
+
for (let i = 0; i < modifiers.length; i++) {
|
|
214
|
+
const modifier = modifiers[i].content;
|
|
215
|
+
if (modifier === "native" && context && checkCompatEnabled("COMPILER_V_ON_NATIVE", context, loc)) eventOptionModifiers.push(modifier);
|
|
216
|
+
else if (isEventOptionModifier(modifier)) eventOptionModifiers.push(modifier);
|
|
217
|
+
else {
|
|
218
|
+
const keyString = isString(key) ? key : isStaticExp(key) ? key.content : null;
|
|
219
|
+
if (maybeKeyModifier(modifier)) if (keyString) if (isKeyboardEvent(keyString.toLowerCase())) keyModifiers.push(modifier);
|
|
220
|
+
else nonKeyModifiers.push(modifier);
|
|
221
|
+
else {
|
|
222
|
+
keyModifiers.push(modifier);
|
|
223
|
+
nonKeyModifiers.push(modifier);
|
|
224
|
+
}
|
|
225
|
+
else if (isNonKeyModifier(modifier)) nonKeyModifiers.push(modifier);
|
|
226
|
+
else keyModifiers.push(modifier);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
keyModifiers,
|
|
231
|
+
nonKeyModifiers,
|
|
232
|
+
eventOptionModifiers
|
|
233
|
+
};
|
|
364
234
|
};
|
|
365
235
|
const transformClick = (key, event) => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
]) : key;
|
|
236
|
+
return isStaticExp(key) && key.content.toLowerCase() === "onclick" ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
|
|
237
|
+
`(`,
|
|
238
|
+
key,
|
|
239
|
+
`) === "onClick" ? "${event}" : (`,
|
|
240
|
+
key,
|
|
241
|
+
`)`
|
|
242
|
+
]) : key;
|
|
374
243
|
};
|
|
375
|
-
const transformOn = (dir, node, context) => {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
|
396
|
-
handlerExp,
|
|
397
|
-
JSON.stringify(keyModifiers)
|
|
398
|
-
]);
|
|
399
|
-
}
|
|
400
|
-
if (eventOptionModifiers.length) {
|
|
401
|
-
const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
|
|
402
|
-
key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
|
403
|
-
}
|
|
404
|
-
return {
|
|
405
|
-
props: [createObjectProperty(key, handlerExp)]
|
|
406
|
-
};
|
|
407
|
-
});
|
|
244
|
+
const transformOn$1 = (dir, node, context) => {
|
|
245
|
+
return transformOn(dir, node, context, (baseResult) => {
|
|
246
|
+
const { modifiers } = dir;
|
|
247
|
+
if (!modifiers.length) return baseResult;
|
|
248
|
+
let { key, value: handlerExp } = baseResult.props[0];
|
|
249
|
+
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
|
250
|
+
if (nonKeyModifiers.includes("right")) key = transformClick(key, `onContextmenu`);
|
|
251
|
+
if (nonKeyModifiers.includes("middle")) key = transformClick(key, `onMouseup`);
|
|
252
|
+
if (nonKeyModifiers.length) handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [handlerExp, JSON.stringify(nonKeyModifiers)]);
|
|
253
|
+
if (keyModifiers.length && (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [handlerExp, JSON.stringify(keyModifiers)]);
|
|
254
|
+
if (eventOptionModifiers.length) {
|
|
255
|
+
const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
|
|
256
|
+
key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([
|
|
257
|
+
`(`,
|
|
258
|
+
key,
|
|
259
|
+
`) + "${modifierPostfix}"`
|
|
260
|
+
]);
|
|
261
|
+
}
|
|
262
|
+
return { props: [createObjectProperty(key, handlerExp)] };
|
|
263
|
+
});
|
|
408
264
|
};
|
|
409
|
-
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region packages/compiler-dom/src/transforms/vShow.ts
|
|
410
267
|
const transformShow = (dir, node, context) => {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return {
|
|
418
|
-
props: [],
|
|
419
|
-
needRuntime: context.helper(V_SHOW)
|
|
420
|
-
};
|
|
268
|
+
const { exp, loc } = dir;
|
|
269
|
+
if (!exp) context.onError(createDOMCompilerError(62, loc));
|
|
270
|
+
return {
|
|
271
|
+
props: [],
|
|
272
|
+
needRuntime: context.helper(V_SHOW)
|
|
273
|
+
};
|
|
421
274
|
};
|
|
422
|
-
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region packages/compiler-dom/src/transforms/Transition.ts
|
|
423
277
|
const transformTransition = (node, context) => {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return postTransformTransition(node, context.onError);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
278
|
+
if (node.type === 1 && node.tagType === 1) {
|
|
279
|
+
if (context.isBuiltInComponent(node.tag) === TRANSITION) return postTransformTransition(node, context.onError);
|
|
280
|
+
}
|
|
430
281
|
};
|
|
431
282
|
function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
type: 6,
|
|
451
|
-
name: "persisted",
|
|
452
|
-
nameLoc: node.loc,
|
|
453
|
-
value: void 0,
|
|
454
|
-
loc: node.loc
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
};
|
|
283
|
+
return () => {
|
|
284
|
+
if (!node.children.length) return;
|
|
285
|
+
if (hasMultipleChildren(node)) onError(createDOMCompilerError(63, {
|
|
286
|
+
start: node.children[0].loc.start,
|
|
287
|
+
end: node.children[node.children.length - 1].loc.end,
|
|
288
|
+
source: ""
|
|
289
|
+
}));
|
|
290
|
+
const child = node.children[0];
|
|
291
|
+
if (child.type === 1) {
|
|
292
|
+
for (const p of child.props) if (p.type === 7 && p.name === "show") node.props.push({
|
|
293
|
+
type: 6,
|
|
294
|
+
name: "persisted",
|
|
295
|
+
nameLoc: node.loc,
|
|
296
|
+
value: void 0,
|
|
297
|
+
loc: node.loc
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
};
|
|
460
301
|
}
|
|
461
302
|
function defaultHasMultipleChildren(node) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const child = children[0];
|
|
466
|
-
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
|
|
303
|
+
const children = node.children = node.children.filter((c) => !isCommentOrWhitespace(c));
|
|
304
|
+
const child = children[0];
|
|
305
|
+
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
|
|
467
306
|
}
|
|
468
|
-
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region packages/compiler-dom/src/transforms/ignoreSideEffectTags.ts
|
|
469
309
|
const ignoreSideEffectTags = (node, context) => {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
node.loc
|
|
475
|
-
)
|
|
476
|
-
);
|
|
477
|
-
context.removeNode();
|
|
478
|
-
}
|
|
310
|
+
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
|
311
|
+
process.env.NODE_ENV !== "production" && context.onError(createDOMCompilerError(64, node.loc));
|
|
312
|
+
context.removeNode();
|
|
313
|
+
}
|
|
479
314
|
};
|
|
480
|
-
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region packages/compiler-dom/src/htmlNesting.ts
|
|
317
|
+
/**
|
|
318
|
+
* Copied from https://github.com/MananTank/validate-html-nesting
|
|
319
|
+
* with ISC license
|
|
320
|
+
*
|
|
321
|
+
* To avoid runtime dependency on validate-html-nesting
|
|
322
|
+
* This file should not change very often in the original repo
|
|
323
|
+
* but we may need to keep it up-to-date from time to time.
|
|
324
|
+
*/
|
|
325
|
+
/**
|
|
326
|
+
* returns true if given parent-child nesting is valid HTML
|
|
327
|
+
*/
|
|
481
328
|
function isValidHTMLNesting(parent, child) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (knownInvalidChildren[parent].has(child)) return false;
|
|
493
|
-
}
|
|
494
|
-
if (child in knownInvalidParents) {
|
|
495
|
-
if (knownInvalidParents[child].has(parent)) return false;
|
|
496
|
-
}
|
|
497
|
-
return true;
|
|
329
|
+
if (parent === "template") return true;
|
|
330
|
+
if (parent in onlyValidChildren) return onlyValidChildren[parent].has(child);
|
|
331
|
+
if (child in onlyValidParents) return onlyValidParents[child].has(parent);
|
|
332
|
+
if (parent in knownInvalidChildren) {
|
|
333
|
+
if (knownInvalidChildren[parent].has(child)) return false;
|
|
334
|
+
}
|
|
335
|
+
if (child in knownInvalidParents) {
|
|
336
|
+
if (knownInvalidParents[child].has(parent)) return false;
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
498
339
|
}
|
|
499
|
-
const headings =
|
|
340
|
+
const headings = new Set([
|
|
341
|
+
"h1",
|
|
342
|
+
"h2",
|
|
343
|
+
"h3",
|
|
344
|
+
"h4",
|
|
345
|
+
"h5",
|
|
346
|
+
"h6"
|
|
347
|
+
]);
|
|
500
348
|
const emptySet = /* @__PURE__ */ new Set([]);
|
|
349
|
+
/**
|
|
350
|
+
* maps element to set of elements that can be it's children, no other */
|
|
501
351
|
const onlyValidChildren = {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
352
|
+
head: new Set([
|
|
353
|
+
"base",
|
|
354
|
+
"basefront",
|
|
355
|
+
"bgsound",
|
|
356
|
+
"link",
|
|
357
|
+
"meta",
|
|
358
|
+
"title",
|
|
359
|
+
"noscript",
|
|
360
|
+
"noframes",
|
|
361
|
+
"style",
|
|
362
|
+
"script",
|
|
363
|
+
"template"
|
|
364
|
+
]),
|
|
365
|
+
optgroup: new Set(["option"]),
|
|
366
|
+
select: new Set([
|
|
367
|
+
"optgroup",
|
|
368
|
+
"option",
|
|
369
|
+
"hr"
|
|
370
|
+
]),
|
|
371
|
+
table: new Set([
|
|
372
|
+
"caption",
|
|
373
|
+
"colgroup",
|
|
374
|
+
"tbody",
|
|
375
|
+
"tfoot",
|
|
376
|
+
"thead"
|
|
377
|
+
]),
|
|
378
|
+
tr: new Set(["td", "th"]),
|
|
379
|
+
colgroup: new Set(["col"]),
|
|
380
|
+
tbody: new Set(["tr"]),
|
|
381
|
+
thead: new Set(["tr"]),
|
|
382
|
+
tfoot: new Set(["tr"]),
|
|
383
|
+
script: emptySet,
|
|
384
|
+
iframe: emptySet,
|
|
385
|
+
option: emptySet,
|
|
386
|
+
textarea: emptySet,
|
|
387
|
+
style: emptySet,
|
|
388
|
+
title: emptySet
|
|
531
389
|
};
|
|
390
|
+
/** maps elements to set of elements which can be it's parent, no other */
|
|
532
391
|
const onlyValidParents = {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
area: /* @__PURE__ */ new Set(["map"])
|
|
392
|
+
html: emptySet,
|
|
393
|
+
body: new Set(["html"]),
|
|
394
|
+
head: new Set(["html"]),
|
|
395
|
+
td: new Set(["tr"]),
|
|
396
|
+
colgroup: new Set(["table"]),
|
|
397
|
+
caption: new Set(["table"]),
|
|
398
|
+
tbody: new Set(["table"]),
|
|
399
|
+
tfoot: new Set(["table"]),
|
|
400
|
+
col: new Set(["colgroup"]),
|
|
401
|
+
th: new Set(["tr"]),
|
|
402
|
+
thead: new Set(["table"]),
|
|
403
|
+
tr: new Set([
|
|
404
|
+
"tbody",
|
|
405
|
+
"thead",
|
|
406
|
+
"tfoot"
|
|
407
|
+
]),
|
|
408
|
+
dd: new Set(["dl", "div"]),
|
|
409
|
+
dt: new Set(["dl", "div"]),
|
|
410
|
+
figcaption: new Set(["figure"]),
|
|
411
|
+
summary: new Set(["details"]),
|
|
412
|
+
area: new Set(["map"])
|
|
555
413
|
};
|
|
414
|
+
/** maps element to set of elements that can not be it's children, others can */
|
|
556
415
|
const knownInvalidChildren = {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
416
|
+
p: new Set([
|
|
417
|
+
"address",
|
|
418
|
+
"article",
|
|
419
|
+
"aside",
|
|
420
|
+
"blockquote",
|
|
421
|
+
"center",
|
|
422
|
+
"details",
|
|
423
|
+
"dialog",
|
|
424
|
+
"dir",
|
|
425
|
+
"div",
|
|
426
|
+
"dl",
|
|
427
|
+
"fieldset",
|
|
428
|
+
"figure",
|
|
429
|
+
"footer",
|
|
430
|
+
"form",
|
|
431
|
+
"h1",
|
|
432
|
+
"h2",
|
|
433
|
+
"h3",
|
|
434
|
+
"h4",
|
|
435
|
+
"h5",
|
|
436
|
+
"h6",
|
|
437
|
+
"header",
|
|
438
|
+
"hgroup",
|
|
439
|
+
"hr",
|
|
440
|
+
"li",
|
|
441
|
+
"main",
|
|
442
|
+
"nav",
|
|
443
|
+
"menu",
|
|
444
|
+
"ol",
|
|
445
|
+
"p",
|
|
446
|
+
"pre",
|
|
447
|
+
"section",
|
|
448
|
+
"table",
|
|
449
|
+
"ul"
|
|
450
|
+
]),
|
|
451
|
+
svg: new Set([
|
|
452
|
+
"b",
|
|
453
|
+
"blockquote",
|
|
454
|
+
"br",
|
|
455
|
+
"code",
|
|
456
|
+
"dd",
|
|
457
|
+
"div",
|
|
458
|
+
"dl",
|
|
459
|
+
"dt",
|
|
460
|
+
"em",
|
|
461
|
+
"embed",
|
|
462
|
+
"h1",
|
|
463
|
+
"h2",
|
|
464
|
+
"h3",
|
|
465
|
+
"h4",
|
|
466
|
+
"h5",
|
|
467
|
+
"h6",
|
|
468
|
+
"hr",
|
|
469
|
+
"i",
|
|
470
|
+
"img",
|
|
471
|
+
"li",
|
|
472
|
+
"menu",
|
|
473
|
+
"meta",
|
|
474
|
+
"ol",
|
|
475
|
+
"p",
|
|
476
|
+
"pre",
|
|
477
|
+
"ruby",
|
|
478
|
+
"s",
|
|
479
|
+
"small",
|
|
480
|
+
"span",
|
|
481
|
+
"strong",
|
|
482
|
+
"sub",
|
|
483
|
+
"sup",
|
|
484
|
+
"table",
|
|
485
|
+
"u",
|
|
486
|
+
"ul",
|
|
487
|
+
"var"
|
|
488
|
+
])
|
|
630
489
|
};
|
|
490
|
+
/** maps element to set of elements that can not be it's parent, others can */
|
|
631
491
|
const knownInvalidParents = {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
492
|
+
a: new Set(["a"]),
|
|
493
|
+
button: new Set(["button"]),
|
|
494
|
+
dd: new Set(["dd", "dt"]),
|
|
495
|
+
dt: new Set(["dd", "dt"]),
|
|
496
|
+
form: new Set(["form"]),
|
|
497
|
+
li: new Set(["li"]),
|
|
498
|
+
h1: headings,
|
|
499
|
+
h2: headings,
|
|
500
|
+
h3: headings,
|
|
501
|
+
h4: headings,
|
|
502
|
+
h5: headings,
|
|
503
|
+
h6: headings
|
|
644
504
|
};
|
|
645
|
-
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region packages/compiler-dom/src/transforms/validateHtmlNesting.ts
|
|
646
507
|
const validateHtmlNesting = (node, context) => {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
context.onWarn(error);
|
|
653
|
-
}
|
|
508
|
+
if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
|
|
509
|
+
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.`);
|
|
510
|
+
error.loc = node.loc;
|
|
511
|
+
context.onWarn(error);
|
|
512
|
+
}
|
|
654
513
|
};
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
...!!(process.env.NODE_ENV !== "production") ? [transformTransition, validateHtmlNesting] : []
|
|
659
|
-
];
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region packages/compiler-dom/src/index.ts
|
|
516
|
+
const DOMNodeTransforms = [transformStyle, ...!!(process.env.NODE_ENV !== "production") ? [transformTransition, validateHtmlNesting] : []];
|
|
660
517
|
const DOMDirectiveTransforms = {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
// override compiler-core
|
|
668
|
-
show: transformShow
|
|
518
|
+
cloak: noopDirectiveTransform,
|
|
519
|
+
html: transformVHtml,
|
|
520
|
+
text: transformVText,
|
|
521
|
+
model: transformModel$1,
|
|
522
|
+
on: transformOn$1,
|
|
523
|
+
show: transformShow
|
|
669
524
|
};
|
|
670
525
|
function compile(src, options = {}) {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
...options.nodeTransforms || []
|
|
681
|
-
],
|
|
682
|
-
directiveTransforms: extend(
|
|
683
|
-
{},
|
|
684
|
-
DOMDirectiveTransforms,
|
|
685
|
-
options.directiveTransforms || {}
|
|
686
|
-
),
|
|
687
|
-
transformHoist: null
|
|
688
|
-
})
|
|
689
|
-
);
|
|
526
|
+
return baseCompile(src, extend({}, parserOptions, options, {
|
|
527
|
+
nodeTransforms: [
|
|
528
|
+
ignoreSideEffectTags,
|
|
529
|
+
...DOMNodeTransforms,
|
|
530
|
+
...options.nodeTransforms || []
|
|
531
|
+
],
|
|
532
|
+
directiveTransforms: extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
|
|
533
|
+
transformHoist: null
|
|
534
|
+
}));
|
|
690
535
|
}
|
|
691
536
|
function parse(template, options = {}) {
|
|
692
|
-
|
|
537
|
+
return baseParse(template, extend({}, parserOptions, options));
|
|
693
538
|
}
|
|
694
|
-
|
|
539
|
+
//#endregion
|
|
695
540
|
export { DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, TRANSITION, TRANSITION_GROUP, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, compile, createDOMCompilerError, isKeyboardEvent, isValidHTMLNesting, parse, parserOptions, postTransformTransition, resolveModifiers, transformStyle };
|