Subscribe on changes!

Wrapping a computed in `readonly()` causes console warnings and breaks the computed's functionality

avatar
Mar 6th 2021

Version

3.0.7

Reproduction link

https://codesandbox.io/s/admiring-mendel-pgnty?file=/src/App.vue

Steps to reproduce

  1. Open the Sandbox link
  2. Check console and see readonly warnings
  3. Read explanation in App.vue or below

What is expected?

  1. No warnings about readonly properties
  2. computed logging true to the console

What is actually happening?

  1. Warning about readonly properties _value & _dirty being set
  2. computed stops working, longs undefined

reading the value from the readonly-computed causes console warnings about setting readonly properties _value && _dirty - however, those are internal properties of the computed implementation and need to be allowed to be set.

This also breaks the computed itself, as it can no longer be marked as dirty or update its computed value - that's why it logs undefined to the console instead of true

Already working on a PR