jsdom

What are the use cases of jsdom

拜拜、爱过 提交于 2019-12-20 09:14:35
问题 After reading this Micro templates are dead article. I've become curious: Whether Using the DOM on the server results in cleaner more maintainable code then templating. Whether it's more efficient to use jsdom instead of a templating engine. How to factor jsdom into the View of a standard MVC setup. And generally in what situations would it be better to use a server-side DOM abstraction, like jsdom rather then a templating engine, like EJS or jade. The question is specific to node.js and

Launch jsdom from Rhino on Java

点点圈 提交于 2019-12-19 10:22:50
问题 I'm following up on this answer: I managed to run simple JavaScript code from Rhino Engine on Java. But when it comes to D3.js, for example: var svg = d3.select("body").append("svg") as you can see d3 requires DOM to be available on first place. So, for that reason JSDOM is supposed to be the solution. But JSDOM happens to be depended on requirejs From RequireJs site: The r.js file allows you to run the optimizer as well as run modules in Node, Rhino or xpcshell. Then my Java Rhino code look

Migrate from jsdom to phantomJS ? (basic DOM creation)

左心房为你撑大大i 提交于 2019-12-19 08:52:08
问题 M. Bostock pointed out that nodejs' jsdom have incomplete support for svg, and, critical for me, doesn't support getBBox() . Also, he advised to switch to nodejs' PhantomJS. I checked out but the approach is new to me. My nodejs + jsdom script create a virtual DOM, with which my d3js plays and is as follow : var jsdom = require('jsdom'); jsdom.env( // creates virtual page "<html><body></body></html>", // create my DOM hook, [ 'http://d3js.org/d3.v3.min.js', // add my online dependencies ... '

How do you add stylesheets to JSDOM

独自空忆成欢 提交于 2019-12-18 16:17:10
问题 I am currently working on a project that requires me to have computed styles send to the browser via JSDOM. I am currently looking for a way to inject some basic CSS into JSDOM so that it could compute the correct inline style (Yes I know that's bad). From what I have found out I can use JSDOM Level 2, but from there I can't find any documentation on how to inject the styles. This is what I have so far; var document = jsdom.jsdom('<!DOCTYPE html><html><head></head><body id="abody" ></body><

jsdom not loading or not running external scripts in page

无人久伴 提交于 2019-12-14 03:50:53
问题 Cross-posted from https://github.com/tmpvar/jsdom/issues#issue/127 I will post a minimal test case in the next day or so - but I wanted to see if anyone else had the same problem - or if (more likely) if I am doing something stupid. I'm using NodeJS v2.6 on Ubuntu 10.04 AMD64 and jsdom@0.1.23. var file = readFileSync("./www/index.html", "utf8"); var window = jsdom.jsdom(file).createWindow(); All inline scripts run, but complain about missing variables which should be supplied by the external

node.js: problems with jsdom - jQuery object returns undefined

独自空忆成欢 提交于 2019-12-13 18:29:49
问题 I am interested in doing some server-side DOM manipulations for one of projects, so I decided to take a look at node.js, and at jsdom in particular. I'm completely new to node.js, so probably my mistakes are obvious, but never the less i couldn't find solution for my problem anywhere... First of all i'm running node on Windows locally, and also use online IDE cloud9 It was worth mentioning as i got troubles installing latest jsdom package for node (which is 0.2.15), because a required

unable to complete promises due to out of memory

坚强是说给别人听的谎言 提交于 2019-12-13 02:44:09
问题 I have a script to scrape ~1000 webpages. I'm using Promise.all to fire them together, and it returns when all pages are done: Promise.all(urls.map(url => scrap(url))) .then(results => console.log('all done!', results)); This is sweet and correct, except for one thing - machine goes out of memory because of the concurrent requests. I'm use jsdom for scrapping, it quickly takes up a few GB of mem, which is understandable considering it instantiates hundreds of window . I have an idea to fix

jsdom.jsdom missing a “createWindow” method

北城以北 提交于 2019-12-12 11:34:35
问题 I am trying to use jsdom to analyze some html content. Examples that i have seen use the .createWindow() method of a jsdom.jsdom document based on html content. But when I try to follow these examples, my document does not have a .createWindow() method. var getaPage=function (req, res, callback) { jsdom.defaultDocumentFeatures={ FetchExternalResources : ['script'], ProcessExternalResources : ['script'], MutationEvents : '2.0', QuerySelector : false }; var htmlDoc = '<html lang="en-US">' + '<

Jest can not deal with insertAdjacentElement?

自作多情 提交于 2019-12-12 11:06:01
问题 I want to test a quite simple JS function export function displaySpinner() { const loadingOverlayDOM = document.createElement('DIV'); const spinner = document.createElement('IMG'); loadingOverlayDOM.id = 'overlay-spinner'; loadingOverlayDOM.className = 'content-overlay'; spinner.className = 'is-spinning'; spinner.setAttribute('src', '/assets/img/svg/icons/spinner.svg'); l loadingOverlayDOM.insertAdjacentElement('beforeend', spinner); document.body.insertAdjacentElement('beforeend',

node.js module works from command line, not from script

為{幸葍}努か 提交于 2019-12-11 20:09:08
问题 I've installed jsdom on my windows 8.1 machine. If I am one directory above my local installation of jsdom, I can call node jsdom and everything works. However, if, from the same dir / pwd, I call a script (at a different path) with require("jsdom").jsdom; I get errors of the type Error: cannot find module 'jsdom' 回答1: If you omit the extension, node will resort to looking in the node_modules folder for a package named "jsdom" (installed via NPM). You can either install the module with NPM