Skip to content

Commit f97c81d

Browse files
feat: add onBeforeMount callback to createIframeUi options (#1899)
Co-authored-by: Aaron <[email protected]>
1 parent b7b3fc5 commit f97c81d

File tree

1 file changed

+6
-0
lines changed
  • packages/wxt/src/utils/content-script-ui

1 file changed

+6
-0
lines changed

packages/wxt/src/utils/content-script-ui/iframe.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function createIframeUi<TMounted>(
2222
let mounted: TMounted | undefined = undefined;
2323
const mount = () => {
2424
applyPosition(wrapper, iframe, options);
25+
options.onBeforeMount?.(wrapper, iframe);
2526
mountUi(wrapper, options);
2627
mounted = options.onMount?.(wrapper, iframe);
2728
};
@@ -73,4 +74,9 @@ export type IframeContentScriptUiOptions<TMounted> =
7374
* Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
7475
*/
7576
onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted;
77+
/**
78+
* Callback executed before mounting the UI. Use this function to customize the iframe or wrapper
79+
* elements before they are injected into the DOM. It is called every time `ui.mount()` is called.
80+
*/
81+
onBeforeMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => void;
7682
};

0 commit comments

Comments
 (0)