Fix for #907
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 5 Feb 2007 20:16:46 +0000 (20:16 +0000)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 5 Feb 2007 20:16:46 +0000 (20:16 +0000)
build/test/data/dashboard.xml
src/jquery/coreTest.js
src/jquery/jquery.js

index d954f27..d230559 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <dashboard>\r
-       <locations>\r
-               <location>\r
+       <locations class="foo">
+               <location for="bar">\r
                        <infowindowtab>\r
                                <tab title="Location"><![CDATA[blabla]]></tab>\r
                                <tab title="Users"><![CDATA[blublu]]></tab>\r
index a753315..f24a10b 100644 (file)
@@ -74,7 +74,7 @@ test("index(Object)", function() {
 });\r
 \r
 test("attr(String)", function() {\r
-       expect(13);\r
+       expect(15);\r
        ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );\r
        ok( $('#text1').attr('type') == "text", 'Check for type attribute' );\r
        ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );\r
@@ -88,6 +88,12 @@ test("attr(String)", function() {
        ok( $('#text1').attr('name') == "action", 'Check for name attribute' );\r
        ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );\r
        ok( $('#anchor2').attr('href') == "#2", 'Check for non-absolute href (an anchor)' );\r
+       stop();\r
+       $.get("data/dashboard.xml", function(xml) {\r
+               ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );\r
+               ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );\r
+               start();\r
+       });\r
 });\r
 \r
 test("attr(String, Function)", function() {\r
index 004d634..e58f895 100644 (file)
@@ -1228,6 +1228,11 @@ jQuery.extend({
                return !!fn && typeof fn != "string" &&
                        typeof fn[0] == "undefined" && /function/i.test( fn + "" );
        },
+       
+       // check if an element is in a XML document
+       isXMLDoc: function(elem) {
+               return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
+       },
 
        nodeName: function( elem, name ) {
                return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
@@ -1476,7 +1481,7 @@ jQuery.extend({
        },
        
        attr: function(elem, name, value){
-               var fix = {
+               var fix = jQuery.isXMLDoc(elem) ? {} : {
                        "for": "htmlFor",
                        "class": "className",
                        "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
@@ -1507,6 +1512,8 @@ jQuery.extend({
                // Mozilla doesn't play well with opacity 1
                if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
                        value = 0.9999;
+                       
+               // 
 
                // Certain attributes only work when accessed via the old DOM 0 way
                if ( fix[name] ) {
@@ -1518,7 +1525,8 @@ jQuery.extend({
 
                // IE elem.getAttribute passes even for style
                else if ( elem.tagName ) {
-                       if ( value != undefined ) elem.setAttribute( name, value );
+                       if ( value != undefined ) 
+                               elem.setAttribute( name, value );
                        return elem.getAttribute( name );
 
                } else {