-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom DOM library support on Node.js (e.g. JSDOM) #158
Comments
There could be a new var html = require('nanohtml/lib/browser')
global.document = jsdomDocument
var el = html`
<h1>uses jsdom</h1>
` or: function html (document) {
var inner = require('nanohtml/lib/browser')
return function (strings, ...expressions) {
global.document = document
var result
try {
return inner(strings, ...expressions)
} finally {
delete global.document
}
}
} |
The maintainer of hyperhtml suggested same thing but I don't want to pollute global scope. (And I hope there be no hack modifying and de-modifying global scope.) |
I wouldn't be opposed to a dependency injection like API like you suggest. I think to implement it, the simplest way is to:
then it could be released as a minor version. I don't really wanna do it myself 🙈 but would review a PR, whether it takes the above approach or a different one! |
Hi, nanohtml maintainers:
I'm a maintainer of ReSpec and currently working on porting our string template HTML code to make it work on Node.js without big changes.
We need a way to generate DOM tree instead of a string from inline HTML, because our code currently heavily relies on DOM APIs. I wonder we could do something like this:
What do you think? Would this also benefit other nanohtml users?
The text was updated successfully, but these errors were encountered: