@vue/compiler-dom 3.2.35 → 3.2.38
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 +596 -575
- 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 +596 -575
- package/dist/compiler-dom.global.prod.js +1 -1
- package/package.json +3 -3
package/dist/compiler-dom.cjs.js
CHANGED
|
@@ -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,16 +2535,16 @@ 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
|
function checkDuplicatedValue() {
|
|
2545
2545
|
const value = compilerCore.findProp(node, 'value');
|
|
2546
2546
|
if (value) {
|
|
2547
|
-
context.onError(createDOMCompilerError(57 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
|
|
2547
|
+
context.onError(createDOMCompilerError(57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
|
|
2548
2548
|
}
|
|
2549
2549
|
}
|
|
2550
2550
|
const { tag } = node;
|
|
@@ -2558,7 +2558,7 @@ const transformModel = (dir, node, context) => {
|
|
|
2558
2558
|
if (tag === 'input' || isCustomElement) {
|
|
2559
2559
|
const type = compilerCore.findProp(node, `type`);
|
|
2560
2560
|
if (type) {
|
|
2561
|
-
if (type.type === 7 /* DIRECTIVE */) {
|
|
2561
|
+
if (type.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
2562
2562
|
// :type="foo"
|
|
2563
2563
|
directiveToUse = V_MODEL_DYNAMIC;
|
|
2564
2564
|
}
|
|
@@ -2572,7 +2572,7 @@ const transformModel = (dir, node, context) => {
|
|
|
2572
2572
|
break;
|
|
2573
2573
|
case 'file':
|
|
2574
2574
|
isInvalidType = true;
|
|
2575
|
-
context.onError(createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
2575
|
+
context.onError(createDOMCompilerError(56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
2576
2576
|
break;
|
|
2577
2577
|
default:
|
|
2578
2578
|
// text type
|
|
@@ -2606,11 +2606,11 @@ const transformModel = (dir, node, context) => {
|
|
|
2606
2606
|
}
|
|
2607
2607
|
}
|
|
2608
2608
|
else {
|
|
2609
|
-
context.onError(createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
2609
|
+
context.onError(createDOMCompilerError(54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
2610
2610
|
}
|
|
2611
2611
|
// native vmodel doesn't need the `modelValue` props since they are also
|
|
2612
2612
|
// passed to the runtime as `binding.value`. removing it reduces code size.
|
|
2613
|
-
baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
2613
|
+
baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
2614
2614
|
p.key.content === 'modelValue'));
|
|
2615
2615
|
return baseResult;
|
|
2616
2616
|
};
|
|
@@ -2633,7 +2633,7 @@ const resolveModifiers = (key, modifiers, context, loc) => {
|
|
|
2633
2633
|
for (let i = 0; i < modifiers.length; i++) {
|
|
2634
2634
|
const modifier = modifiers[i];
|
|
2635
2635
|
if (modifier === 'native' &&
|
|
2636
|
-
compilerCore.checkCompatEnabled("COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */, context, loc)) {
|
|
2636
|
+
compilerCore.checkCompatEnabled("COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */, context, loc)) {
|
|
2637
2637
|
eventOptionModifiers.push(modifier);
|
|
2638
2638
|
}
|
|
2639
2639
|
else if (isEventOptionModifier(modifier)) {
|
|
@@ -2677,7 +2677,7 @@ const transformClick = (key, event) => {
|
|
|
2677
2677
|
const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === 'onclick';
|
|
2678
2678
|
return isStaticClick
|
|
2679
2679
|
? compilerCore.createSimpleExpression(event, true)
|
|
2680
|
-
: key.type !== 4 /* SIMPLE_EXPRESSION */
|
|
2680
|
+
: key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */
|
|
2681
2681
|
? compilerCore.createCompoundExpression([
|
|
2682
2682
|
`(`,
|
|
2683
2683
|
key,
|
|
@@ -2730,7 +2730,7 @@ const transformOn = (dir, node, context) => {
|
|
|
2730
2730
|
const transformShow = (dir, node, context) => {
|
|
2731
2731
|
const { exp, loc } = dir;
|
|
2732
2732
|
if (!exp) {
|
|
2733
|
-
context.onError(createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */, loc));
|
|
2733
|
+
context.onError(createDOMCompilerError(58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */, loc));
|
|
2734
2734
|
}
|
|
2735
2735
|
return {
|
|
2736
2736
|
props: [],
|
|
@@ -2739,8 +2739,8 @@ const transformShow = (dir, node, context) => {
|
|
|
2739
2739
|
};
|
|
2740
2740
|
|
|
2741
2741
|
const transformTransition = (node, context) => {
|
|
2742
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
2743
|
-
node.tagType === 1 /* COMPONENT */) {
|
|
2742
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
2743
|
+
node.tagType === 1 /* ElementTypes.COMPONENT */) {
|
|
2744
2744
|
const component = context.isBuiltInComponent(node.tag);
|
|
2745
2745
|
if (component === TRANSITION) {
|
|
2746
2746
|
return () => {
|
|
@@ -2749,7 +2749,7 @@ const transformTransition = (node, context) => {
|
|
|
2749
2749
|
}
|
|
2750
2750
|
// warn multiple transition children
|
|
2751
2751
|
if (hasMultipleChildren(node)) {
|
|
2752
|
-
context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
|
|
2752
|
+
context.onError(createDOMCompilerError(59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */, {
|
|
2753
2753
|
start: node.children[0].loc.start,
|
|
2754
2754
|
end: node.children[node.children.length - 1].loc.end,
|
|
2755
2755
|
source: ''
|
|
@@ -2758,11 +2758,11 @@ const transformTransition = (node, context) => {
|
|
|
2758
2758
|
// check if it's s single child w/ v-show
|
|
2759
2759
|
// if yes, inject "persisted: true" to the transition props
|
|
2760
2760
|
const child = node.children[0];
|
|
2761
|
-
if (child.type === 1 /* ELEMENT */) {
|
|
2761
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */) {
|
|
2762
2762
|
for (const p of child.props) {
|
|
2763
|
-
if (p.type === 7 /* DIRECTIVE */ && p.name === 'show') {
|
|
2763
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'show') {
|
|
2764
2764
|
node.props.push({
|
|
2765
|
-
type: 6 /* ATTRIBUTE */,
|
|
2765
|
+
type: 6 /* NodeTypes.ATTRIBUTE */,
|
|
2766
2766
|
name: 'persisted',
|
|
2767
2767
|
value: undefined,
|
|
2768
2768
|
loc: node.loc
|
|
@@ -2776,12 +2776,12 @@ const transformTransition = (node, context) => {
|
|
|
2776
2776
|
};
|
|
2777
2777
|
function hasMultipleChildren(node) {
|
|
2778
2778
|
// #1352 filter out potential comment nodes.
|
|
2779
|
-
const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */ &&
|
|
2780
|
-
!(c.type === 2 /* TEXT */ && !c.content.trim())));
|
|
2779
|
+
const children = (node.children = node.children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */ &&
|
|
2780
|
+
!(c.type === 2 /* NodeTypes.TEXT */ && !c.content.trim())));
|
|
2781
2781
|
const child = children[0];
|
|
2782
2782
|
return (children.length !== 1 ||
|
|
2783
|
-
child.type === 11 /* FOR */ ||
|
|
2784
|
-
(child.type === 9 /* IF */ && child.branches.some(hasMultipleChildren)));
|
|
2783
|
+
child.type === 11 /* NodeTypes.FOR */ ||
|
|
2784
|
+
(child.type === 9 /* NodeTypes.IF */ && child.branches.some(hasMultipleChildren)));
|
|
2785
2785
|
}
|
|
2786
2786
|
|
|
2787
2787
|
/**
|
|
@@ -2824,8 +2824,8 @@ const stringifyStatic = (children, context, parent) => {
|
|
|
2824
2824
|
let ec = 0; // current element with binding count
|
|
2825
2825
|
const currentChunk = [];
|
|
2826
2826
|
const stringifyCurrentChunk = (currentIndex) => {
|
|
2827
|
-
if (nc >= 20 /* NODE_COUNT */ ||
|
|
2828
|
-
ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
|
|
2827
|
+
if (nc >= 20 /* StringifyThresholds.NODE_COUNT */ ||
|
|
2828
|
+
ec >= 5 /* StringifyThresholds.ELEMENT_WITH_BINDING_COUNT */) {
|
|
2829
2829
|
// combine all currently eligible nodes into a single static vnode call
|
|
2830
2830
|
const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
|
|
2831
2831
|
JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
|
|
@@ -2876,16 +2876,16 @@ const stringifyStatic = (children, context, parent) => {
|
|
|
2876
2876
|
// in case the last node was also stringifiable
|
|
2877
2877
|
stringifyCurrentChunk(i);
|
|
2878
2878
|
};
|
|
2879
|
-
const getHoistedNode = (node) => ((node.type === 1 /* ELEMENT */ && node.tagType === 0 /* ELEMENT */) ||
|
|
2880
|
-
node.type == 12 /* TEXT_CALL */) &&
|
|
2879
|
+
const getHoistedNode = (node) => ((node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 0 /* ElementTypes.ELEMENT */) ||
|
|
2880
|
+
node.type == 12 /* NodeTypes.TEXT_CALL */) &&
|
|
2881
2881
|
node.codegenNode &&
|
|
2882
|
-
node.codegenNode.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
2882
|
+
node.codegenNode.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
2883
2883
|
node.codegenNode.hoisted;
|
|
2884
2884
|
const dataAriaRE = /^(data|aria)-/;
|
|
2885
2885
|
const isStringifiableAttr = (name, ns) => {
|
|
2886
|
-
return ((ns === 0 /* HTML */
|
|
2886
|
+
return ((ns === 0 /* DOMNamespaces.HTML */
|
|
2887
2887
|
? shared.isKnownHtmlAttr(name)
|
|
2888
|
-
: ns === 1 /* SVG */
|
|
2888
|
+
: ns === 1 /* DOMNamespaces.SVG */
|
|
2889
2889
|
? shared.isKnownSvgAttr(name)
|
|
2890
2890
|
: false) || dataAriaRE.test(name));
|
|
2891
2891
|
};
|
|
@@ -2902,10 +2902,10 @@ const isNonStringifiable = /*#__PURE__*/ shared.makeMap(`caption,thead,tr,th,tbo
|
|
|
2902
2902
|
* - ec is the number of element with bindings inside
|
|
2903
2903
|
*/
|
|
2904
2904
|
function analyzeNode(node) {
|
|
2905
|
-
if (node.type === 1 /* ELEMENT */ && isNonStringifiable(node.tag)) {
|
|
2905
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ && isNonStringifiable(node.tag)) {
|
|
2906
2906
|
return false;
|
|
2907
2907
|
}
|
|
2908
|
-
if (node.type === 12 /* TEXT_CALL */) {
|
|
2908
|
+
if (node.type === 12 /* NodeTypes.TEXT_CALL */) {
|
|
2909
2909
|
return [1, 0];
|
|
2910
2910
|
}
|
|
2911
2911
|
let nc = 1; // node count
|
|
@@ -2923,20 +2923,20 @@ function analyzeNode(node) {
|
|
|
2923
2923
|
for (let i = 0; i < node.props.length; i++) {
|
|
2924
2924
|
const p = node.props[i];
|
|
2925
2925
|
// bail on non-attr bindings
|
|
2926
|
-
if (p.type === 6 /* ATTRIBUTE */ &&
|
|
2926
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
2927
2927
|
!isStringifiableAttr(p.name, node.ns)) {
|
|
2928
2928
|
return bail();
|
|
2929
2929
|
}
|
|
2930
|
-
if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
|
|
2930
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind') {
|
|
2931
2931
|
// bail on non-attr bindings
|
|
2932
2932
|
if (p.arg &&
|
|
2933
|
-
(p.arg.type === 8 /* COMPOUND_EXPRESSION */ ||
|
|
2933
|
+
(p.arg.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
|
|
2934
2934
|
(p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
|
|
2935
2935
|
return bail();
|
|
2936
2936
|
}
|
|
2937
2937
|
if (p.exp &&
|
|
2938
|
-
(p.exp.type === 8 /* COMPOUND_EXPRESSION */ ||
|
|
2939
|
-
p.exp.constType < 3 /* CAN_STRINGIFY */)) {
|
|
2938
|
+
(p.exp.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
|
|
2939
|
+
p.exp.constType < 3 /* ConstantTypes.CAN_STRINGIFY */)) {
|
|
2940
2940
|
return bail();
|
|
2941
2941
|
}
|
|
2942
2942
|
}
|
|
@@ -2944,7 +2944,7 @@ function analyzeNode(node) {
|
|
|
2944
2944
|
for (let i = 0; i < node.children.length; i++) {
|
|
2945
2945
|
nc++;
|
|
2946
2946
|
const child = node.children[i];
|
|
2947
|
-
if (child.type === 1 /* ELEMENT */) {
|
|
2947
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */) {
|
|
2948
2948
|
if (child.props.length > 0) {
|
|
2949
2949
|
ec++;
|
|
2950
2950
|
}
|
|
@@ -2966,17 +2966,17 @@ function stringifyNode(node, context) {
|
|
|
2966
2966
|
return ``;
|
|
2967
2967
|
}
|
|
2968
2968
|
switch (node.type) {
|
|
2969
|
-
case 1 /* ELEMENT */:
|
|
2969
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
2970
2970
|
return stringifyElement(node, context);
|
|
2971
|
-
case 2 /* TEXT */:
|
|
2971
|
+
case 2 /* NodeTypes.TEXT */:
|
|
2972
2972
|
return shared.escapeHtml(node.content);
|
|
2973
|
-
case 3 /* COMMENT */:
|
|
2973
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
2974
2974
|
return `<!--${shared.escapeHtml(node.content)}-->`;
|
|
2975
|
-
case 5 /* INTERPOLATION */:
|
|
2975
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
2976
2976
|
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
|
2977
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
2977
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
2978
2978
|
return shared.escapeHtml(evaluateConstant(node));
|
|
2979
|
-
case 12 /* TEXT_CALL */:
|
|
2979
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
2980
2980
|
return stringifyNode(node.content, context);
|
|
2981
2981
|
default:
|
|
2982
2982
|
// static trees will not contain if/for nodes
|
|
@@ -2988,13 +2988,13 @@ function stringifyElement(node, context) {
|
|
|
2988
2988
|
let innerHTML = '';
|
|
2989
2989
|
for (let i = 0; i < node.props.length; i++) {
|
|
2990
2990
|
const p = node.props[i];
|
|
2991
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
2991
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
2992
2992
|
res += ` ${p.name}`;
|
|
2993
2993
|
if (p.value) {
|
|
2994
2994
|
res += `="${shared.escapeHtml(p.value.content)}"`;
|
|
2995
2995
|
}
|
|
2996
2996
|
}
|
|
2997
|
-
else if (p.type === 7 /* DIRECTIVE */) {
|
|
2997
|
+
else if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
2998
2998
|
if (p.name === 'bind') {
|
|
2999
2999
|
const exp = p.exp;
|
|
3000
3000
|
if (exp.content[0] === '_') {
|
|
@@ -3051,7 +3051,7 @@ function stringifyElement(node, context) {
|
|
|
3051
3051
|
// run JSFuck in here. But we mark it unsafe for security review purposes.
|
|
3052
3052
|
// (see compiler-core/src/transforms/transformExpression)
|
|
3053
3053
|
function evaluateConstant(exp) {
|
|
3054
|
-
if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
3054
|
+
if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
3055
3055
|
return new Function(`return ${exp.content}`)();
|
|
3056
3056
|
}
|
|
3057
3057
|
else {
|
|
@@ -3061,10 +3061,10 @@ function evaluateConstant(exp) {
|
|
|
3061
3061
|
if (shared.isString(c) || shared.isSymbol(c)) {
|
|
3062
3062
|
return;
|
|
3063
3063
|
}
|
|
3064
|
-
if (c.type === 2 /* TEXT */) {
|
|
3064
|
+
if (c.type === 2 /* NodeTypes.TEXT */) {
|
|
3065
3065
|
res += c.content;
|
|
3066
3066
|
}
|
|
3067
|
-
else if (c.type === 5 /* INTERPOLATION */) {
|
|
3067
|
+
else if (c.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
3068
3068
|
res += shared.toDisplayString(evaluateConstant(c.content));
|
|
3069
3069
|
}
|
|
3070
3070
|
else {
|
|
@@ -3076,10 +3076,10 @@ function evaluateConstant(exp) {
|
|
|
3076
3076
|
}
|
|
3077
3077
|
|
|
3078
3078
|
const ignoreSideEffectTags = (node, context) => {
|
|
3079
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
3080
|
-
node.tagType === 0 /* ELEMENT */ &&
|
|
3079
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
3080
|
+
node.tagType === 0 /* ElementTypes.ELEMENT */ &&
|
|
3081
3081
|
(node.tag === 'script' || node.tag === 'style')) {
|
|
3082
|
-
context.onError(createDOMCompilerError(60 /* X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
|
|
3082
|
+
context.onError(createDOMCompilerError(60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
|
|
3083
3083
|
context.removeNode();
|
|
3084
3084
|
}
|
|
3085
3085
|
};
|