Skip to content

getComputedStyle returns psuedo-classes by default #3607

@blake-discover

Description

@blake-discover

Basic info:

  • Node.js version: v18.8.0
  • jsdom version: ^22.1.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const html = `<!DOCTYPE html>
<html lang="en">
  <head>
    <style>
      button { background-color: rgb(127, 255, 212); }
      button:hover { background-color: rgb(255, 228, 196); }
    </style>
  </head>
  <body>
    <button>Submit</button>
  </body>
</html>
`;

const { window } = new JSDOM(html);

const button = window.document.querySelector("button");
const styles = window.getComputedStyle(button);
// This returns `rgb(255, 228, 196)`
console.log(styles.getPropertyValue("background-color"));

How does similar code behave in browsers?

getComputedStyle does not return pseudo classes by default

jsbin

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions