@vue/compiler-dom 3.2.36 → 3.2.39
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 +83 -83
- package/dist/compiler-dom.cjs.prod.js +72 -72
- package/dist/compiler-dom.esm-browser.js +591 -578
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +57 -57
- package/dist/compiler-dom.global.js +591 -578
- package/dist/compiler-dom.global.prod.js +1 -1
- package/package.json +3 -3
|
@@ -2400,54 +2400,54 @@ const parserOptions = {
|
|
|
2400
2400
|
},
|
|
2401
2401
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
|
2402
2402
|
getNamespace(tag, parent) {
|
|
2403
|
-
let ns = parent ? parent.ns : 0 /* HTML */;
|
|
2404
|
-
if (parent && ns === 2 /* MATH_ML */) {
|
|
2403
|
+
let ns = parent ? parent.ns : 0 /* DOMNamespaces.HTML */;
|
|
2404
|
+
if (parent && ns === 2 /* DOMNamespaces.MATH_ML */) {
|
|
2405
2405
|
if (parent.tag === 'annotation-xml') {
|
|
2406
2406
|
if (tag === 'svg') {
|
|
2407
|
-
return 1 /* SVG */;
|
|
2407
|
+
return 1 /* DOMNamespaces.SVG */;
|
|
2408
2408
|
}
|
|
2409
|
-
if (parent.props.some(a => a.type === 6 /* ATTRIBUTE */ &&
|
|
2409
|
+
if (parent.props.some(a => a.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
2410
2410
|
a.name === 'encoding' &&
|
|
2411
2411
|
a.value != null &&
|
|
2412
2412
|
(a.value.content === 'text/html' ||
|
|
2413
2413
|
a.value.content === 'application/xhtml+xml'))) {
|
|
2414
|
-
ns = 0 /* HTML */;
|
|
2414
|
+
ns = 0 /* DOMNamespaces.HTML */;
|
|
2415
2415
|
}
|
|
2416
2416
|
}
|
|
2417
2417
|
else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
|
|
2418
2418
|
tag !== 'mglyph' &&
|
|
2419
2419
|
tag !== 'malignmark') {
|
|
2420
|
-
ns = 0 /* HTML */;
|
|
2420
|
+
ns = 0 /* DOMNamespaces.HTML */;
|
|
2421
2421
|
}
|
|
2422
2422
|
}
|
|
2423
|
-
else if (parent && ns === 1 /* SVG */) {
|
|
2423
|
+
else if (parent && ns === 1 /* DOMNamespaces.SVG */) {
|
|
2424
2424
|
if (parent.tag === 'foreignObject' ||
|
|
2425
2425
|
parent.tag === 'desc' ||
|
|
2426
2426
|
parent.tag === 'title') {
|
|
2427
|
-
ns = 0 /* HTML */;
|
|
2427
|
+
ns = 0 /* DOMNamespaces.HTML */;
|
|
2428
2428
|
}
|
|
2429
2429
|
}
|
|
2430
|
-
if (ns === 0 /* HTML */) {
|
|
2430
|
+
if (ns === 0 /* DOMNamespaces.HTML */) {
|
|
2431
2431
|
if (tag === 'svg') {
|
|
2432
|
-
return 1 /* SVG */;
|
|
2432
|
+
return 1 /* DOMNamespaces.SVG */;
|
|
2433
2433
|
}
|
|
2434
2434
|
if (tag === 'math') {
|
|
2435
|
-
return 2 /* MATH_ML */;
|
|
2435
|
+
return 2 /* DOMNamespaces.MATH_ML */;
|
|
2436
2436
|
}
|
|
2437
2437
|
}
|
|
2438
2438
|
return ns;
|
|
2439
2439
|
},
|
|
2440
2440
|
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
|
|
2441
2441
|
getTextMode({ tag, ns }) {
|
|
2442
|
-
if (ns === 0 /* HTML */) {
|
|
2442
|
+
if (ns === 0 /* DOMNamespaces.HTML */) {
|
|
2443
2443
|
if (tag === 'textarea' || tag === 'title') {
|
|
2444
|
-
return 1 /* RCDATA */;
|
|
2444
|
+
return 1 /* TextModes.RCDATA */;
|
|
2445
2445
|
}
|
|
2446
2446
|
if (isRawTextContainer(tag)) {
|
|
2447
|
-
return 2 /* RAWTEXT */;
|
|
2447
|
+
return 2 /* TextModes.RAWTEXT */;
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
return 0 /* DATA */;
|
|
2450
|
+
return 0 /* TextModes.DATA */;
|
|
2451
2451
|
}
|
|
2452
2452
|
};
|
|
2453
2453
|
|
|
@@ -2458,12 +2458,12 @@ const parserOptions = {
|
|
|
2458
2458
|
// It is then processed by `transformElement` and included in the generated
|
|
2459
2459
|
// props.
|
|
2460
2460
|
const transformStyle = node => {
|
|
2461
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
2461
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
2462
2462
|
node.props.forEach((p, i) => {
|
|
2463
|
-
if (p.type === 6 /* ATTRIBUTE */ && p.name === 'style' && p.value) {
|
|
2463
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'style' && p.value) {
|
|
2464
2464
|
// replace p with an expression node
|
|
2465
2465
|
node.props[i] = {
|
|
2466
|
-
type: 7 /* DIRECTIVE */,
|
|
2466
|
+
type: 7 /* NodeTypes.DIRECTIVE */,
|
|
2467
2467
|
name: `bind`,
|
|
2468
2468
|
arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
|
|
2469
2469
|
exp: parseInlineCSS(p.value.content, p.loc),
|
|
@@ -2476,33 +2476,33 @@ const transformStyle = node => {
|
|
|
2476
2476
|
};
|
|
2477
2477
|
const parseInlineCSS = (cssText, loc) => {
|
|
2478
2478
|
const normalized = shared.parseStringStyle(cssText);
|
|
2479
|
-
return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* CAN_STRINGIFY */);
|
|
2479
|
+
return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
|
|
2480
2480
|
};
|
|
2481
2481
|
|
|
2482
2482
|
function createDOMCompilerError(code, loc) {
|
|
2483
2483
|
return compilerCore.createCompilerError(code, loc, DOMErrorMessages );
|
|
2484
2484
|
}
|
|
2485
2485
|
const DOMErrorMessages = {
|
|
2486
|
-
[50 /* X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
|
|
2487
|
-
[51 /* X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
|
|
2488
|
-
[52 /* X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
|
|
2489
|
-
[53 /* X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
|
|
2490
|
-
[54 /* X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
|
2491
|
-
[55 /* X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
|
|
2492
|
-
[56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
|
2493
|
-
[57 /* X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
|
2494
|
-
[58 /* X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
|
|
2495
|
-
[59 /* X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
|
|
2496
|
-
[60 /* X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
|
2486
|
+
[50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
|
|
2487
|
+
[51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
|
|
2488
|
+
[52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
|
|
2489
|
+
[53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
|
|
2490
|
+
[54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
|
2491
|
+
[55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
|
|
2492
|
+
[56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
|
2493
|
+
[57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
|
2494
|
+
[58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
|
|
2495
|
+
[59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
|
|
2496
|
+
[60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
|
2497
2497
|
};
|
|
2498
2498
|
|
|
2499
2499
|
const transformVHtml = (dir, node, context) => {
|
|
2500
2500
|
const { exp, loc } = dir;
|
|
2501
2501
|
if (!exp) {
|
|
2502
|
-
context.onError(createDOMCompilerError(50 /* X_V_HTML_NO_EXPRESSION */, loc));
|
|
2502
|
+
context.onError(createDOMCompilerError(50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */, loc));
|
|
2503
2503
|
}
|
|
2504
2504
|
if (node.children.length) {
|
|
2505
|
-
context.onError(createDOMCompilerError(51 /* X_V_HTML_WITH_CHILDREN */, loc));
|
|
2505
|
+
context.onError(createDOMCompilerError(51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */, loc));
|
|
2506
2506
|
node.children.length = 0;
|
|
2507
2507
|
}
|
|
2508
2508
|
return {
|
|
@@ -2515,10 +2515,10 @@ const transformVHtml = (dir, node, context) => {
|
|
|
2515
2515
|
const transformVText = (dir, node, context) => {
|
|
2516
2516
|
const { exp, loc } = dir;
|
|
2517
2517
|
if (!exp) {
|
|
2518
|
-
context.onError(createDOMCompilerError(52 /* X_V_TEXT_NO_EXPRESSION */, loc));
|
|
2518
|
+
context.onError(createDOMCompilerError(52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */, loc));
|
|
2519
2519
|
}
|
|
2520
2520
|
if (node.children.length) {
|
|
2521
|
-
context.onError(createDOMCompilerError(53 /* X_V_TEXT_WITH_CHILDREN */, loc));
|
|
2521
|
+
context.onError(createDOMCompilerError(53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */, loc));
|
|
2522
2522
|
node.children.length = 0;
|
|
2523
2523
|
}
|
|
2524
2524
|
return {
|
|
@@ -2535,11 +2535,11 @@ const transformVText = (dir, node, context) => {
|
|
|
2535
2535
|
const transformModel = (dir, node, context) => {
|
|
2536
2536
|
const baseResult = compilerCore.transformModel(dir, node, context);
|
|
2537
2537
|
// base transform has errors OR component v-model (only need props)
|
|
2538
|
-
if (!baseResult.props.length || node.tagType === 1 /* COMPONENT */) {
|
|
2538
|
+
if (!baseResult.props.length || node.tagType === 1 /* ElementTypes.COMPONENT */) {
|
|
2539
2539
|
return baseResult;
|
|
2540
2540
|
}
|
|
2541
2541
|
if (dir.arg) {
|
|
2542
|
-
context.onError(createDOMCompilerError(55 /* X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
|
|
2542
|
+
context.onError(createDOMCompilerError(55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
|
|
2543
2543
|
}
|
|
2544
2544
|
const { tag } = node;
|
|
2545
2545
|
const isCustomElement = context.isCustomElement(tag);
|
|
@@ -2552,7 +2552,7 @@ const transformModel = (dir, node, context) => {
|
|
|
2552
2552
|
if (tag === 'input' || isCustomElement) {
|
|
2553
2553
|
const type = compilerCore.findProp(node, `type`);
|
|
2554
2554
|
if (type) {
|
|
2555
|
-
if (type.type === 7 /* DIRECTIVE */) {
|
|
2555
|
+
if (type.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
2556
2556
|
// :type="foo"
|
|
2557
2557
|
directiveToUse = V_MODEL_DYNAMIC;
|
|
2558
2558
|
}
|
|
@@ -2566,7 +2566,7 @@ const transformModel = (dir, node, context) => {
|
|
|
2566
2566
|
break;
|
|
2567
2567
|
case 'file':
|
|
2568
2568
|
isInvalidType = true;
|
|
2569
|
-
context.onError(createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
2569
|
+
context.onError(createDOMCompilerError(56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
2570
2570
|
break;
|
|
2571
2571
|
}
|
|
2572
2572
|
}
|
|
@@ -2590,11 +2590,11 @@ const transformModel = (dir, node, context) => {
|
|
|
2590
2590
|
}
|
|
2591
2591
|
}
|
|
2592
2592
|
else {
|
|
2593
|
-
context.onError(createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
2593
|
+
context.onError(createDOMCompilerError(54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
2594
2594
|
}
|
|
2595
2595
|
// native vmodel doesn't need the `modelValue` props since they are also
|
|
2596
2596
|
// passed to the runtime as `binding.value`. removing it reduces code size.
|
|
2597
|
-
baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
2597
|
+
baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
2598
2598
|
p.key.content === 'modelValue'));
|
|
2599
2599
|
return baseResult;
|
|
2600
2600
|
};
|
|
@@ -2617,7 +2617,7 @@ const resolveModifiers = (key, modifiers, context, loc) => {
|
|
|
2617
2617
|
for (let i = 0; i < modifiers.length; i++) {
|
|
2618
2618
|
const modifier = modifiers[i];
|
|
2619
2619
|
if (modifier === 'native' &&
|
|
2620
|
-
compilerCore.checkCompatEnabled("COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */, context, loc)) {
|
|
2620
|
+
compilerCore.checkCompatEnabled("COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */, context, loc)) {
|
|
2621
2621
|
eventOptionModifiers.push(modifier);
|
|
2622
2622
|
}
|
|
2623
2623
|
else if (isEventOptionModifier(modifier)) {
|
|
@@ -2661,7 +2661,7 @@ const transformClick = (key, event) => {
|
|
|
2661
2661
|
const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === 'onclick';
|
|
2662
2662
|
return isStaticClick
|
|
2663
2663
|
? compilerCore.createSimpleExpression(event, true)
|
|
2664
|
-
: key.type !== 4 /* SIMPLE_EXPRESSION */
|
|
2664
|
+
: key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */
|
|
2665
2665
|
? compilerCore.createCompoundExpression([
|
|
2666
2666
|
`(`,
|
|
2667
2667
|
key,
|
|
@@ -2714,7 +2714,7 @@ const transformOn = (dir, node, context) => {
|
|
|
2714
2714
|
const transformShow = (dir, node, context) => {
|
|
2715
2715
|
const { exp, loc } = dir;
|
|
2716
2716
|
if (!exp) {
|
|
2717
|
-
context.onError(createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */, loc));
|
|
2717
|
+
context.onError(createDOMCompilerError(58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */, loc));
|
|
2718
2718
|
}
|
|
2719
2719
|
return {
|
|
2720
2720
|
props: [],
|
|
@@ -2762,8 +2762,8 @@ const stringifyStatic = (children, context, parent) => {
|
|
|
2762
2762
|
let ec = 0; // current element with binding count
|
|
2763
2763
|
const currentChunk = [];
|
|
2764
2764
|
const stringifyCurrentChunk = (currentIndex) => {
|
|
2765
|
-
if (nc >= 20 /* NODE_COUNT */ ||
|
|
2766
|
-
ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
|
|
2765
|
+
if (nc >= 20 /* StringifyThresholds.NODE_COUNT */ ||
|
|
2766
|
+
ec >= 5 /* StringifyThresholds.ELEMENT_WITH_BINDING_COUNT */) {
|
|
2767
2767
|
// combine all currently eligible nodes into a single static vnode call
|
|
2768
2768
|
const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
|
|
2769
2769
|
JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
|
|
@@ -2814,16 +2814,16 @@ const stringifyStatic = (children, context, parent) => {
|
|
|
2814
2814
|
// in case the last node was also stringifiable
|
|
2815
2815
|
stringifyCurrentChunk(i);
|
|
2816
2816
|
};
|
|
2817
|
-
const getHoistedNode = (node) => ((node.type === 1 /* ELEMENT */ && node.tagType === 0 /* ELEMENT */) ||
|
|
2818
|
-
node.type == 12 /* TEXT_CALL */) &&
|
|
2817
|
+
const getHoistedNode = (node) => ((node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 0 /* ElementTypes.ELEMENT */) ||
|
|
2818
|
+
node.type == 12 /* NodeTypes.TEXT_CALL */) &&
|
|
2819
2819
|
node.codegenNode &&
|
|
2820
|
-
node.codegenNode.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
2820
|
+
node.codegenNode.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
2821
2821
|
node.codegenNode.hoisted;
|
|
2822
2822
|
const dataAriaRE = /^(data|aria)-/;
|
|
2823
2823
|
const isStringifiableAttr = (name, ns) => {
|
|
2824
|
-
return ((ns === 0 /* HTML */
|
|
2824
|
+
return ((ns === 0 /* DOMNamespaces.HTML */
|
|
2825
2825
|
? shared.isKnownHtmlAttr(name)
|
|
2826
|
-
: ns === 1 /* SVG */
|
|
2826
|
+
: ns === 1 /* DOMNamespaces.SVG */
|
|
2827
2827
|
? shared.isKnownSvgAttr(name)
|
|
2828
2828
|
: false) || dataAriaRE.test(name));
|
|
2829
2829
|
};
|
|
@@ -2840,10 +2840,10 @@ const isNonStringifiable = /*#__PURE__*/ shared.makeMap(`caption,thead,tr,th,tbo
|
|
|
2840
2840
|
* - ec is the number of element with bindings inside
|
|
2841
2841
|
*/
|
|
2842
2842
|
function analyzeNode(node) {
|
|
2843
|
-
if (node.type === 1 /* ELEMENT */ && isNonStringifiable(node.tag)) {
|
|
2843
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ && isNonStringifiable(node.tag)) {
|
|
2844
2844
|
return false;
|
|
2845
2845
|
}
|
|
2846
|
-
if (node.type === 12 /* TEXT_CALL */) {
|
|
2846
|
+
if (node.type === 12 /* NodeTypes.TEXT_CALL */) {
|
|
2847
2847
|
return [1, 0];
|
|
2848
2848
|
}
|
|
2849
2849
|
let nc = 1; // node count
|
|
@@ -2861,20 +2861,20 @@ function analyzeNode(node) {
|
|
|
2861
2861
|
for (let i = 0; i < node.props.length; i++) {
|
|
2862
2862
|
const p = node.props[i];
|
|
2863
2863
|
// bail on non-attr bindings
|
|
2864
|
-
if (p.type === 6 /* ATTRIBUTE */ &&
|
|
2864
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
2865
2865
|
!isStringifiableAttr(p.name, node.ns)) {
|
|
2866
2866
|
return bail();
|
|
2867
2867
|
}
|
|
2868
|
-
if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
|
|
2868
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind') {
|
|
2869
2869
|
// bail on non-attr bindings
|
|
2870
2870
|
if (p.arg &&
|
|
2871
|
-
(p.arg.type === 8 /* COMPOUND_EXPRESSION */ ||
|
|
2871
|
+
(p.arg.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
|
|
2872
2872
|
(p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
|
|
2873
2873
|
return bail();
|
|
2874
2874
|
}
|
|
2875
2875
|
if (p.exp &&
|
|
2876
|
-
(p.exp.type === 8 /* COMPOUND_EXPRESSION */ ||
|
|
2877
|
-
p.exp.constType < 3 /* CAN_STRINGIFY */)) {
|
|
2876
|
+
(p.exp.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
|
|
2877
|
+
p.exp.constType < 3 /* ConstantTypes.CAN_STRINGIFY */)) {
|
|
2878
2878
|
return bail();
|
|
2879
2879
|
}
|
|
2880
2880
|
}
|
|
@@ -2882,7 +2882,7 @@ function analyzeNode(node) {
|
|
|
2882
2882
|
for (let i = 0; i < node.children.length; i++) {
|
|
2883
2883
|
nc++;
|
|
2884
2884
|
const child = node.children[i];
|
|
2885
|
-
if (child.type === 1 /* ELEMENT */) {
|
|
2885
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */) {
|
|
2886
2886
|
if (child.props.length > 0) {
|
|
2887
2887
|
ec++;
|
|
2888
2888
|
}
|
|
@@ -2904,17 +2904,17 @@ function stringifyNode(node, context) {
|
|
|
2904
2904
|
return ``;
|
|
2905
2905
|
}
|
|
2906
2906
|
switch (node.type) {
|
|
2907
|
-
case 1 /* ELEMENT */:
|
|
2907
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
2908
2908
|
return stringifyElement(node, context);
|
|
2909
|
-
case 2 /* TEXT */:
|
|
2909
|
+
case 2 /* NodeTypes.TEXT */:
|
|
2910
2910
|
return shared.escapeHtml(node.content);
|
|
2911
|
-
case 3 /* COMMENT */:
|
|
2911
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
2912
2912
|
return `<!--${shared.escapeHtml(node.content)}-->`;
|
|
2913
|
-
case 5 /* INTERPOLATION */:
|
|
2913
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
2914
2914
|
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
|
2915
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
2915
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
2916
2916
|
return shared.escapeHtml(evaluateConstant(node));
|
|
2917
|
-
case 12 /* TEXT_CALL */:
|
|
2917
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
2918
2918
|
return stringifyNode(node.content, context);
|
|
2919
2919
|
default:
|
|
2920
2920
|
// static trees will not contain if/for nodes
|
|
@@ -2926,13 +2926,13 @@ function stringifyElement(node, context) {
|
|
|
2926
2926
|
let innerHTML = '';
|
|
2927
2927
|
for (let i = 0; i < node.props.length; i++) {
|
|
2928
2928
|
const p = node.props[i];
|
|
2929
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
2929
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
2930
2930
|
res += ` ${p.name}`;
|
|
2931
2931
|
if (p.value) {
|
|
2932
2932
|
res += `="${shared.escapeHtml(p.value.content)}"`;
|
|
2933
2933
|
}
|
|
2934
2934
|
}
|
|
2935
|
-
else if (p.type === 7 /* DIRECTIVE */) {
|
|
2935
|
+
else if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
2936
2936
|
if (p.name === 'bind') {
|
|
2937
2937
|
const exp = p.exp;
|
|
2938
2938
|
if (exp.content[0] === '_') {
|
|
@@ -2989,7 +2989,7 @@ function stringifyElement(node, context) {
|
|
|
2989
2989
|
// run JSFuck in here. But we mark it unsafe for security review purposes.
|
|
2990
2990
|
// (see compiler-core/src/transforms/transformExpression)
|
|
2991
2991
|
function evaluateConstant(exp) {
|
|
2992
|
-
if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2992
|
+
if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
2993
2993
|
return new Function(`return ${exp.content}`)();
|
|
2994
2994
|
}
|
|
2995
2995
|
else {
|
|
@@ -2999,10 +2999,10 @@ function evaluateConstant(exp) {
|
|
|
2999
2999
|
if (shared.isString(c) || shared.isSymbol(c)) {
|
|
3000
3000
|
return;
|
|
3001
3001
|
}
|
|
3002
|
-
if (c.type === 2 /* TEXT */) {
|
|
3002
|
+
if (c.type === 2 /* NodeTypes.TEXT */) {
|
|
3003
3003
|
res += c.content;
|
|
3004
3004
|
}
|
|
3005
|
-
else if (c.type === 5 /* INTERPOLATION */) {
|
|
3005
|
+
else if (c.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
3006
3006
|
res += shared.toDisplayString(evaluateConstant(c.content));
|
|
3007
3007
|
}
|
|
3008
3008
|
else {
|
|
@@ -3014,10 +3014,10 @@ function evaluateConstant(exp) {
|
|
|
3014
3014
|
}
|
|
3015
3015
|
|
|
3016
3016
|
const ignoreSideEffectTags = (node, context) => {
|
|
3017
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
3018
|
-
node.tagType === 0 /* ELEMENT */ &&
|
|
3017
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
3018
|
+
node.tagType === 0 /* ElementTypes.ELEMENT */ &&
|
|
3019
3019
|
(node.tag === 'script' || node.tag === 'style')) {
|
|
3020
|
-
context.onError(createDOMCompilerError(60 /* X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
|
|
3020
|
+
context.onError(createDOMCompilerError(60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
|
|
3021
3021
|
context.removeNode();
|
|
3022
3022
|
}
|
|
3023
3023
|
};
|