File tree 2 files changed +9
-5
lines changed
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -627,7 +627,7 @@ describe('api: options', () => {
627
627
render ( h ( Comp ) , root )
628
628
instance . foo = 1
629
629
expect (
630
- 'Computed property "foo" was assigned to but it has no setter. '
630
+ 'Write operation failed: computed property "foo" is readonly '
631
631
) . toHaveBeenWarned ( )
632
632
} )
633
633
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ import {
40
40
reactive ,
41
41
ComputedGetter ,
42
42
WritableComputedOptions ,
43
- ComputedRef
43
+ ComputedRef ,
44
+ toRaw
44
45
} from '@vue/reactivity'
45
46
import {
46
47
ComponentObjectPropsOptions ,
@@ -276,11 +277,12 @@ export function applyOptions(
276
277
errorCaptured
277
278
} = options
278
279
279
- const renderContext =
280
+ const renderContext = toRaw (
280
281
instance . renderContext === EMPTY_OBJ &&
281
282
( computedOptions || methods || watchOptions || injectOptions )
282
283
? ( instance . renderContext = reactive ( { } ) )
283
284
: instance . renderContext
285
+ )
284
286
285
287
const globalMixins = instance . appContext . mixins
286
288
// call it only during dev
@@ -355,7 +357,7 @@ export function applyOptions(
355
357
: __DEV__
356
358
? ( ) => {
357
359
warn (
358
- `Computed property "${ key } " was assigned to but it has no setter .`
360
+ `Write operation failed: computed property "${ key } " is readonly .`
359
361
)
360
362
}
361
363
: NOOP
@@ -369,7 +371,9 @@ export function applyOptions(
369
371
if ( renderContext [ key ] && ! ( key in proxyTarget ) ) {
370
372
Object . defineProperty ( proxyTarget , key , {
371
373
enumerable : true ,
372
- get : ( ) => ( renderContext [ key ] as ComputedRef ) . value
374
+ configurable : true ,
375
+ get : ( ) => ( renderContext [ key ] as ComputedRef ) . value ,
376
+ set : NOOP
373
377
} )
374
378
}
375
379
}
You can’t perform that action at this time.
0 commit comments