-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
getComputedStyle
cache issue with v21.1.0
#3502
Comments
EDIT: I updated the original repro with Vue code (as the one without was not reproducing the issue) |
Closing per this comment in the issue template:
Let us know if you can follow these instructions, and then we can reopen and investigate the issue. |
@domenic Sorry about that, I updated the repro 👍 |
`attachTo` can be removed when jsdom/jsdom#3502 is fixed With jsdom v21.1, `getComputedStyle` is cached and not updated for elements not the DOM so some our tests fail (because the elements are checked a first time)
`attachTo` can be removed when jsdom/jsdom#3502 is fixed With jsdom v21.1, `getComputedStyle` is cached and not updated for elements not in the DOM so some our tests fail (because the elements are checked a first time)
`attachTo` can be removed when jsdom/jsdom#3502 is fixed With jsdom v21.1, `getComputedStyle` is cached and not updated for elements not in the DOM so some our tests fail (because the elements are checked a first time)
`attachTo` can be removed when jsdom/jsdom#3502 is fixed With jsdom v21.1, `getComputedStyle` is cached and not updated for elements not in the DOM so some our tests fail (because the elements are checked a first time)
Thanks for updating the repro, and sorry for the delay as I was on vacation. It looks to me like jsdom's behavior now correctly matches browsers: https://jsbin.com/covuqujaru/edit?html,console . Do you agree? If so, then I think this is working as intended, and you got a bugfix when you upgraded jsdom. |
Thanks for taking a look @domenic If that now matches the browser's behavior then I can't argue For a bit of context: this triggers regressions in the Vue ecosystem as the official testing lib does not attach tested components to the DOM by default. We'll probably have to change that. Thanks for your time |
This change updates the documentation to reflect that `isVisible()` will only work correctly [when attached to the DOM][1] because of an upstream [`jsdom` issue][2]. [1]: vuejs#2016 [2]: jsdom/jsdom#3502
This change updates the documentation to reflect that `isVisible()` will only work correctly [when attached to the DOM][1] because of an upstream [`jsdom` issue][2]. [1]: #2016 [2]: jsdom/jsdom#3502
Basic info:
Minimal reproduction case
IIUC jsdom v21.1 introduced caching for getComputedStyle, triggering test failures when we upgraded to it.
Please take a look at the following test.
It accesses the computed style of an element created with
document.createElement
but never inserts it in the DOM, then updates it, then accesses the computed style again.Then the test fails because the computed style is cached and we get the same one as the first access.
Removing the first access makes the test succeed (or downgrading to v21.0).
See the repro online on the following stackblitz if you prefer
https://stackblitz.com/edit/vitest-dev-vitest-whharw?file=test/basic.test.ts
The test succeeds if:
The text was updated successfully, but these errors were encountered: