fix(compiler): patchFlag analysis should factor in props returned by directive transforms

This commit is contained in:
Evan You
2019-10-04 08:37:10 -04:00
parent 095f5edf8d
commit 6059fe69e8
2 changed files with 34 additions and 37 deletions

View File

@@ -292,18 +292,20 @@ describe('compiler: element transform', () => {
}
]
})
// should factor in props returned by custom directive transforms
// in patchFlag analysis
expect(node.arguments[3]).toMatch(PatchFlags.PROPS + '')
expect(node.arguments[4]).toMatch(`"bar"`)
})
test('directiveTransform with needRuntime: true', () => {
let _dir: DirectiveNode
const { root, node } = parseWithElementTransform(
`<div v-foo:bar="hello" />`,
{
directiveTransforms: {
foo(dir) {
_dir = dir
foo() {
return {
props: [createObjectProperty(dir.arg!, dir.exp!)],
props: [],
needRuntime: true
}
}
@@ -320,16 +322,7 @@ describe('compiler: element transform', () => {
callee: `_${CREATE_VNODE}`,
arguments: [
`"div"`,
{
type: NodeTypes.JS_OBJECT_EXPRESSION,
properties: [
{
type: NodeTypes.JS_PROPERTY,
key: _dir!.arg,
value: _dir!.exp
}
]
},
`null`,
`null`,
`${PatchFlags.NEED_PATCH} /* NEED_PATCH */` // should generate appropriate flag
]