Make sure that non-px values aren't manipulated before input to height/width.

This commit is contained in:
John Resig 2010-09-21 17:12:42 -04:00
parent 1ac3713e7f
commit e3463946e1
2 changed files with 5 additions and 2 deletions

View File

@ -155,7 +155,7 @@ jQuery.each(["height", "width"], function( i, name ) {
},
set: function( elem, value ) {
if ( value !== "" ) {
if ( rnumpx.test( value ) ) {
// ignore negative width and height values #1599
value = parseFloat(value);

View File

@ -1,7 +1,7 @@
module("css");
test("css(String|Hash)", function() {
expect(28);
expect(29);
equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');
@ -44,6 +44,9 @@ test("css(String|Hash)", function() {
equals( parseInt(child.css("fontSize")), 16, "Verify fontSize px set." );
equals( parseInt(child.css("font-size")), 16, "Verify fontSize px set." );
child.css("height", "100%");
equals( child[0].style.height, "100%", "Make sure the height is being set correctly." );
child.attr("class", "em");
equals( parseInt(child.css("fontSize")), 32, "Verify fontSize em set." );