Skip to content

Commit

Permalink
feat(srcDoc): added onload arg
Browse files Browse the repository at this point in the history
  • Loading branch information
makhnatkin committed Oct 7, 2024
1 parent 5913371 commit 546251e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/runtime/SrcDocIFrameController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export class SrcDocIFrameController extends Disposable implements IEmbeddedConte

this.addAnchorLinkHandlers();
this.handleHashChange();
this.config.onload?.(this.host);
if (this.config.onload) {
this.dispose.add(() => this.config.onload?.(this.host));
}
}

// finds all relative links (href^="#") and changes their click behavior
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface EmbedsConfig {
classNames?: string[];
styles?: Record<string, string>;
isolatedSandboxHostURIOverride?: string;
onload?: (host: HTMLIFrameElement) => void;
onload?: (host: HTMLIFrameElement) => (() => void) | void;
}

export type Unsubscribe = () => void;
Expand Down

0 comments on commit 546251e

Please sign in to comment.