-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
For my research project Treehouse, I forked jsdom and got it to run in a web worker. This was two years ago. I'm interested in doing this again, but in a way that is maintainable, rather than just a proof-of-concept.
At a high level, this is what was necessary to get jsdom 0.2.4 running in a worker:
- remove node dependencies that cannot be met in the browser (
fs, e.g.)* - provide pure-JS implementations of node dependencies where possible (
url, e.g.)* - use
util.inheritsinstead of assigning to__proto__ - use
Object.definePropertyinstead of__defineSetter__/Getter__ - replace uses of variables named
windowanddocumentwithwinanddoc**
I also refactored the code to use AMD and build with RequireJS. I don't think this is necessary now (and may not have been necessary then): it should be possible to use the cjsTranslate method to build for the browser.
I would like to keep the diff from my fork to the original as minimal as possible. So, I'd like to upstream those changes that support browser compatibility in a non-breaking way. Would y'all be open to that?
* browserify may help with these
** I'm embarrassed to admit I don't remember why this was necessary
EDIT: I'm aware of this thread and #245