Skip to main content

Bug Tracker

Side navigation

#10855 closed bug (duplicate)

Opened November 22, 2011 11:27AM UTC

Closed November 22, 2011 02:17PM UTC

Last modified March 14, 2012 10:38AM UTC

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

Reported by: lazahu@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:
Description

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/

Attachments (0)
Change History (3)

Changed November 22, 2011 02:17PM UTC by dmethvin comment:1

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.

Changed November 22, 2011 02:17PM UTC by dmethvin comment:2

Duplicate of #7058.

Changed November 23, 2011 11:01AM UTC by lazahu@gmail.com comment:3

@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