传单区域选择在 Internet Explorer 上删除

Leaflet Areaselect remove on Internet Explorer

本文关键字:Internet Explorer 删除 选择 单区域 区域      更新时间:2023-09-26
嗨,我

正在使用传单区域选择,当我在IE上使用删除功能时,我收到以下错误:

SCRIPT438:对象不支持属性或方法"删除">

文件: 传单区域选择.js, 行: 45, 列: 9

你们中有没有人可以在IE浏览器上运行此功能?我尝试了chrome和Firefox,这很好。

var areaSelect = L.areaSelect({
    width:100, 
    height:150, 
    keepAspectRatio:true
}).addTo(map);
areaSelect.remove();

这是Plunker上的一个测试用例:http://plnkr.co/edit/Snj1cB?p=preview

做了一些调试/挖掘,这是错误。有问题的容器元素在这里创建:https://github.com/heyman/leaflet-areaselect/blob/master/src/leaflet-areaselect.js#L52 它是通过使用L.DomUtil.create创建的,它只不过是createElement的包装器:https://github.com/Leaflet/Leaflet/blob/master/src/dom/DomUtil.js#L22 并应用类名。

在Chrome/Safari(webkit(和Firefox中创建的元素具有本机remove()方法,这不是根据标准。IE没有,因此错误。根据我的猜测remove只不过是一个用于执行element.parentNode.removeChild(element);的包装器 插件的创建者应该使用它来保持跨浏览器兼容。

我建议提交错误报告:https://github.com/heyman/leaflet-areaselect/issues

编辑:已经提出了一个问题,但没有太多的行动/后续行动,发表了评论并链接到这个问题:https://github.com/heyman/leaflet-areaselect/issues/10,所以他也可以重现这一点。