Skip to content

Commit

Permalink
fix(reactivity): fix triggerRef to handle ObjectRefImpl instances
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhe141 committed Sep 20, 2024
1 parent e075dfa commit dbfc9e0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,19 @@ class RefImpl<T = any> {
* @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
*/
export function triggerRef(ref: Ref): void {
if (__DEV__) {
;(ref as unknown as RefImpl).dep.trigger({
target: ref,
type: TriggerOpTypes.SET,
key: 'value',
newValue: (ref as unknown as RefImpl)._value,
})
} else {
;(ref as unknown as RefImpl).dep.trigger()
// ref may be an instance of ObjectRefImpl
const dep = (ref as unknown as RefImpl).dep
if (dep) {
if (__DEV__) {
dep.trigger({
target: ref,
type: TriggerOpTypes.SET,
key: 'value',
newValue: (ref as unknown as RefImpl)._value,
})
} else {
dep.trigger()
}
}
}

Expand Down

0 comments on commit dbfc9e0

Please sign in to comment.