From e7ca7b1e95385988272cbe5db393f32ca56e1636 Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Mon, 21 Apr 2014 09:23:17 -0400 Subject: [PATCH] Prefer DOMParser over ActiveX when both are availables. --- src/openseadragon.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index 289652b6..628d128d 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1947,23 +1947,9 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ * @returns {Document} */ parseXml: function( string ) { - //TODO: yet another example where we can determine the correct - // implementation once at start-up instead of everytime we use - // the function. DONE. - if ( window.ActiveXObject ) { + if ( window.DOMParser ) { - $.parseXml = function( string ){ - var xmlDoc = null; - - xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" ); - xmlDoc.async = false; - xmlDoc.loadXML( string ); - return xmlDoc; - }; - - } else if ( window.DOMParser ) { - - $.parseXml = function( string ){ + $.parseXml = function( string ) { var xmlDoc = null, parser; @@ -1972,6 +1958,17 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ return xmlDoc; }; + } else if ( window.ActiveXObject ) { + + $.parseXml = function( string ) { + var xmlDoc = null; + + xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" ); + xmlDoc.async = false; + xmlDoc.loadXML( string ); + return xmlDoc; + }; + } else { throw new Error( "Browser doesn't support XML DOM." ); }