Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Static content optimization] <iframe> onload events may not fire #4081

Closed
nolanlawson opened this issue Mar 19, 2024 · 0 comments · Fixed by #4082
Closed

[Static content optimization] <iframe> onload events may not fire #4081

nolanlawson opened this issue Mar 19, 2024 · 0 comments · Fixed by #4082
Labels

Comments

@nolanlawson
Copy link
Contributor

nolanlawson commented Mar 19, 2024

Description

The onload event does not fire for an <iframe> without a src because the event listener is added after the <iframe> has already been inserted into the DOM. This only occurs when the <iframe> is optimized by the static content optimization.

Steps to Reproduce

Minimal repro

<template>
  <iframe onload={loadHandler}></iframe>
  <span if:true={loaded}>show me</span>
</template>
import { LightningElement } from 'lwc';

export default class extends LightningElement {
    loaded = false;

    loadHandler() {
        console.log('load handler called');
        this.loaded = true;
    }
}

Expected Results

onload handler fires

Actual Results

onload handler does not fire

Possible Solution
Adding data-foo={foo} to the iframe disables the static content optimization, and the bug goes away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant