Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14792 closed bug (fixed)

Inconsistent .css('font-weight') return values

Reported by: whatthejeff Owned by: dmethvin
Priority: low Milestone: 1.11.1/2.1.1
Component: css Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:


The origin of this issue is: https://github.com/jquery/jquery/commit/b9b87d53c681a8337cdbdbe81f8f4e577e5ec277

In WebKit/Blink browsers, window.getComputedStyle returns the following for font-weight:

  • "100"
  • "200"
  • "300"
  • "normal"
  • "500"
  • "600"
  • "bold"
  • "800"
  • "900"

In WebKit/Blink browsers, .css() returns the following for font-weight:

  • "100"
  • "200"
  • "300"
  • 400
  • "500"
  • "600"
  • "bold"
  • "800"
  • "900"

It's inconsistent that the return type for normal/400 is a Number when the return type for all other values is a String.

It's also a little confusing that "normal" is converted to a numeric value, but "bold" is not.

In other browsers, both window.getComputedStyle and .css() return numeric strings for all values. This seems like the most desirable behavior.

Change History (5)

comment:1 Changed 10 years ago by dmethvin

Component: unfiledcss
Priority: undecidedlow

Seems that once again we're halfway in to fixing a messy rare edge case, one that probably matters for 1% of all users since it's survived this long. The spec does say that "bold" ==> 700 though so we could attempt to fix this.


comment:2 Changed 10 years ago by dmethvin

Milestone: None1.11.1/2.1.1
Status: newopen

Let's fix "400" but not "bold".

comment:3 Changed 10 years ago by dmethvin

Owner: set to dmethvin
Status: openassigned

comment:4 Changed 10 years ago by Dave Methvin

Resolution: fixed
Status: assignedclosed

CSS: Return values should be numbers

Fixes #14792

Changeset: f4b37d89820535d6c7503925aa8872645681a865

comment:5 Changed 10 years ago by anonymous

Thanks :)

Note: See TracTickets for help on using tickets.