fix(runtime-core): ensure custom directive instance properly exposes properties on closed instances. (#5022)

fix #5018
This commit is contained in:
Thorsten Lünborg
2022-04-12 09:54:03 +02:00
committed by GitHub
parent 0a301d4dab
commit f44087e171
2 changed files with 31 additions and 3 deletions

View File

@@ -7,7 +7,8 @@ import {
DirectiveHook,
VNode,
DirectiveBinding,
nextTick
nextTick,
defineComponent
} from '@vue/runtime-test'
import { currentInstance, ComponentInternalInstance } from '../src/component'
@@ -395,4 +396,29 @@ describe('directives', () => {
expect(beforeUpdate).toHaveBeenCalledTimes(1)
expect(count.value).toBe(1)
})
test('should receive exposeProxy for closed instances', async () => {
let res: string
const App = defineComponent({
setup(_, { expose }) {
expose({
msg: 'Test'
})
return () =>
withDirectives(h('p', 'Lore Ipsum'), [
[
{
mounted(el, { instance }) {
res = (instance as any).msg as string
}
}
]
])
}
})
const root = nodeOps.createElement('div')
render(h(App), root)
expect(res!).toBe('Test')
})
})