fix(runtime-core): should not cache property access during data() invocation (#3299)

fix #3297
This commit is contained in:
HcySunYang
2021-03-26 03:48:12 +08:00
committed by GitHub
parent 4bf7ba19bf
commit 6e88156934
3 changed files with 28 additions and 5 deletions

View File

@@ -275,4 +275,25 @@ describe('renderer: component', () => {
await nextTick()
expect(App.updated).toHaveBeenCalledTimes(0)
})
describe('render with access caches', () => {
// #3297
test('should not set the access cache in the data() function (production mode)', () => {
const Comp = {
data() {
;(this as any).foo
return { foo: 1 }
},
render() {
return h('h1', (this as any).foo)
}
}
const root = nodeOps.createElement('div')
__DEV__ = false
render(h(Comp), root)
__DEV__ = true
expect(serializeInner(root)).toBe(`<h1>1</h1>`)
})
})
})