Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch listens to computed and should not be triggered by ref in computed #3068

Closed
xlboy opened this issue Jan 20, 2021 · 1 comment · Fixed by #3066
Closed

Watch listens to computed and should not be triggered by ref in computed #3068

xlboy opened this issue Jan 20, 2021 · 1 comment · Fixed by #3066
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working

Comments

@xlboy
Copy link

xlboy commented Jan 20, 2021

Version

3.0.5

Reproduction link

https://jsfiddle.net/twgh75x4/4/

Steps to reproduce

test case

  it('watching multiple sources: computed', async () => {
    let count = 0
    const _ref = ref('1')
    const _computed = computed(() => !!_ref.value)
    
    watch([_computed], () => {
      count.value++
    })
    watch(_computed, () => {
      count.value++  
    })
    
    // When the _ref value changes
    // in factthe _computed value remains the same
    // watch should not be triggered
    _ref.value = '2' 
    // count.value is 1, Is not the expected 0
    await nextTick()

    _ref.value = '3'
    // count.value is 2, Is not the expected 0
    await nextTick()
    expect(count).toBe(0)
  })

What is expected?

experct(count).toBe(0)

What is actually happening?

experct(count).toBe(2)

@posva
Copy link
Member

posva commented Jan 20, 2021

Seems to be a regression of #2231

@posva posva added 🐞 bug Something isn't working ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Jan 20, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants