Skip to content

Commit

Permalink
fix(useScript): avoid registering promises server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Oct 14, 2024
1 parent ab17616 commit 4416366
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/unhead/src/composables/useScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export function useScript<T extends Record<symbol | string, any> = Record<symbol
}
else if (trigger instanceof Promise) {
script._triggerAbortController = script._triggerAbortController || new AbortController()
// promise triggers only work client side
if (head.ssr) {
return
}
script._triggerPromises = script._triggerPromises || []
const idx = script._triggerPromises.push(Promise.race([
trigger.then(v => typeof v === 'undefined' || v ? script.load : undefined),
Expand Down

0 comments on commit 4416366

Please sign in to comment.