Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Patch for jQuery 1.6 compatibility #167

Merged
merged 2 commits into from

4 participants

@kcivey

Updated for compatibility with jQuery 1.6. Boolean attributes need to be handled differently -- eg, .is(":checked") instead of .attr("checked") (which may return ""). The .is(":checked") syntax should also be compatible with earlier versions.

@kcivey kcivey Updated for compatibility with jQuery 1.6. Boolean attributes need to…
… be handled differently -- eg, .is(":checked") instead of .attr("checked") (which may return "").
3028512
@marioestrada

I don't think jquery supports is(":multiple"), I would use .prop("multiple") instead.

@kcivey
@marioestrada

Maybe: jQuery.prop ? jQuery.prop('multiple') : jQuery.attr('multiple')

@kcivey

Actually in this case elem.attr("multiple") != true can be changed to just !this.multiple because the DOM element is in this.

@kcivey

Looks like jQuery 1.6.1 has made .attr() on boolean attributes be backward-compatible with pre-1.6 versions, so this patch shouldn't be needed.

@samkelleher

Using jQuery v1.6.4, uniform.js didn't work with checkboxes as it was using $(elem).attr("checked") to determine checked status, changing it to $(elem).prop("checked") works correctly. The symtom the user sees is clicking the checkbox doesn't do anything. Whilst I read that jQuery made the attr/prop change more backwards compaible, it wasn't everything.

So I still think this change should be put in, maybe as marioestrada provided?

@fidian
Collaborator

The v1.8 branch already had this merged in. Updating master with your pull request. Checkboxes and jQuery 1.6 now are happier. Thanks for the code!

@fidian fidian merged commit 9db972b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 4, 2011
  1. @kcivey

    Updated for compatibility with jQuery 1.6. Boolean attributes need to…

    kcivey authored
    … be handled differently -- eg, .is(":checked") instead of .attr("checked") (which may return "").
  2. @kcivey
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 9 deletions.
  1. +9 −9 jquery.uniform.js
View
18 jquery.uniform.js
@@ -214,7 +214,7 @@ Enjoy!
});
//handle disabled state
- if($(elem).attr("disabled")){
+ if($(elem).is(":disabled")){
//box is checked by default, check our box
divTag.addClass(options.disabledClass);
}
@@ -260,7 +260,7 @@ Enjoy!
divTag.removeClass(options.focusClass);
},
"click.uniform touchend.uniform": function(){
- if(!$(elem).attr("checked")){
+ if(!$(elem).is(":checked")){
//box was just unchecked, uncheck span
spanTag.removeClass(options.checkedClass);
}else{
@@ -284,13 +284,13 @@ Enjoy!
});
//handle defaults
- if($(elem).attr("checked")){
+ if($(elem).is(":checked")){
//box is checked by default, check our box
spanTag.addClass(options.checkedClass);
}
//handle disabled state
- if($(elem).attr("disabled")){
+ if($(elem).is(":disabled")){
//box is checked by default, check our box
divTag.addClass(options.disabledClass);
}
@@ -333,7 +333,7 @@ Enjoy!
divTag.removeClass(options.focusClass);
},
"click.uniform touchend.uniform": function(){
- if(!$(elem).attr("checked")){
+ if(!$(elem).is(":checked")){
//box was just unchecked, uncheck span
spanTag.removeClass(options.checkedClass);
}else{
@@ -361,12 +361,12 @@ Enjoy!
});
//handle defaults
- if($(elem).attr("checked")){
+ if($(elem).is(":checked")){
//box is checked by default, check span
spanTag.addClass(options.checkedClass);
}
//handle disabled state
- if($(elem).attr("disabled")){
+ if($(elem).is(":disabled")){
//box is checked by default, check our box
divTag.addClass(options.disabledClass);
}
@@ -470,7 +470,7 @@ Enjoy!
}
//handle defaults
- if($el.attr("disabled")){
+ if($el.is(":disabled")){
//box is checked by default, check our box
divTag.addClass(options.disabledClass);
}
@@ -643,7 +643,7 @@ Enjoy!
if(elem.is("select")){
//element is a select
- if(elem.attr("multiple") != true){
+ if(!this.multiple){
//element is not a multi-select
if(elem.attr("size") == undefined || elem.attr("size") <= 1){
doSelect(elem);
Something went wrong with that request. Please try again.