refactor(reactivity): use more efficient reactive checks
WeakSets and WeakMaps shows degrading performance as the amount of observed objects increases. Using hidden keys result in better performance especially when repeatedly creating large amounts of reactive proxies. This also makes it possible to more efficiently declare non-reactive objects in userland.
This commit is contained in:
18
packages/runtime-core/__tests__/misc.spec.ts
Normal file
18
packages/runtime-core/__tests__/misc.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { render, h, nodeOps, reactive, isReactive } from '@vue/runtime-test'
|
||||
|
||||
describe('misc', () => {
|
||||
test('component public instance should not be observable', () => {
|
||||
let instance: any
|
||||
const Comp = {
|
||||
render() {},
|
||||
mounted() {
|
||||
instance = this
|
||||
}
|
||||
}
|
||||
render(h(Comp), nodeOps.createElement('div'))
|
||||
expect(instance).toBeDefined()
|
||||
const r = reactive(instance)
|
||||
expect(r).toBe(instance)
|
||||
expect(isReactive(r)).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user