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

Frozen array in reactive breaks list rendering #867

Closed
CyberAP opened this issue Mar 23, 2020 · 1 comment
Closed

Frozen array in reactive breaks list rendering #867

CyberAP opened this issue Mar 23, 2020 · 1 comment

Comments

@CyberAP
Copy link
Contributor

CyberAP commented Mar 23, 2020

Version

3.0.0-alpha.9

Reproduction link

https://codesandbox.io/s/hopeful-newton-su9mz

Steps to reproduce

  1. Create frozen array
  2. Use that array as a value in reactive
  3. Pass that value as a prop in render function

What is expected?

Frozen arrays should be supported in lists

What is actually happening?

Rendering breaks

@thecrypticace
Copy link
Contributor

thecrypticace commented Mar 23, 2020

I did some poking around and will add that rendering only breaks when the frozen array contains objects. If it contains primitives it (from what I can tell) works as expected. It seems it's related to the proxy's that wrap objects.

The error is:

TypeError: 'get' on proxy: property '0' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '#<Object>' but got '[object Object]')

The following is a low-level code reproduction:

const list = ref(Object.freeze([{id: 1}]))
renderList(list.value, () => null)

@yyx990803 This seems like it would be a reasonable fix (at the end of get(…)) but I'm not 100% certain that this would always work as expected. Thoughts?

    const descriptor = Reflect.getOwnPropertyDescriptor(target, key);
    if (descriptor && !descriptor.configurable && !descriptor.writable) {
      return res
    }

@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants