From 8e892824fe5ce7dd5b1acaa4f1d97e87b147f414 Mon Sep 17 00:00:00 2001 From: Bohuslav Semenov Date: Tue, 16 Sep 2025 13:27:29 +0200 Subject: [PATCH] feat: add onBeforeMount callback to createIframeUi options --- packages/wxt/src/utils/content-script-ui/iframe.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/wxt/src/utils/content-script-ui/iframe.ts b/packages/wxt/src/utils/content-script-ui/iframe.ts index 65968ea38..11f1b84c3 100644 --- a/packages/wxt/src/utils/content-script-ui/iframe.ts +++ b/packages/wxt/src/utils/content-script-ui/iframe.ts @@ -23,6 +23,7 @@ export function createIframeUi( let mounted: TMounted | undefined = undefined; const mount = () => { applyPosition(wrapper, iframe, options); + options.onBeforeMount?.(wrapper, iframe); mountUi(wrapper, options); mounted = options.onMount?.(wrapper, iframe); }; @@ -73,4 +74,9 @@ export type IframeContentScriptUiOptions = * Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback. */ onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted; + /** + * Callback executed before mounting the UI. Use this function to customize the iframe or wrapper + * elements before they are injected into the DOM. It is called every time `ui.mount()` is called. + */ + onBeforeMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => void; };