Skip to content

Loaders - check if node exists in DOM before attaching handler? #10

@madsenmm

Description

@madsenmm

As the title says, there are cases where content is replaced entirely, but the components initial loader on mount still exists, and therefore triggers multiple times, and then behaves unexpectedly because of sudden multiple triggers on non-existent elements in the DOM.

Current fixes

// Bail early if node doesn't exists anymore
if (!document.body.contains(node)) {
  return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions