Skip to content
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

Element's checkVisibility method not implemented in JSDOM #3695

Open
WikKam opened this issue Mar 21, 2024 · 0 comments
Open

Element's checkVisibility method not implemented in JSDOM #3695

WikKam opened this issue Mar 21, 2024 · 0 comments

Comments

@WikKam
Copy link

WikKam commented Mar 21, 2024

Basic info:

  • Node.js version: v20.11.1
  • jsdom version: 24.0.0

Minimal reproduction case

https://stackblitz.com/edit/stackblitz-starters-m39mou?file=index.js,package-lock.json

Hi! currently trying to use "checkVisibility" function results in a exception:

import { JSDOM } from "jsdom";
const dom = new JSDOM(`<!DOCTYPE html><p id="test">Hello world</p>`);

const element = dom.window.document.getElementById("test");

console.log(element.checkVisibility())
file:///Users/wkaminski/Desktop/jsdom-test/app.js:6
console.log(element.checkVisibility())
                    ^

TypeError: element.checkVisibility is not a function
    at file:///Users/wkaminski/Desktop/jsdom-test/app.js:6:21
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Not sure what should be the behaviour of this method (and if its even possible to implement it in jsdom), but its annoying while testing browser code that rely on this function. I would appreciate some guidance on how to mock this method if adding it to JSDOM is not possible.

How does similar code behave in browsers?

Correctly returns if the element is visible. This method is documented here: https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant