Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10855 closed bug (duplicate)

Make sure the css("borderTopWidth") returns numeric value in IE8 if no border (width) was specified.

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:


Using the el.css("borderTopWidth") query now returns "medium" on IE8 (and below?) if there was no border width specified. In order to safely use this function cross-browser you might need to return "0" or "0px" as other browsers do, otherwise it might break javascript.

Here's a jsFiddle example: http://jsfiddle.net/RzK5t/2/

Change History (3)

comment:1 Changed 11 years ago by dmethvin

Resolution: duplicate
Status: newclosed

You said "now" but this behavior has been consistent since the beginning of jQuery, I had to deal with it a few times over the years. The problem is that IE doesn't give you the computed style. You need to look at the borderTopStyle and see if it is "none", then use 0 if it is. Most likely you're in a loop grabbing all four sides, so just add another check for border*Style.

I had a css hook fix for this a long time back but it took way too much code given how cornery a case it is.

comment:2 Changed 11 years ago by dmethvin

Duplicate of #7058.

comment:3 Changed 11 years ago by [email protected]

@dmethvin: Thanks a lot for explaining it.

Anyway, I still consider it is a bug, as in other areas jQuery delivers consistent results cross-browser way - that's why so many of us use it - and returning "medium" as border-top-width is the least expected thing, and can mess up numeric calculations. I think it's high time to let developers ignore all old browser's odd behaviors. I believe replacing "medium" with "0px" in case the "border-style" definition is missing won't screw up any older code, as those who's already stumbled upon this, already made this replacement by themselves.

Thanks, Laza

Note: See TracTickets for help on using tickets.