Skip to content

Commit 79f23f2

Browse files
committed
fix(autoHeightBridge): reintroduce iframe load handler and ensure image/iframe listeners run on bootstrap
1 parent 951d063 commit 79f23f2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/constants/autoHeightBridge.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,16 @@ export const AUTO_HEIGHT_BRIDGE = `(() => {
217217
window.__AUTO_HEIGHT_VISUAL_VIEWPORT_HANDLER__ = handler;
218218
};
219219
220-
const attachFontLoadListeners = () => {
221-
const fonts = document.fonts;
222-
if (!fonts || !fonts.addEventListener) {
220+
const attachIframeLoadListeners = () => {
221+
const iframes = document.querySelectorAll('iframe');
222+
if (!iframes.length) {
223223
return;
224224
}
225225
226226
const handler = () => scheduleHeightUpdate();
227-
fonts.addEventListener('loadingdone', handler);
228-
fonts.addEventListener('loadingerror', handler);
229-
window.__AUTO_HEIGHT_FONT_HANDLER__ = handler;
227+
for (let index = 0; index < iframes.length; index += 1) {
228+
iframes[index].addEventListener('load', handler);
229+
}
230230
};
231231
232232
const attachGlobalListeners = () => {
@@ -251,6 +251,8 @@ export const AUTO_HEIGHT_BRIDGE = `(() => {
251251
attachResizeObserver();
252252
attachVisualViewport();
253253
attachFontLoadListeners();
254+
attachImageLoadListeners();
255+
attachIframeLoadListeners();
254256
attachGlobalListeners();
255257
scheduleHeightUpdate();
256258

0 commit comments

Comments
 (0)