列出HTMLElement类(或Html节点对象)的所有方法名称

问题描述 投票:0回答:0

如何获取Html节点实例/对象的

HTMLElement
类的所有方法名称列表
在 JSdom 安装的 Node js 上尝试过 REPL:

$ 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);
[]

仅给出空数组
请帮助实现它更实际、正确的方法

javascript html node.js jsdom
© www.soinside.com 2019 - 2024. All rights reserved.