Skip to content

Original triggering event layer inaccessible in 0.7 when using event delegation #2252

@kirkedev

Description

@kirkedev

I have a FeatureGroup that contains two GeoJSON collections. I want to fire a popup on a mouseover event on a GeoJSON feature, and have been doing so with event delegation by binding a mouseover event handler to the parent FeatureGroup.

Prior to 0.7, the event.layer object in the handler would point to the feature that originally triggered the event. It seems to me that 2464d13 is overwriting event.layer to always equal event.target, even if event.layer already has a value. In the above case, event.target = event.layer = the GeoJSON collection containing the layer, with the default context being the parent FeatureGroup. This means I have no way to access the original layer and set the content of the popup from the feature's properties.

I will be sending over a commit shortly that fixes the issue on my end, but I admit I don't understand the issue in #1938 well enough to know that it doesn't regress that fix.

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