From 0f780ba7cc5968d53bba386bdcb59b8d9410873b Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Tue, 7 Jan 2020 23:59:08 +0100 Subject: Build:Tests: Fix custom build tests, verify on Travis This commit fixes unit tests for the following builds: 1. The no-deprecated build: `custom:-deprecated` 2. The current slim build: `custom:-ajax,-effects` 3. The future (#4553) slim build: `custom:-ajax,-callbacks,-deferred,-effects` It also adds separate Travis jobs for the no-deprecated & slim builds. Closes gh-4577 --- src/core/parseXML.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/core/parseXML.js (limited to 'src/core/parseXML.js') diff --git a/src/core/parseXML.js b/src/core/parseXML.js new file mode 100644 index 000000000..d547eab53 --- /dev/null +++ b/src/core/parseXML.js @@ -0,0 +1,24 @@ +import jQuery from "../core.js"; + +// Cross-browser xml parsing +jQuery.parseXML = function( data ) { + var xml; + if ( !data || typeof data !== "string" ) { + return null; + } + + // Support: IE 9 - 11+ + // IE throws on parseFromString with invalid input. + try { + xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); + } catch ( e ) { + xml = undefined; + } + + if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; +}; + +export default jQuery.parseXML; -- cgit v1.2.3