Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Server side capability via jsdom #2

Merged
merged 10 commits into from
Apr 13, 2016
Merged

Conversation

bceskavich
Copy link

While working with convert-rich-text at Vox Media, we've come across the need to use this package on both the server and the client. Currently, this only works on the client as it requires access to the DOM. This PR includes changes to add this functionality:

  • Two package entries, one for the browser and one for the server. The server entry instantiates a global document variable that is a jsdom instance
  • add functions in formats objects can include an optional third argument called dom. If used, we'll pass in our own helper, instead of asking the user to provide their own.

@thomsbg
Copy link
Owner

thomsbg commented Apr 12, 2016

Is there a way to reduce duplication between browser.js and index.js? Perhaps the convert function could take in document as an option?

// index.js
var document = require('jsdom').jsdom();
module.exports = require('./browser')({ document: jsdom() })

@thomsbg thomsbg merged commit 9998515 into thomsbg:master Apr 13, 2016
@thomsbg
Copy link
Owner

thomsbg commented Apr 13, 2016

Thanks @bceskavich!

@stephenmckinney stephenmckinney deleted the bc-jsdom branch June 18, 2020 14:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants