]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(reactivity): add `__v_skip` flag to `Dep` to prevent reactive conversion (#12804)
authorSerKo <44749100+serkodev@users.noreply.github.com>
Thu, 5 Jun 2025 02:19:16 +0000 (10:19 +0800)
committerGitHub <noreply@github.com>
Thu, 5 Jun 2025 02:19:16 +0000 (10:19 +0800)
close #12803

packages/reactivity/__tests__/readonly.spec.ts
packages/reactivity/src/dep.ts

index 9acd5c6491ab5714890c502f5426332f49ad487d..b035779f85aba3736b6cea0de488903b57a3e34b 100644 (file)
@@ -8,7 +8,9 @@ import {
   reactive,
   readonly,
   ref,
+  shallowRef,
   toRaw,
+  triggerRef,
 } from '../src'
 
 /**
@@ -520,3 +522,16 @@ describe('reactivity/readonly', () => {
     expect(r.value).toBe(ro)
   })
 })
+
+test('should be able to trigger with triggerRef', () => {
+  const r = shallowRef({ a: 1 })
+  const ror = readonly(r)
+  let dummy
+  effect(() => {
+    dummy = ror.value.a
+  })
+  r.value.a = 2
+  expect(dummy).toBe(1)
+  triggerRef(ror)
+  expect(dummy).toBe(2)
+})
index 196c2aaf98ed7a2c372c1e82c6df0c4974d5d7cb..8ad8a389bafea77b262e8e7c1432c88fc930b565 100644 (file)
@@ -93,6 +93,12 @@ export class Dep {
    */
   sc: number = 0
 
+  /**
+   * @internal
+   */
+  readonly __v_skip = true
+  // TODO isolatedDeclarations ReactiveFlags.SKIP
+
   constructor(public computed?: ComputedRefImpl | undefined) {
     if (__DEV__) {
       this.subsHead = undefined