Skip to content

Elements font-weight returned by getComputedStyle is not normalized #2238

Description

@rijenkii

Describe the bug
In a browser window.getComputedStyle returns some kind of a normalized style, e.g. if a div has font-weight: bold on it, getComputedStyle will return font-weight: 700.

To Reproduce
Run the following script:

import { Window } from "happy-dom";
const window = new Window();
const { document } = window;

const div = document.createElement("div");
div.style.fontWeight = "bold";
document.body.appendChild(div);

console.log(window.getComputedStyle(div).fontWeight);

It will print bold.

Expected behavior
Running the script in a browser (without the first three lines) results in 700 being printed to console.

Device and details:

  • OS: Linux 7.1.3-200.fc44.x86_64
  • Node version: v20.20.0
  • Package version: 20.10.6

Additional context
Similar issues: #1829

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions