@@ -6,16 +6,22 @@ import type CoreModal from './components/CoreModal/CoreModal.vue'
66import { internalVfmSymbol } from './injectionSymbols'
77
88import type { ComponentProps , Constructor , InternalVfm , ModalSlot , ModalSlotOptions , RawProps , UseModalOptions , UseModalOptionsPrivate , UseModalReturnType , Vfm } from './Modal'
9- import { activeVfm , getActiveVfm } from './plugin'
9+ import { getActiveVfm } from './plugin'
1010
1111/**
1212 * Returns the vfm instance. Equivalent to using `$vfm` inside
1313 * templates.
1414 */
1515export function useVfm ( ) : Vfm {
1616 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+ }
1925
2026 return vfm !
2127}
@@ -80,10 +86,6 @@ export function useModal<P = InstanceType<typeof VueFinalModal>['$props']>(_opti
8086 async function open ( ) : Promise < string > {
8187 await nextTick ( )
8288 const vfm = useVfm ( )
83- if ( ! vfm ) {
84- consoleError ( )
85- return Promise . resolve ( 'error' )
86- }
8789 if ( options . modelValue )
8890 return Promise . resolve ( '[Vue Final Modal] modal is already opened.' )
8991
@@ -152,10 +154,6 @@ export function useModal<P = InstanceType<typeof VueFinalModal>['$props']>(_opti
152154
153155 function destroy ( ) : void {
154156 const vfm = useVfm ( )
155- if ( ! vfm ) {
156- consoleError ( )
157- return
158- }
159157 const index = vfm . dynamicModals . indexOf ( options )
160158 if ( index !== - 1 )
161159 vfm . dynamicModals . splice ( index , 1 )
@@ -221,14 +219,3 @@ export function useVfmAttrs(options: {
221219
222220 return vfmAttrs
223221}
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