]> source.dussan.org Git - jquery.git/commitdiff
#5413 - Much shorter solution for getting width/height in ie6
authortimmywil <tim.willison@thisismedium.com>
Sat, 2 Apr 2011 01:38:54 +0000 (21:38 -0400)
committertimmywil <tim.willison@thisismedium.com>
Sun, 3 Apr 2011 23:13:41 +0000 (19:13 -0400)
- #8255 Added support for the list attribute in browsers that support it (it is automatically readonly, but can be set if using getAttribute( name, 2)

src/attributes.js
test/index.html
test/unit/attributes.js

index f29c340a355e7efef3c0569b1becc525a2a90fbd..5afcffce3d7f230990ed248eed3ed8c153814895 100644 (file)
@@ -446,20 +446,6 @@ if ( !jQuery.support.getSetAttribute ) {
                        return value;
                }
        };
-
-       // Retrieving the width/height attributes on an
-       // element with display: none returns 0 in ie6/7 (#5413)
-       jQuery.each([ "width", "height" ], function( i, name ) {
-               jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
-                       get: function( elem ) {
-                               var ret;
-                               jQuery.swap( elem, { visibility: "hidden", display: "block" }, function() {
-                                       ret = elem.getAttribute( name );
-                               });
-                               return ret;
-                       }
-               });
-       });
 }
 
 // Remove certain attrs if set to false
@@ -481,7 +467,7 @@ jQuery.each([ "selected", "checked", "readonly", "disabled" ], function( i, name
 
 // Some attributes require a special call on IE
 if ( !jQuery.support.hrefNormalized ) {
-       jQuery.each([ "href", "src", "style" ], function( i, name ) {
+       jQuery.each([ "href", "src", "style", "width", "height", "list" ], function( i, name ) {
                jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
                        get: function( elem ) {
                                return elem.getAttribute( name, 2 );
index c7c2ae55dc0c7b89d272bea935a14026517bd17c..a106550898d860127d66ba585599370066e4f37e 100644 (file)
@@ -203,6 +203,10 @@ Z</textarea>
                        <select name="D4" disabled="disabled">
                                <option selected="selected" value="NO">NO</option>
                        </select>
+                       <input id="list-test" type="text" />
+                       <datalist id="datalist">
+                               <option value="option"></option>
+                       </datalist>
                </form>
                <div id="moretests">
                        <form>
index a73b51fc54bdb1d1738c4bc3c33cf41fdebad7e6..ad051649fa50d8455243b1401d5169395cea95d5 100644 (file)
@@ -75,7 +75,7 @@ test("prop(String, Object)", function() {
 });
 
 test("attr(String)", function() {
-       expect(30);
+       expect(31);
 
        equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' );
        equals( jQuery('#radio1').attr('type'), "radio", 'Check for type attribute' );
@@ -108,6 +108,10 @@ test("attr(String)", function() {
        jQuery('<a/>').attr({ 'id': 'tAnchor5', 'href': '#5' }).appendTo('#main');
        equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );
 
+       // list attribute is readonly by default in browsers that support it
+       jQuery("#list-test").attr("list", "datalist");
+       equals( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" );
+
        // Related to [5574] and [5683]
        var body = document.body, $body = jQuery(body);