refactor(compiler): better constant hoist/stringify checks

This commit is contained in:
Evan You
2020-11-20 19:26:07 -05:00
parent acba86ef45
commit 90bdf59f4c
22 changed files with 291 additions and 204 deletions

View File

@@ -6,7 +6,8 @@ import {
ErrorCodes,
ElementTypes,
InterpolationNode,
AttributeNode
AttributeNode,
ConstantTypes
} from '@vue/compiler-core'
import { parserOptions, DOMNamespaces } from '../src/parserOptions'
@@ -253,7 +254,7 @@ describe('DOM parser', () => {
type: NodeTypes.SIMPLE_EXPRESSION,
content: `a < b`,
isStatic: false,
isConstant: false,
constType: ConstantTypes.NOT_CONSTANT,
loc: {
start: { offset: 8, line: 1, column: 9 },
end: { offset: 16, line: 1, column: 17 },

View File

@@ -2,7 +2,8 @@ import {
compile,
NodeTypes,
CREATE_STATIC,
createSimpleExpression
createSimpleExpression,
ConstantTypes
} from '../../src'
import {
stringifyStatic,
@@ -176,9 +177,8 @@ describe('stringify static html', () => {
'_imports_0_',
false,
node.loc,
true
ConstantTypes.CAN_HOIST
)
exp.isRuntimeConstant = true
node.props[0] = {
type: NodeTypes.DIRECTIVE,
name: 'bind',