From a64b6c2e08fad8ea133bb07fd7cdfac1d5905549 Mon Sep 17 00:00:00 2001 From: Tamas Szekeres Date: Wed, 25 Mar 2015 20:20:43 +0100 Subject: [PATCH] Fix detection of activex support to work in IE11 --- lib/OpenLayers/Format/XML.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Format/XML.js b/lib/OpenLayers/Format/XML.js index b3f60ce9796..2316c302af7 100644 --- a/lib/OpenLayers/Format/XML.js +++ b/lib/OpenLayers/Format/XML.js @@ -70,6 +70,12 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { */ xmldom: null, + /** + * Property: supportActiveX + * Boolean flag to check if this browser uses ActiveX + */ + supportActiveX: false, + /** * Constructor: OpenLayers.Format.XML * Construct an XML parser. The parser is used to read and write XML. @@ -81,7 +87,9 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { * the object. */ initialize: function(options) { - if(window.ActiveXObject) { + this.supportActiveX = (Object.getOwnPropertyDescriptor && + Object.getOwnPropertyDescriptor(window, "ActiveXObject")) || ("ActiveXObject" in window); + if (this.supportActiveX) { this.xmldom = new ActiveXObject("Microsoft.XMLDOM"); } OpenLayers.Format.prototype.initialize.apply(this, [options]); @@ -138,7 +146,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { * Since we want to be able to call this method on the prototype * itself, this.xmldom may not exist even if in IE. */ - if(window.ActiveXObject && !this.xmldom) { + if (this.supportActiveX && !this.xmldom) { xmldom = new ActiveXObject("Microsoft.XMLDOM"); } else { xmldom = this.xmldom; @@ -871,7 +879,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { if (document.implementation && document.implementation.createDocument) { OpenLayers.Format.XML.document = document.implementation.createDocument("", "", null); - } else if (!this.xmldom && window.ActiveXObject) { + } else if (!this.xmldom && this.supportActiveX) { this.xmldom = new ActiveXObject("Microsoft.XMLDOM"); } }