2015-02-11 57 views
1

嗨,我是用单张areaselect,当我使用Internet Explorer上的删除功能,我得到了以下错误:单张Areaselect上删除Internet Explorer

SCRIPT438: Object doesn't support property or method 'remove'

File: leaflet-areaselect.js, Line: 45, Column: 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

+0

为您添加了一个测试用例和错误消息,并且可以说我的Internet Explorer 11.0.9600.17501更新11.0.15更新了11.0.15 – iH8 2015-02-11 23:36:34

+0

嗨,我尝试了IE 11并且它可以正常工作,但IE10不能正常工作。 – 2015-02-12 11:52:31

+0

非常奇怪,对我来说不是。但后来又出现了与Firefox不一致的问题,在我回答下面的Github问题中,有人说他有Firefox问题,但他/她有Ubuntu。我对Firefox没有任何问题。必须是修订/更新的东西 – iH8 2015-02-12 11:57:13

回答

1

做了一些调试/挖掘,这是错误。这里创建的容器元素被创建为: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,所以他也可以重现此。

+0

谢谢这是非常有用的,我通过“this._container.parentNode.removeChild(this._container)”更改“this._container.remove()”,它在每个浏览器上都很棒。顺便说一句功能删除仍然在IE 11上工作。 – 2015-02-12 11:50:10

+0

正如您在问题的评论中所解释的那样,对我来说它并不是,但它已经不再重要,因为问题已经解决:https://github.com/heyman/leaflet-areaselect/issues/10#issuecomment -73999141 – iH8 2015-02-12 12:02:36

相关问题