#How can `getOwnPropertyDescriptor(window, 'HTMLElement')` exist when `getOwnPropertyNames` does not?

5 messages · Page 1 of 1 (latest)

lean yoke
#

Here is my question in detail: https://stackoverflow.com/questions/78085257/why-doesnt-jsdoms-object-getownpropertynameswindow-include-dom-objects

I have a scenario where Object.getOwnPropertyDescriptor(window, 'HTMLElement') returns a property descriptor but HTMLElement does not exist in Object.getOwnPropertyNames(window). I don't understand how this is possible. Can someone explain that to me?

Here's the output of Object.getOwnPropertyDescriptor(window, 'HTMLElement'):

{
  value: [class HTMLElement extends Element],
  writable: true,
  enumerable: false,
  configurable: true
}

FWIW, I am running this in a node environment with JSDOM.

lean yoke
#

!helper I have a scenario where Object.getOwnPropertyDescriptor(window, 'HTMLElement') returns a property descriptor but HTMLElement does not exist in Object.getOwnPropertyNames(window). I don't understand how this is possible. Can someone explain that to me?

cold grail
#

FWIW, can't reproduce; I tried running this:

const JSDOM = require("jsdom").JSDOM;
Object.getOwnPropertyNames(new JSDOM("").window).includes('HTMLElement')

and it outputted true as I'd expect.

#

I think this repo has jsdom 22.1 if you want to dig into whether it's a version issue.

lean yoke