aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/parseXML.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-01-07 23:59:08 +0100
committerGitHub <noreply@github.com>2020-01-07 23:59:08 +0100
commit0f780ba7cc5968d53bba386bdcb59b8d9410873b (patch)
tree7b67a1637447eea398606dc516e1f7a8cd8e22ab /src/core/parseXML.js
parent1dad1185e0b2ca2a13bf411558eda75fb2d4da88 (diff)
downloadjquery-0f780ba7cc5968d53bba386bdcb59b8d9410873b.tar.gz
jquery-0f780ba7cc5968d53bba386bdcb59b8d9410873b.zip
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
Diffstat (limited to 'src/core/parseXML.js')
-rw-r--r--src/core/parseXML.js24
1 files changed, 24 insertions, 0 deletions
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;