如何获取Html节点实例/对象的
HTMLElement
类的所有方法名称列表$ node
Welcome to Node.js v21.6.0.
Type ".help" for more information.
> const { JSDOM } = require('jsdom'); const dom = new JSDOM('<!DOCTYPE html>')
undefined
> (node:7523) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> const document = dom.window.document
> nodeObj = document.createElement('div');
HTMLDivElement {}
>
> const methodNames = [];
undefined
> for (const key in nodeObj) {
if (typeof nodeObj[key] === 'function' && nodeObj.hasOwnProperty(key)) {
methodNames.push(key);
}
}
undefined
>
> console.log(methodNames);
[]
仅给出空数组
请帮助实现它更实际、正确的方法