Skip to main content

Bug Tracker

Side navigation

#7486 closed bug (wontfix)

Opened November 12, 2010 11:43AM UTC

Closed June 15, 2011 12:55AM UTC

Last modified October 15, 2012 08:17PM UTC

css('height')

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: 1.next
Component: css Version: 1.4.4
Keywords: regression Cc:
Blocked by: Blocking:
Description

Until now "$('#x').css('height')" returned 'auto', if no css-height was defined.

Now it returns always the height, e.g. '35 px';

Attachments (0)
Change History (19)

Changed November 17, 2010 03:04AM UTC by addyosmani comment:1

owner: → anonymous
status: newpending

Please supply a valid test case reproducing what you're trying to achieve, ideally on jsFiddle.net. This will allow us to investigate the problem described more thoroughly.

Changed November 22, 2010 08:01AM UTC by anonymous comment:2

status: pendingnew

<p id="test">blabla</p>

<script>

alert( $('#test').css('height') );

</script>

Until jQuery 1.4.3: "auto"

jQuery 1.4.4: e.g. "22px"

Changed November 22, 2010 01:54PM UTC by danheberden comment:3

Probably related to fixes for #7225 http://bugs.jquery.com/ticket/7225

Changed November 22, 2010 01:56PM UTC by danheberden comment:4

Can you please provide a live demo via jsfiddle.net? That helps a ton in looking into the problem :)

Changed November 22, 2010 03:39PM UTC by snover comment:5

component: unfiledcss
keywords: → regression
milestone: 1.51.4.5
status: newopen

This was noted on the commit notes for [53396b879bd29c090824da182e3cf69158829f82], though for whatever reason the ramifications of that change did not make it into the release notes. Now that there is an official report of this breaking someone’s stuff, I’m going to mark this and maybe we can revert this (though it is unlikely that the behaviour will change).

Changed November 23, 2010 12:30PM UTC by anonymous comment:6

Hello,

Yes, it broke my app, but it was easy to fix.

Maybe you should update the release notes and the API-docs.

Thanks

Marcus

Changed November 23, 2010 05:24PM UTC by jitter comment:7

keywords: regressionregression needsdocs

Changed December 22, 2010 10:04PM UTC by Matt Palmerlee <mpalmerlee@gmail.com> comment:8

I have this same problem, it seems that this problem started in jQuery 1.4.3, not 1.4.4

Please see my jsFiddle test case here:

http://jsfiddle.net/mpalmerlee/DnRUG/

In 1.4.2 css("height") returns "auto" and in 1.4.3 and 1.4.4 it returns 0px in both IE and FF

Changed December 22, 2010 10:15PM UTC by Matt Palmerlee <mpalmerlee@gmail.com> comment:9

In addition to this not working with height:auto, My test case doesn't work with height:100% in the div either.

Here is a forked jsFiddle test case with height:100%

http://jsfiddle.net/mpalmerlee/rrMTZ/

This also works as expected in jQuery 1.4.2

Changed December 22, 2010 10:27PM UTC by mpalmerlee comment:10

_comment0: Correction to my last commend, here is the jsFiddle for the height 100% version: \ http://jsfiddle.net/mpalmerlee/rrMTZ/1/ \ \ This breaks my app and is not as easy to fix for me as it was for anonymous, If I put in Height:16px for the div, my replaced input box looks ok in FF, but is too small in IE (IE wants input boxes ~ 20px high) \ \ And if I specify Height:16px Firefox looks fine, but the input box is smaller in IE so this method doesn't work for me as well: \ \ http://jsfiddle.net/mpalmerlee/rrMTZ/2/1293056838847743

Correction to my last comment, here is the jsFiddle for the height 100% version:

http://jsfiddle.net/mpalmerlee/rrMTZ/1/

This breaks my app and is not as easy to fix for me as it was for anonymous, If I put in Height:16px for the div, my replaced input box looks ok in FF, but is too small in IE (IE wants input boxes ~ 20px high)

And if I specify Height:16px Firefox looks fine, but the input box is smaller in IE so this method doesn't work for me as well:

http://jsfiddle.net/mpalmerlee/rrMTZ/2/

Changed December 30, 2010 05:48AM UTC by snover comment:11

mpalmerlee, investigate the box-sizing CSS property.

Changed January 04, 2011 07:47PM UTC by mpalmerlee comment:12

snover,

Thanks for the pointer to the box-sizing CSS property, I was having trouble reproducing my application's behavior on jsFiddle in IE (the form elements looked fine when replaced when specifying an exact size like 16px). I finally realized that my application uses IE Quirks mode which I'm not able to simulate using jsFiddle, and it seems that the box-sizing properties don't work with IE quirks mode.

I've uploaded a test page to a server so that you can see the issue I have in IE:

http://ea1.conversive.com/jsFiddleJQueryHeightBug.html

Since it is not feasible to change my application from quirks mode because it would mean a ton of layout refactoring, and since I can't find another work around, I won't be able to upgrade from jQuery 1.4.2 to 1.4.4 until css('height') works how it does in 1.4.2 (height:auto or height:100% elements return auto and 100% respectively).

Thanks,

-Matt

Changed May 02, 2011 01:41AM UTC by timmywil comment:13

#8741 is a duplicate of this ticket.

Changed June 08, 2011 01:57AM UTC by timmywil comment:14

priority: undecidedlow

jQuery.style gets uncomputed and looks like jQuery.css always gets computed. The question I think is, what should jQuery.fn.css return and is it specific to certain properties?

Changed June 15, 2011 12:29AM UTC by mikesherov comment:15

Timmy, for what it's worth, isn't this exactly what cssHooks are for? Theoretically, a user could easily a cssHook to get the old behavior back:

Something like this... (untested)

jQuery.each(["height", "width"], function( i, name ) {
	jQuery.cssHooks[ name ] = {
		get: function( elem, computed, extra ) {
			return jQuery.style(elem, name);
		},

		set: function( elem, value ) {
						return jQuery.style(elem, name, value);
		}
	};
});

Changed June 15, 2011 12:55AM UTC by timmywil comment:16

resolution: → wontfix
status: openclosed

I think we can safely say that this won't change, but a note on the docs would probably be good to indicate the change in behavior.

Changed July 13, 2011 12:08AM UTC by anonymous comment:17

I need the ability to reset an element to 'height: auto' in some cases, but only if it was 'height: auto' or didn't have a height set to begin with.

jQuery.style still doesn't work for this. There does not appear to be a way to get information about styles that are not applied inline. In addition, I don't think that saying that this is "easily" achievable with an undocumented function is not really the best solution anyway...

http://jsfiddle.net/CbcUR/5/

Changed July 13, 2011 12:24AM UTC by rwaldron comment:18

@anonymous - see above, this can be resolved with a custom cssHook

Changed October 15, 2012 08:17PM UTC by mikesherov comment:19

keywords: regression needsdocsregression