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
Basic info:
Minimal reproduction case
How does similar code behave in browsers?
getComputedStyledoes not return pseudo classes by defaultjsbin