Skip to content

Commit 9bb36f1

Browse files
author
Lanny McNie
committed
Wrapped XML parsing in try/catch
Signed-off-by: Lanny McNie <lanny@gskinner.com>
1 parent b0a53d9 commit 9bb36f1

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

VERSIONS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ CRITICAL (may break existing content)
2323
- Fixed issue with XHR scripts and maxConnections.
2424
- Added an argument to LoadQueue to specify a crossOrigin property on images tags generated by PreloadJS.
2525
- included a sample htaccess file in /extras that can be used to serve CORS-safe images.
26+
- Wrapped XML parsing in a try/catch. CocoonJS doesn't support it, and Opera has occasional issues with XML.
2627

2728

2829
Version 0.4.0 [September 25, 2013]

src/preloadjs/XHRLoader.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,18 @@ this.createjs = this.createjs || {};
588588
*/
589589
p._parseXML = function (text, type) {
590590
var xml = null;
591-
if (window.DOMParser) {
592-
var parser = new DOMParser();
593-
xml = parser.parseFromString(text, type); // OJR Opera throws DOMException: NOT_SUPPORTED_ERR // potential solution https://gist.github.com/1129031
594-
} else { // IE
595-
xml = new ActiveXObject("Microsoft.XMLDOM");
596-
xml.async = false;
597-
xml.loadXML(text);
598-
}
591+
try {
592+
// CocoonJS does not support XML parsing with either method.
593+
// Windows (?) Opera DOMParser throws DOMException: NOT_SUPPORTED_ERR // potential solution https://gist.github.com/1129031
594+
if (window.DOMParser) {
595+
var parser = new DOMParser();
596+
xml = parser.parseFromString(text, type);
597+
} else { // IE
598+
xml = new ActiveXObject("Microsoft.XMLDOM");
599+
xml.async = false;
600+
xml.loadXML(text);
601+
}
602+
} catch (e) {}
599603
return xml;
600604
};
601605

0 commit comments

Comments
 (0)