refactor(compiler): better constant hoist/stringify checks
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -3,7 +3,8 @@ import {
|
||||
NodeTypes,
|
||||
createSimpleExpression,
|
||||
SimpleExpressionNode,
|
||||
SourceLocation
|
||||
SourceLocation,
|
||||
ConstantTypes
|
||||
} from '@vue/compiler-core'
|
||||
import { parseStringStyle } from '@vue/shared'
|
||||
|
||||
@@ -36,5 +37,10 @@ const parseInlineCSS = (
|
||||
loc: SourceLocation
|
||||
): SimpleExpressionNode => {
|
||||
const normalized = parseStringStyle(cssText)
|
||||
return createSimpleExpression(JSON.stringify(normalized), false, loc, true)
|
||||
return createSimpleExpression(
|
||||
JSON.stringify(normalized),
|
||||
false,
|
||||
loc,
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user