Skip to content

Events.removeEventListener fails when no events are registered. #1631

@tjoekbezoer

Description

@tjoekbezoer

Situation
Consider the following code:

var line = new L.Polyline(points, {clickable: false});

Now if you call line.removeEventListener('click') without manually adding a listener, it will throw an error.

Problem
This seems to be caused by the fact that the this['_leaflet_events'] will only exist if addEventListener is called at least once. removeEventListener however does not check the existence of the property.

Solution
Add the check :) See my pull request.

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