Comments (12)
My feeling is that this is an issue with jsDOM
I guess that's quite possible. I'll give the options a few more tries. Based on other issues and stackoverflow, I had tried these, which were suppose to be the common way of getting around similar problems and worked for others:
JSDOM.reconfigureWindow(window, { url: 'http://localhost' })
JSDOM.reconfigureWindow(window, { location: 'http://localhost' })
JSDOM.reconfigureWindow(global.window, { url: 'http://localhost' })
window.location.href = 'http://localhost'
location.href = 'http://localhost'
...but strangely, setting href via the reconfigureWindow
option was never among them. I'll try that as well and see what sticks.
Since the issue does seem to originate with jsdom's output, I'll close this off. Thanks for looking into it, though!
from domjson.
Can you provide the smallest subset of the HTML code that causes this error? Also, information on the environment in which this occurred (browser, os, incognito or not, etc) would be very helpful.
from domjson.
I'm afraid I can't, as the page I am scraping via JSDOM.fromURL
is part of a proprietary project I have no direct access to, and I do not know which part of that HTML is causing the error.
But it has a bunch of Javascript in it, which I have to evaluate using JSDom's runScripts: 'dangerously'
option of the fromURL()
call.
It's also got a few hidden iframes and jQuery usage, some shadow dom stuff, as far as I can see. Not sure if any of this could be an issue?
from domjson.
Hmmm, it will be really hard to help without more information. Can you at least tell me what type of node (tagName, attribute, etc) is the last to be visited before the error is thrown?
from domjson.
The error occurs during the parsing, i.e. at the snippet I shared above.
I'm not sure how to find out which node the parser complains about?
The error points to the domJSON file, line 19:
...so for some reason the win
that gets passed in during the run of domJSON
, doesn't have a location
property.
from domjson.
Ok, that's a much more solvable issue. What btowser/os/environment is this occurring in?
from domjson.
Windows 10, 64bit.
Browser is jsdom, as mentioned.
from domjson.
Ah, you're using jsDOM, I missed that. I'm not very familiar with that library, but here is my suspicion: almost all browsers (at least all of the IE8+ ones) set this
to equal window
in the global scope, which is what this line that bootstraps the domJSON relies on. The existence of this library implies that jsDom does not do that. I will make a small change to that setup (this
=> this || window
) which will hopefully fix things for you, but you may need to use jsdom-global as well to get things to work properly.
from domjson.
Ok, attempted a fix with this commit. Can you please try it and let me know if it works?
from domjson.
I'm afraid I'm still getting the same error with that commit:
from domjson.
Just to be clear, you are getting that error even when using jsdom-global?
from domjson.
Also worth reading: jsdom/jsdom#1388 and https://github.com/tmpvar/jsdom#simple-options.
My feeling is that this is an issue with jsDOM not implementing a (very) standard portion of the DOM spec more than it is a bug with this library per se. Also, its worth noting that jsDOM is not one of the (psuedo-)browsers listed as being supported in the README...
That being said, I do recognize that this library should be usable in browsers that almost but not quite simulate the real thing, so if there's an easy fix, I'm happy to put it in. I just want to make sure we exhaust all of the options that involve configuring or extending jsDOM itself first.
from domjson.
Related Issues (20)
- Create page and demos
- Add browser compatibility table to docs
- Create demos
- When serialProperties is not false, .toDOM() produces multiple copies
- Speed optimizations
- "The input element's type ('checkbox') does not support selection." HOT 2
- Missing computedStyle in `toDOM` HOT 2
- Issues with UMD, automatically generate UMD HOT 5
- Getting the complete DOM HOT 4
- better reprasentation of json output HOT 1
- [question] How to pass pure html in toJSON() method? HOT 2
- Help guide has the wrong implementation of Node.replaceChild() HOT 1
- has some errors on NodeJS environment HOT 2
- Question about banned/disallowed tags HOT 9
- IE 11 InvalidStateError during copyJSON HOT 3
- I do not get instructions HOT 3
- Request to include xpath of the HTML element in the JSON
- How to handle DOM mutations?
- Cannot import this inside jest tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from domjson.