Icon.Default.detectIconPath can throw TypeError: path is null
See original GitHub issueThe 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
@chpio you can set
L.Icon.Default.prototype.options.imagePath
.Is there no other way to pass configuration directly to leaflets js code, reading css is an unusual way passing config to a js lib?
Map seem to break too when the js code gets executed before the css can take effect.
This is relaying on hacks like this one.