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
});
test("attr(String)", function() {
- expect(28);
+ expect(30);
equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' );
equals( jQuery('#radio1').attr('type'), "radio", 'Check for type attribute' );
optgroup.appendChild( option );
select.appendChild( optgroup );
- ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
- ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
-
+ 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." );
+
// Check for style support
ok( !!~jQuery('#dl').attr('style').indexOf('absolute'), 'Check style attribute getter' );
ok( !!~jQuery('#foo').attr('style', 'position:absolute;').attr('style').indexOf('absolute'), 'Check style setter' );
+
+ ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
+ ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
});
if ( !isLocal ) {