-
Notifications
You must be signed in to change notification settings - Fork 237
Open
Description
in storphe.private.js, the code below does not work in Internet Explorer 9-10.
_textToXml: function( text ){
var doc = null;
try {
if( window.DOMParser ){
var parser = new DOMParser();
doc = parser.parseFromString( text, 'text/xml');
} else {
doc = new ActiveXObject("MSXML2.DOMDocument");
doc.async = false;
doc.loadXML(text);
}
...
},
I think that parser.parseFromString seems to be throwing an exception.
I make some workaround this problem:
_isIE : function() {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
},
_isPlainText : function(text){
return !/<[^>]*>((.|[\n\r])*)<\/[^>]+>/.test(text);
},
_textToXml: function( text ){
var doc = null;
/* IE는 plain text를 parseFromString의 인자로 전달하면 exception 발생함. */
if( this._isIE() && this._isPlainText() ){
return null;
}
try {
if( window.DOMParser ){
var parser = new DOMParser();
doc = parser.parseFromString( text, 'text/xml');
} else {
doc = new ActiveXObject("MSXML2.DOMDocument");
doc.async = false;
doc.loadXML(text);
}
} catch(e) {
throw {
type: 'Parse error',
message: "No DOM parser object found."
};
}
var error = doc.getElementsByTagName("parsererror");
if( error.length > 0 ){
return null;
}
if(doc.body == null){
return null;
}
var node = document.importNode( doc.documentElement, true );
return node;
},
Metadata
Metadata
Assignees
Labels
No labels