Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | define( [ |
| 2 | "../core" |
| 3 | ], function( jQuery ) { |
| 4 | |
| 5 | "use strict"; |
| 6 | |
| 7 | // Cross-browser xml parsing |
| 8 | jQuery.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 | |
| 28 | return jQuery.parseXML; |
| 29 | |
| 30 | } ); |