Skip to content

getComputedStyle performance #3234

@just-boris

Description

@just-boris

Basic info:

  • Node.js version: n/a
  • jsdom version: any version is affected

Minimal reproduction case

const div = document.createElement('div');
document.body.appendChild(div);

console.time('getComputedStyle');
getComputedStyle(div);
console.timeEnd('getComputedStyle');

How does similar code behave in browsers?

This code take a fraction of millisecond in real browsers, but 100 times slower in JSDOM. There are some libraries in the ecosystem heavily relying on this API and the tests become slow because of that.

Related issues:

testing-library/dom-testing-library#820
theKashey/react-focus-lock#151

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions