Subscribe on changes!

(reactivity): markRaw doesn't check whether an object is extensible

avatar
Feb 7th 2024

Vue version

3.4.15

Link to minimal reproduction

https://play.vuejs.org/#eNp9kD9PwzAQxb+K5aWtVCVDtxIhAeoAA0WF0UtILsGp/8k+pxFRvju2Q0sH1O3uvd+d3t1IH4zJeg90SwtXWW6QOEBv7pni0miLZCSytMdDeSITaayWZBHwBVNM/erL/WcHFWaNBfiG5TitVndMFfm8LiwKDYI0okQIHSFFzXuSh7LIr3S6pugqrRreZp3TKiQaI81opaXhAuzeINfKMbolyYleKYQ+vSQNrYf1Wa++oDr+o3duiBqjbxYc2B4YvXhY2hZwtnfvrzCE+mJKXXsR6BvmAZwWPmacsUev6hD7iktpn9NfuWo/3G5AUO58VAwaySnxjIY/P904/S/uJtukOaYmOv0AgyybQQ==

Steps to reproduce

  1. Mark an object as non-extensible by sealing or freezing it.
  2. Try to mark it as raw using markRaw.

What is expected?

markRaw should just return the original object since it can't be changed (or observed) anyway. This is how it already works in Vue 2.7 and it makes sense to keep the same behavior here.

What is actually happening?

markRaw tries to define a new property on the object causing a TypeError.

System Info

System:
    OS: macOS 12.6.8
    CPU: (10) arm64 Apple M1 Pro
    Memory: 160.86 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.17.1/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    pnpm: 8.15.1 - ~/.nvm/versions/node/v18.17.1/bin/pnpm
  Browsers:
    Chrome: 121.0.6167.139
    Safari: 17.0

Any additional comments?

No response