v.value += ' World'
await nextTick()
- expect(serializeInner(root)).toBe('Hello World World World')
+ expect(serializeInner(root)).toBe('Hello World World World World')
// expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})
v.value += ' World'
await nextTick()
expect(serializeInner(root)).toBe(
- 'Hello World World World | Hello World World World',
+ 'Hello World World World World | Hello World World World World',
)
})
})
})
+ // #11797
test('should prevent endless recursion in self-referencing computed getters', async () => {
const Comp = defineComponent({
data() {
})
const root = nodeOps.createElement('div')
render(h(Comp), root)
- expect(serializeInner(root)).toBe(`<button>Step</button><p></p>`)
+ expect(serializeInner(root)).toBe(`<button>Step</button><p>Step 1</p>`)
triggerEvent(root.children[1] as TestElement, 'click')
await nextTick()
expect(serializeInner(root)).toBe(`<button>Step</button><p>Step 2</p>`)
* @internal
*/
notify(): void {
+ this.flags |= EffectFlags.DIRTY
// avoid infinite self recursion
if (activeSub !== this) {
- this.flags |= EffectFlags.DIRTY
this.dep.notify()
} else if (__DEV__) {
// TODO warn
for (let link = sub.deps; link; link = link.nextDep) {
if (
link.dep.version !== link.version ||
- (link.dep.computed && refreshComputed(link.dep.computed) === false) ||
+ (link.dep.computed && refreshComputed(link.dep.computed)) ||
link.dep.version !== link.version
) {
return true
* Returning false indicates the refresh failed
* @internal
*/
-export function refreshComputed(computed: ComputedRefImpl): false | undefined {
- if (computed.flags & EffectFlags.RUNNING) {
- return false
- }
+export function refreshComputed(computed: ComputedRefImpl): undefined {
if (
computed.flags & EffectFlags.TRACKING &&
!(computed.flags & EffectFlags.DIRTY)