fix(compiler): force block for custom dirs and inline beforeUpdate hooks
to ensure they are called before children updates
This commit is contained in:
@@ -67,13 +67,13 @@ exports[`compiler: transform text element with custom directives and only one te
|
||||
|
||||
return function render(_ctx, _cache) {
|
||||
with (_ctx) {
|
||||
const { toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, resolveDirective: _resolveDirective, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue
|
||||
const { toDisplayString: _toDisplayString, createTextVNode: _createTextVNode, resolveDirective: _resolveDirective, openBlock: _openBlock, createElementBlock: _createElementBlock, withDirectives: _withDirectives } = _Vue
|
||||
|
||||
const _directive_foo = _resolveDirective(\\"foo\\")
|
||||
|
||||
return _withDirectives((_openBlock(), _createElementBlock(\\"p\\", null, [
|
||||
_createTextVNode(_toDisplayString(foo), 1 /* TEXT */)
|
||||
], 512 /* NEED_PATCH */)), [
|
||||
])), [
|
||||
[_directive_foo]
|
||||
])
|
||||
}
|
||||
|
||||
@@ -1202,6 +1202,23 @@ describe('compiler: element transform', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('force block for runtime custom directive w/ children', () => {
|
||||
const { node } = parseWithElementTransform(`<div v-foo>hello</div>`)
|
||||
expect(node.isBlock).toBe(true)
|
||||
})
|
||||
|
||||
test('force block for inline before-update handlers w/ children', () => {
|
||||
expect(
|
||||
parseWithElementTransform(`<div @vnode-before-update>hello</div>`).node
|
||||
.isBlock
|
||||
).toBe(true)
|
||||
|
||||
expect(
|
||||
parseWithElementTransform(`<div @vnodeBeforeUpdate>hello</div>`).node
|
||||
.isBlock
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
// #938
|
||||
test('element with dynamic keys should be forced into blocks', () => {
|
||||
const ast = parse(`<div><div :key="foo" /></div>`)
|
||||
|
||||
Reference in New Issue
Block a user