|
|
@@ -4,7 +4,8 @@ import {
|
|
|
transform,
|
|
|
ErrorCodes,
|
|
|
BindingTypes,
|
|
|
- NodeTransform
|
|
|
+ NodeTransform,
|
|
|
+ transformExpression
|
|
|
} from '../../src'
|
|
|
import {
|
|
|
RESOLVE_COMPONENT,
|
|
|
@@ -773,6 +774,37 @@ describe('compiler: element transform', () => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ test(`props merging: style w/ transformExpression`, () => {
|
|
|
+ const { node, root } = parseWithElementTransform(
|
|
|
+ `<div style="color: green" :style="{ color: 'red' }" />`,
|
|
|
+ {
|
|
|
+ nodeTransforms: [transformExpression, transformStyle, transformElement],
|
|
|
+ directiveTransforms: {
|
|
|
+ bind: transformBind
|
|
|
+ },
|
|
|
+ prefixIdentifiers: true
|
|
|
+ }
|
|
|
+ )
|
|
|
+ expect(root.helpers).toContain(NORMALIZE_STYLE)
|
|
|
+ expect(node.props).toMatchObject({
|
|
|
+ type: NodeTypes.JS_OBJECT_EXPRESSION,
|
|
|
+ properties: [
|
|
|
+ {
|
|
|
+ type: NodeTypes.JS_PROPERTY,
|
|
|
+ key: {
|
|
|
+ type: NodeTypes.SIMPLE_EXPRESSION,
|
|
|
+ content: `style`,
|
|
|
+ isStatic: true
|
|
|
+ },
|
|
|
+ value: {
|
|
|
+ type: NodeTypes.JS_CALL_EXPRESSION,
|
|
|
+ callee: NORMALIZE_STYLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
test(`props merging: class`, () => {
|
|
|
const { node, root } = parseWithElementTransform(
|
|
|
`<div class="foo" :class="{ bar: isBar }" />`,
|