Skip to content

Removing a control not previously added raises an error #2877

Closed
@jenkin

Description

I refer to v0.7.3 tag, not to the last commit.

If I add a control on a map using control.addTo(map), I can remove it later using control.removeFrom(map) without problems. But if I try to remove it before any addTo(map) calls, it fails: "Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node" (in Chomium console).

It could be possibile to add a boolean in control definition (in https://github.com/Leaflet/Leaflet/blob/v0.7.3/src/control/Control.js) such as control.isAdded to track the state of the control and to use it in add / remove methods and avoid errors.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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