aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortimmywil <tim.willison@thisismedium.com>2011-05-12 19:42:53 -0400
committertimmywil <tim.willison@thisismedium.com>2011-05-13 13:33:43 -0400
commit6f676e692d48b4f979ba1dfc5d10f3f16954b381 (patch)
tree70a0a91fe8091440d35fc85ba77e74d51dc7193c
parentec829431feed29b393b1c22ca97e8af49f47e228 (diff)
downloadjquery-6f676e692d48b4f979ba1dfc5d10f3f16954b381.tar.gz
jquery-6f676e692d48b4f979ba1dfc5d10f3f16954b381.zip
Use prop to retrieve boolean properties (so the selected hook will be used)
-rw-r--r--src/attributes.js2
-rw-r--r--test/unit/attributes.js8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/attributes.js b/src/attributes.js
index bc26d735a..f1d2944e2 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -466,7 +466,7 @@ jQuery.extend({
boolHook = {
get: function( elem, name ) {
// Align boolean attributes with corresponding properties
- return elem[ jQuery.propFix[ name ] || name ] ?
+ return jQuery.prop( elem, name ) ?
name.toLowerCase() :
undefined;
},
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index d2d43475d..efeb46e48 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -40,7 +40,7 @@ test("jQuery.attrFix/jQuery.propFix integrity test", function() {
});
test("attr(String)", function() {
- expect(37);
+ expect(38);
equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
@@ -92,6 +92,12 @@ test("attr(String)", function() {
body.removeAttribute("foo"); // Cleanup
+ var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
+ optgroup.appendChild( option );
+ select.appendChild( optgroup );
+
+ equal( jQuery( option ).attr("selected"), "selected", "Make sure that a single option is selected, even when in an optgroup." );
+
var $img = jQuery("<img style='display:none' width='215' height='53' src='http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif'/>").appendTo("body");
equals( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." );
equals( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." );