<?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
});\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
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
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();
},
attr: function(elem, name, value){
- var fix = {
+ var fix = jQuery.isXMLDoc(elem) ? {} : {
"for": "htmlFor",
"class": "className",
"float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
// 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] ) {
// 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 {