File tree 3 files changed +5
-92
lines changed
3 files changed +5
-92
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import {
2
- type ComputedGetter ,
3
- type WritableComputedOptions ,
4
- computed as _computed ,
5
- } from '@vue/reactivity'
1
+ import { computed as _computed } from '@vue/reactivity'
6
2
import { isInSSRComponentSetup } from './component'
7
- import { isFunction } from '@vue/shared'
8
-
9
- /**
10
- * For dev warning only.
11
- * Context: https://github.com/vuejs/core/discussions/9974
12
- */
13
- export let isInComputedGetter = false
14
-
15
- function wrapComputedGetter (
16
- getter : ComputedGetter < unknown > ,
17
- ) : ComputedGetter < unknown > {
18
- return ( ) => {
19
- isInComputedGetter = true
20
- try {
21
- return getter ( )
22
- } finally {
23
- isInComputedGetter = false
24
- }
25
- }
26
- }
27
3
28
4
export const computed : typeof _computed = (
29
- getterOrOptions : ComputedGetter < unknown > | WritableComputedOptions < unknown > ,
5
+ getterOrOptions : any ,
30
6
debugOptions ?: any ,
31
7
) => {
32
- if ( __DEV__ ) {
33
- if ( isFunction ( getterOrOptions ) ) {
34
- getterOrOptions = wrapComputedGetter ( getterOrOptions )
35
- } else {
36
- getterOrOptions . get = wrapComputedGetter ( getterOrOptions . get )
37
- }
38
- }
39
-
40
- // @ts -expect-error the 3rd argument is hidden from public types
8
+ // @ts -expect-error
41
9
return _computed ( getterOrOptions , debugOptions , isInSSRComponentSetup )
42
10
}
Original file line number Diff line number Diff line change @@ -85,7 +85,6 @@ import {
85
85
} from './compat/compatConfig'
86
86
import type { SchedulerJob } from './scheduler'
87
87
import type { LifecycleHooks } from './enums'
88
- import { isInComputedGetter } from './apiComputed'
89
88
90
89
export type Data = Record < string , unknown >
91
90
@@ -632,18 +631,8 @@ export function createComponentInstance(
632
631
633
632
export let currentInstance : ComponentInternalInstance | null = null
634
633
635
- export const getCurrentInstance : ( ) => ComponentInternalInstance | null =
636
- ( ) => {
637
- if ( __DEV__ && isInComputedGetter ) {
638
- warn (
639
- `getCurrentInstance() called inside a computed getter. ` +
640
- `This is incorrect usage as computed getters are not guaranteed ` +
641
- `to be executed with an active component instance. If you are using ` +
642
- `a composable inside a computed getter, move it ouside to the setup scope.` ,
643
- )
644
- }
645
- return currentInstance || currentRenderingInstance
646
- }
634
+ export const getCurrentInstance : ( ) => ComponentInternalInstance | null = ( ) =>
635
+ currentInstance || currentRenderingInstance
647
636
648
637
let internalSetCurrentInstance : (
649
638
instance : ComponentInternalInstance | null ,
You can’t perform that action at this time.
2 commit comments
ferferga commentedon Jan 9, 2024
@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?
ferferga commentedon Jan 9, 2024
Found the ongoing discussion (leaving this for future lurkers): #9974 (comment)