aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax/parseXML.js
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2013-09-08 21:05:07 -0400
committerTimmy Willison <timmywillisn@gmail.com>2013-09-08 21:05:07 -0400
commit99c123b159e85ab9d97bea65a5ec4fff62023bf9 (patch)
tree6416b60fffdbdc8ee09dfdd3de0aed20b4fdf11d /src/ajax/parseXML.js
parenteb9cbfcaf6803a07a953e0ca0922a973c5a11016 (diff)
downloadjquery-99c123b159e85ab9d97bea65a5ec4fff62023bf9.tar.gz
jquery-99c123b159e85ab9d97bea65a5ec4fff62023bf9.zip
Move parsing methods to their own files (separates manipulation dependency from core)
Diffstat (limited to 'src/ajax/parseXML.js')
-rw-r--r--src/ajax/parseXML.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ajax/parseXML.js b/src/ajax/parseXML.js
new file mode 100644
index 000000000..9103c3d6f
--- /dev/null
+++ b/src/ajax/parseXML.js
@@ -0,0 +1,26 @@
+define([
+ "../core"
+], function( jQuery ) {
+ // Cross-browser xml parsing
+ jQuery.parseXML = function( data ) {
+ var xml, tmp;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+
+ // Support: IE9
+ try {
+ tmp = new DOMParser();
+ xml = tmp.parseFromString( data , "text/xml" );
+ } catch ( e ) {
+ xml = undefined;
+ }
+
+ if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
+ jQuery.error( "Invalid XML: " + data );
+ }
+ return xml;
+ };
+
+ return jQuery.parseXML;
+});