]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(reactivity): add failSilently argument for onScopeDispose
authorEvan You <yyx990803@gmail.com>
Thu, 7 Mar 2024 09:54:18 +0000 (17:54 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 7 Mar 2024 09:54:18 +0000 (17:54 +0800)
packages/reactivity/src/effectScope.ts

index b9d72f44d0a1f0af3a8fc8d360bf4bf12066f33a..bc45f8491b83a8d7e7af4cbbeef2d5eb8fdf605c 100644 (file)
@@ -136,10 +136,10 @@ export function getCurrentScope() {
  * @param fn - The callback function to attach to the scope's cleanup.
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
  */
-export function onScopeDispose(fn: () => void) {
+export function onScopeDispose(fn: () => void, failSilently = false) {
   if (activeEffectScope) {
     activeEffectScope.cleanups.push(fn)
-  } else if (__DEV__) {
+  } else if (__DEV__ && !failSilently) {
     warn(
       `onScopeDispose() is called when there is no active effect scope` +
         ` to be associated with.`,