Get DOM element's actual width using jsdom

后端 未结 1 415
旧时难觅i
旧时难觅i 2021-01-05 04:29

I wonder if I could get a DOM element\'s actual width and coordinates, as I can get using .clientWidth / .offsetWidth from within the browser.

Does jsdom has browser

相关标签:
1条回答
  • 2021-01-05 04:42

    JSDOM is strictly a DOM API emulation library. It does not attempt to actually render a document, which is necessary to compute element size and position.

    You may want to look at PhantomJS. It is a full WebKit renderer with a JavaScript API. It is entirely separate from node, so you either need to write a utility script using Phantom's API, or use a npm module that lets you control Phantom from node.

    0 讨论(0)
提交回复
热议问题