mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix for #907
This commit is contained in:
parent
2c99c18652
commit
495ecb70b2
@ -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>
|
||||
|
8
src/jquery/coreTest.js
vendored
8
src/jquery/coreTest.js
vendored
@ -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() {
|
||||
|
12
src/jquery/jquery.js
vendored
12
src/jquery/jquery.js
vendored
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user