Bug Tracker

Ticket #14792 (closed bug: fixed)

Opened 10 months ago

Last modified 10 months ago

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:
Blocking: Blocked by:

Description

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

comment:1 Changed 10 months ago by dmethvin

  • Priority changed from undecided to low
  • Component changed from unfiled to css

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.

 http://www.w3.org/TR/css-fonts-3/#font-weight-prop

comment:2 Changed 10 months ago by dmethvin

  • Status changed from new to open
  • Milestone changed from None to 1.11.1/2.1.1

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

comment:3 Changed 10 months ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned

comment:4 Changed 10 months ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

CSS: Return values should be numbers

Fixes #14792

Changeset: f4b37d89820535d6c7503925aa8872645681a865

comment:5 Changed 10 months ago by anonymous

Thanks :)

Note: See TracTickets for help on using tickets.