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

fix(observe): solve the Ref not unwrapping on the ssr side issue with recursive way. #723

Merged
merged 3 commits into from Jul 2, 2021

Conversation

ygj6
Copy link
Member

@ygj6 ygj6 commented Jun 5, 2021

Solving #721 with #722

  it('result of #722', () => {
    const state = { old: ref(false) }
    set(state, 'new', ref(true))
    expect(JSON.stringify(state)).toBe(
      '{"old":{"value":false},"new":true}'  // 'old' is different from 'new'
    )
  })

the form of value of old key is different from new key.

if we solve #721 with recursive way:

  it('solving with recursive way', () => {
    const state = { old: ref(false) }
    set(state, 'new', ref(true))
    expect(JSON.stringify(state)).toBe(
      '{"old":{"value":false},"new":{"value":true}}'
    )
  })

for above case, should {"old":{"value":false},"new":{"value":true}} is more appropriate? @pikax @antfu Look forward your comments?

/**
* Recursive obj, add __ob__
*/
function walk(obj: any) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function walk(obj: any) {
function walk(obj: any, seen = new WeakMap<any, boolean>()) {

Would need a map to avoid circular reference.

@antfu antfu merged commit debd37d into vuejs:master Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants