Closed odanado closed 3 months ago
Describe the bug The value of getPropertyValue is wrong when using style attributes and custom properties.
getPropertyValue
import { Window } from "happy-dom"; const window = new Window({ url: "https://localhost:8080" }); const div = window.document.createElement("div"); div.setAttribute("style", "--my-color1: pink;"); const style = window.document.createElement("style"); style.textContent = ` div { border-color: var(--my-color1); } `; window.document.head.appendChild(style); window.document.body.appendChild(div); // OK: expected: pink, actual: "" (empty string) console.log(window.getComputedStyle(div).getPropertyValue("border-color"));
To Reproduce Steps to reproduce the behavior:
git clone https://github.com/odan-sandbox/happy-dom-getComputedStyle-with-css-variables-sandbox
npm ci
node src/repro-non-fallback.js
Expected behavior --my-color1 is defined, so the background-color should be pink.
--my-color1
background-color
Device:
Thank you for reporting @odanado! :slightly_smiling_face:
There is a fix in now: https://github.com/capricorn86/happy-dom/releases/tag/v14.3.10
Thank you!
Describe the bug The value of
getPropertyValue
is wrong when using style attributes and custom properties.To Reproduce Steps to reproduce the behavior:
git clone https://github.com/odan-sandbox/happy-dom-getComputedStyle-with-css-variables-sandbox
npm ci
node src/repro-non-fallback.js
Expected behavior
--my-color1
is defined, so thebackground-color
should be pink.Device: