Skip to content
Permalink
Browse files

Full test suite now passes in all browsers! There are probably some t…

…weaks we can make to shorten and simplify.

- removeAttr now only uses setAttribute if camelCase setAttribute is not supported

  + Might want to rename jQuery.support.getSetAttribute

- tabIndex is a special case now for hooks where undefined should be returned.

  + Should we be checking if hooks returns undefined?  undefined might be the desired return value in future hooks.
    As of now, tabIndex is the only one that needs it, but the test suite will still pass if we don't check if hooks are undefined.
  • Loading branch information
timmywil
timmywil committed Mar 13, 2011
1 parent 8cd30c6 commit 9f88fa9165e73b879d0c955fdf81fdd681d2d192
Showing with 11 additions and 8 deletions.
  1. +9 −7 src/attributes.js
  2. +2 −1 src/support.js
@@ -313,7 +313,7 @@ jQuery.extend({

} else {

if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem )) !== undefined ) {
if ( hooks && "get" in hooks && notxml && ((ret = hooks.get( elem )) !== undefined || name === "tabIndex") ) {
return ret;

} else {
@@ -325,11 +325,13 @@ jQuery.extend({
}
},

// removeAttribute returns boolean in IE6/7
// set property to null in that case
// removeAttribute returns boolean in IE
// set property to null if getSetAttribute not supported (IE6-7)
removeAttr: function( elem, name ) {
if ( typeof elem.removeAttribute( name ) === "boolean" ) {
elem.setAttribute( name, null );
name = jQuery.attrFix[ name ] || name;
if ( typeof elem.removeAttribute( name ) === "boolean" && !jQuery.support.getSetAttribute ) {
// Setting className to null sets a class of "null"
name === "className" ? elem.className = "" : elem.setAttribute( name, null );
}
},

@@ -399,7 +401,7 @@ if ( !jQuery.support.getSetAttribute ) {
frameborder: "frameBorder"
});

// Action attribute in ie6/7 returns form object
// Action attribute in ie6/7 returns form objects
jQuery.attrHooks.action = jQuery.extend( jQuery.attrHooks.action, {
get: function( elem ) {
return elem.nodeName === "FORM" ? elem.getAttributeNode("action").nodeValue : elem.getAttribute("action");
@@ -414,7 +416,7 @@ if ( !jQuery.support.getSetAttribute ) {
// Remove certain attrs if set to false
jQuery.each([ "selected", "checked", "readonly", "disabled" ], function( i, name ) {
name = jQuery.attrFix[ name ] || name;

jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
set: function( elem, value ) {
if ( !value ) { // '', undefined, false, null will remove attr
@@ -58,7 +58,8 @@
// Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
optSelected: opt.selected,


// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
getSetAttribute: div.className !== "t",

// Will be defined later

0 comments on commit 9f88fa9

Please sign in to comment.
You can’t perform that action at this time.