-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hasStyle does not work for CSS variables #1272
Comments
I came upon this feature request while looking for the same functionality. If this is something wanted in the proposed form I can take a stab at implementing this and opening a PR. |
We would love to see support added for this. |
3.1.0 has been released https://www.npmjs.com/package/qunit-dom/v/3.1.0 See if it works for you |
Closing this since we've released the 3.1.0 version, if the issue is still present, feel free to reopen. |
The bug
Consider this element:
The following assertion does not work:
Since
hasStyle
is implemented withgetComputedStyle
andgetComputedStyle
returns styles after computations are resolved, variable styles are not present on theCSSDeclaration
object.In order to get the variable styles from an element you must use
element.style.getPropertyValue('--my-var')
.Motivation to have this behavior
An emerging pattern now that CSS variables have broad adoption is to dynamically set variables in JS/HTML and then read the variables in static CSS.
For instance:
Proposed solution
I think the API for
hasStyle
can remain unchanged. The keys for theexpected
object can be divided into variables (start with--
) and declarations. Then the two sets can be iterated over usingstyle.getPropertyValue
andgetComputedStyle
respectively.The text was updated successfully, but these errors were encountered: