Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#14849 closed bug (wontfix)

Improve outerWidth / outerHeight on hidden elements

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: css Version: 1.11.0-rc1
Keywords: Cc:
Blocked by: Blocking:


jQuery has a hack for returning width/height of hidden elements by briefly toggling their display:


This doesn't work when !important is used, which is pretty common for .hidden helper classes that need to have their style applied irrespective of the CSS specificity of later rules.

My brief exploration suggest that !important is respected on inline styles (for Chrome at least). So you might want to look into whether adding !important for each declaration in the line of code above makes the implementation work in more cases.

Change History (4)

comment:1 Changed 9 years ago by timmywil

Component: unfiledcss
Resolution: wontfix
Status: newclosed

I think we want to steer clear of using !important anywhere in jQuery. The display hack is there to help provide useful values as often as possible, but it is not full-proof.

comment:2 Changed 9 years ago by nicolas

I think we want to steer clear of using !important anywhere in jQuery.

Why though? We hit this bug at Twitter. The implementation should be more robust, especially given that every significant "CSS framework" uses "!important" in their helper classes for hiding elements. Either don't do any trickery at all, or make it solid.

comment:3 Changed 9 years ago by dmethvin

If we could go back to "no trickery at all" we'd do that. All we can do now is draw the line at the trickery we've already implemented since we know it is a really bad idea both from a logic and performance standpoint. There is no end to the amount of trickery we'd need to do in order to figure out how a hidden element will look once it's displayed.

comment:4 Changed 9 years ago by dmethvin

See also #14685

Note: See TracTickets for help on using tickets.