Skip to content

Use addEventListener('load', {once: true}) to get rid of destroyBadge() #2

@bblanchon

Description

@bblanchon

Hi,

When I discovered your library, I was puzzled by the presence of destroyBadge().
Then, I saw that it was only used to call removeEventListener().

You can eliminate this call if you pass {once: true} to addEventListener().

Extract from MDN:

once Optional

A boolean value indicating that the listener should be invoked at most once after being added. If true, the listener would be automatically removed when invoked. If not specified, defaults to false.

Let me know if I should open a PR.

Best regards,
Benoit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions