Skip to content

Commit c42c57d

Browse files
wckgochuankaiwei
andauthored
fix: useScript missing script API's return in proxy (#302)
* fix: useScript missing script API's return in proxy * fix: set the loaded field to true when the status is loaded --------- Co-authored-by: Chuankai Wei <chuankai.wei@lotusflare.com>
1 parent 4db8d1f commit c42c57d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/unhead/src/composables/useScript.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export function useScript<T>(input: UseScriptInput, _options?: UseScriptOptions<
6969
resolve(options.use())
7070
function watchForScriptLoaded({ script }: { script: ScriptInstance<T> }) {
7171
if (script.id === id && script.status === 'loaded') {
72+
script.loaded = true
7273
resolve(options.use?.() as T)
7374
head!.hooks.removeHook('script:updated', watchForScriptLoaded)
7475
}
@@ -172,7 +173,7 @@ export function useScript<T>(input: UseScriptInput, _options?: UseScriptOptions<
172173
return script.waitForLoad().then(
173174
(api) => {
174175
// @ts-expect-error untyped
175-
api[fn](...args)
176+
return api[fn](...args)
176177
},
177178
)
178179
}

0 commit comments

Comments
 (0)