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

a ref of an array is marked as readonly #811

Closed
posva opened this issue Sep 8, 2021 · 1 comment
Closed

a ref of an array is marked as readonly #811

posva opened this issue Sep 8, 2021 · 1 comment

Comments

@posva
Copy link
Member

posva commented Sep 8, 2021

See https://jsfiddle.net/bqct135h/

isReadonly(ref([])) // true

But it should be false: SFC Playground

@webfansplz
Copy link
Member

readonly() is provided as API alignment with Vue 3 on type-level only. Use isReadonly() on it or it's properties can not be guaranteed.

In @vue/composition-api, Use isReadonly() always return true for reactive object , because:

export function createRef<T>(options: RefOption<T>, readonly = false) {
  const r = new RefImpl<T>(options)
  const sealed = Object.seal(r)
  readonlySet.set(sealed, true) // always trigger
  return sealed
}

@antfu antfu closed this as completed in d3c456a Sep 9, 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

No branches or pull requests

2 participants