]> source.dussan.org Git - jquery.git/commitdiff
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 d954f27affdef8157082c10aaf357a127b30404f..d2305593d59a526ba836fc9c21cdfd653d8e600b 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 a75331558ab339e50ffc4538fe481d09a593d30f..f24a10b3bdc32017384847d5485960c3623e69c3 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 004d6341a3f618d4d4ee1bbf0ea16f36b0f11d1a..e58f895df21d94f54b2dc5cbfe92120c5f5dfde4 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 {