@@ -6,16 +6,22 @@ import type CoreModal from './components/CoreModal/CoreModal.vue'
6
6
import { internalVfmSymbol } from './injectionSymbols'
7
7
8
8
import type { ComponentProps , Constructor , InternalVfm , ModalSlot , ModalSlotOptions , RawProps , UseModalOptions , UseModalOptionsPrivate , UseModalReturnType , Vfm } from './Modal'
9
- import { activeVfm , getActiveVfm } from './plugin'
9
+ import { getActiveVfm } from './plugin'
10
10
11
11
/**
12
12
* Returns the vfm instance. Equivalent to using `$vfm` inside
13
13
* templates.
14
14
*/
15
15
export function useVfm ( ) : Vfm {
16
16
const vfm = getActiveVfm ( )
17
- if ( __DEV__ && ! vfm )
18
- consoleError ( )
17
+ if ( __DEV__ && ! vfm ) {
18
+ throw new Error (
19
+ '[Vue Final Modal]: getActiveVfm was called with no active Vfm. Did you forget to install vfm?\n'
20
+ + '\tconst vfm = createVfm()\n'
21
+ + '\tapp.use(vfm)\n'
22
+ + 'This will fail in production.' ,
23
+ )
24
+ }
19
25
20
26
return vfm !
21
27
}
@@ -80,10 +86,6 @@ export function useModal<P = InstanceType<typeof VueFinalModal>['$props']>(_opti
80
86
async function open ( ) : Promise < string > {
81
87
await nextTick ( )
82
88
const vfm = useVfm ( )
83
- if ( ! vfm ) {
84
- consoleError ( )
85
- return Promise . resolve ( 'error' )
86
- }
87
89
if ( options . modelValue )
88
90
return Promise . resolve ( '[Vue Final Modal] modal is already opened.' )
89
91
@@ -152,10 +154,6 @@ export function useModal<P = InstanceType<typeof VueFinalModal>['$props']>(_opti
152
154
153
155
function destroy ( ) : void {
154
156
const vfm = useVfm ( )
155
- if ( ! vfm ) {
156
- consoleError ( )
157
- return
158
- }
159
157
const index = vfm . dynamicModals . indexOf ( options )
160
158
if ( index !== - 1 )
161
159
vfm . dynamicModals . splice ( index , 1 )
@@ -221,14 +219,3 @@ export function useVfmAttrs(options: {
221
219
222
220
return vfmAttrs
223
221
}
224
-
225
- function consoleError ( ) {
226
- if ( __DEV__ && ! activeVfm ) {
227
- throw new Error (
228
- '[Vue Final Modal]: getActiveVfm was called with no active Vfm. Did you forget to install vfm?\n'
229
- + '\tconst vfm = createVfm()\n'
230
- + '\tapp.use(vfm)\n'
231
- + 'This will fail in production.' ,
232
- )
233
- }
234
- }
0 commit comments