Skip to content

Icon.Default.detectIconPath can throw TypeError: path is nullΒ #5534

Closed
@williamscs

Description

The line is specified at this link:
https://github.com/Leaflet/Leaflet/blob/master/src/layer/marker/Icon.Default.js#L52

DomUtil.getStyle has the ability to return null, but there is no check for this in the calling method.

This can occur in a few scenarios, but specifically occurs if you are using the leaflet.js library, but the DOM hasn't loaded yet.

In my situation, in Firefox (not IE or Chrome) leaflet is loading in an iframe that is in a separate tab. I'm not sure why, but when the detectIconPath attempts to create the div with the class, the rule is not loaded and there is no background-image.

Due to this, even if I override the options with a new imagePath, the check still attempts and throws the exception since there isn't a check.

Current workaround is to assign L.Icon.Default.imagePath directly so that method is not called.

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