expect(isReactive(obj.bar)).toBe(false)
})
+ test('markRaw should skip non-extensible objects', () => {
+ const obj = Object.seal({ foo: 1 })
+ expect(() => markRaw(obj)).not.toThrowError()
+ })
+
test('should not observe non-extensible objects', () => {
const obj = reactive({
foo: Object.preventExtensions({ a: 1 }),
* @see {@link https://vuejs.org/api/reactivity-advanced.html#markraw}
*/
export function markRaw<T extends object>(value: T): Raw<T> {
- def(value, ReactiveFlags.SKIP, true)
+ if (Object.isExtensible(value)) {
+ def(value, ReactiveFlags.SKIP, true)
+ }
return value
}