blob: acf7ab259fa6f7d50de8ae4e26e46bc8a8aaf8bf [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001define( [
2 "../core"
3], function( jQuery ) {
4
5"use strict";
6
7// Cross-browser xml parsing
8jQuery.parseXML = function( data ) {
9 var xml;
10 if ( !data || typeof data !== "string" ) {
11 return null;
12 }
13
14 // Support: IE 9 - 11 only
15 // IE throws on parseFromString with invalid input.
16 try {
17 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
18 } catch ( e ) {
19 xml = undefined;
20 }
21
22 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
23 jQuery.error( "Invalid XML: " + data );
24 }
25 return xml;
26};
27
28return jQuery.parseXML;
29
30} );