-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert: "dx(computed): warn incorrect use of getCurrentInstance insid…
…e computed" This reverts commit 324e817.
- Loading branch information
Showing
3 changed files
with
5 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,10 @@ | ||
import { | ||
type ComputedGetter, | ||
type WritableComputedOptions, | ||
computed as _computed, | ||
} from '@vue/reactivity' | ||
import { computed as _computed } from '@vue/reactivity' | ||
import { isInSSRComponentSetup } from './component' | ||
import { isFunction } from '@vue/shared' | ||
|
||
/** | ||
* For dev warning only. | ||
* Context: https://github.com/vuejs/core/discussions/9974 | ||
*/ | ||
export let isInComputedGetter = false | ||
|
||
function wrapComputedGetter( | ||
getter: ComputedGetter<unknown>, | ||
): ComputedGetter<unknown> { | ||
return () => { | ||
isInComputedGetter = true | ||
try { | ||
return getter() | ||
} finally { | ||
isInComputedGetter = false | ||
} | ||
} | ||
} | ||
|
||
export const computed: typeof _computed = ( | ||
getterOrOptions: ComputedGetter<unknown> | WritableComputedOptions<unknown>, | ||
getterOrOptions: any, | ||
debugOptions?: any, | ||
) => { | ||
if (__DEV__) { | ||
if (isFunction(getterOrOptions)) { | ||
getterOrOptions = wrapComputedGetter(getterOrOptions) | ||
} else { | ||
getterOrOptions.get = wrapComputedGetter(getterOrOptions.get) | ||
} | ||
} | ||
|
||
// @ts-expect-error the 3rd argument is hidden from public types | ||
// @ts-expect-error | ||
return _computed(getterOrOptions, debugOptions, isInSSRComponentSetup) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2fd3905
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yyx990803 Sorry for commenting in a commit, but it's the only reference I could find for this change.
May we know the reason for the revert?
2fd3905
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the ongoing discussion (leaving this for future lurkers): #9974 (comment)