Skip to content

Init side-effects #3

@dy

Description

@dy
  1. It won't trigger initial onload for elements that are in DOM already:
import onload from "fast-on-load";
onload(document.body, () => console.log('on'), () => console.log('off'))
// silence in console
  1. It triggers unload-only for elements present in both added/removed nodes:
let a = document.createElement(a)
onload(a, function () {
  console.log('on')
}, function () {
  console.log('off')
})

document.body.appendChild(a)
document.body.removeChild(a)

// logs only 'off' 

Just to make sure if that's planned behavior.

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