aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2007-02-05 20:16:46 +0000
committerJörn Zaefferer <joern.zaefferer@gmail.com>2007-02-05 20:16:46 +0000
commit495ecb70b2b097e7d4a1ffe46d44562210cdc051 (patch)
tree96cc6ca3c78a9f23694a5903d4730b52b7549829
parent2c99c18652b9a098252d5443506c03fd45b2e2dc (diff)
downloadjquery-495ecb70b2b097e7d4a1ffe46d44562210cdc051.tar.gz
jquery-495ecb70b2b097e7d4a1ffe46d44562210cdc051.zip
Fix for #907
-rw-r--r--build/test/data/dashboard.xml4
-rw-r--r--src/jquery/coreTest.js8
-rw-r--r--src/jquery/jquery.js12
3 files changed, 19 insertions, 5 deletions
diff --git a/build/test/data/dashboard.xml b/build/test/data/dashboard.xml
index d954f27af..d2305593d 100644
--- a/build/test/data/dashboard.xml
+++ b/build/test/data/dashboard.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<dashboard>
- <locations>
- <location>
+ <locations class="foo">
+ <location for="bar">
<infowindowtab>
<tab title="Location"><![CDATA[blabla]]></tab>
<tab title="Users"><![CDATA[blublu]]></tab>
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index a75331558..f24a10b3b 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -74,7 +74,7 @@ test("index(Object)", function() {
});
test("attr(String)", function() {
- expect(13);
+ expect(15);
ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
@@ -88,6 +88,12 @@ test("attr(String)", function() {
ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
ok( $('#anchor2').attr('href') == "#2", 'Check for non-absolute href (an anchor)' );
+ stop();
+ $.get("data/dashboard.xml", function(xml) {
+ ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );
+ ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );
+ start();
+ });
});
test("attr(String, Function)", function() {
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 004d6341a..e58f895df 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -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 {