Skip to content

Bug: <iframe /> onLoad is not getting triggered after the reload triggered by moving the DOM Node #18752

@adamziel

Description

@adamziel

When an <iframe /> DOM Node is moved to a different place in the tree, Chrome triggers a reload. That reload does not notify event handlers registered via onLoad=. In other words:

  • If there is an event handler registered via onLoad={myCallback}, it will not be fired.
  • If there is an event handler registered via iframe.addEventListener("load", myCallback, false), it will be fired.

React version: 16.13.1

Steps To Reproduce

Open a code example below and move the iframe down using arrow button next to it.

https://codesandbox.io/s/serverless-surf-k1ypg?file=/src/App.js

The current behavior

The iframe does not say "Initialized" anymore.

The expected behavior

The iframe should say "Initialized".

Other notes

If you move setIframeContent(e.currentTarget); to nativeLoad and repeat the steps above, it works as expected. The bug does not occur in Firefox.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions