Skip to content

Commit e8d8f5f

Browse files
authored
fix(reactivity): add __v_skip flag to Dep to prevent reactive conversion (#12804)
close #12803
1 parent 5ba1afb commit e8d8f5f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/reactivity/__tests__/readonly.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import {
88
reactive,
99
readonly,
1010
ref,
11+
shallowRef,
1112
toRaw,
13+
triggerRef,
1214
} from '../src'
1315

1416
/**
@@ -520,3 +522,16 @@ describe('reactivity/readonly', () => {
520522
expect(r.value).toBe(ro)
521523
})
522524
})
525+
526+
test('should be able to trigger with triggerRef', () => {
527+
const r = shallowRef({ a: 1 })
528+
const ror = readonly(r)
529+
let dummy
530+
effect(() => {
531+
dummy = ror.value.a
532+
})
533+
r.value.a = 2
534+
expect(dummy).toBe(1)
535+
triggerRef(ror)
536+
expect(dummy).toBe(2)
537+
})

packages/reactivity/src/dep.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ export class Dep {
9393
*/
9494
sc: number = 0
9595

96+
/**
97+
* @internal
98+
*/
99+
readonly __v_skip = true
100+
// TODO isolatedDeclarations ReactiveFlags.SKIP
101+
96102
constructor(public computed?: ComputedRefImpl | undefined) {
97103
if (__DEV__) {
98104
this.subsHead = undefined

0 commit comments

Comments
 (0)