-
Notifications
You must be signed in to change notification settings - Fork 4
Support JSDOM (with DOMPurify) #2
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
Comments
Sadly there is limitations, jsdom was not made to work in the browser. I had a bunch of error while trying to add it and this is why I choose to add parse5 instead. If you manage to make it work, submit a pull request and I will happily merge it. |
I am working on adding it right now. I'll probably do so using an API route. JSDom theoretically officially works on the browser with browserify, but I don't trust browserify to not introduce behaviour changes. |
Got it working locally by running JSDom on the server with a Nuxt API route. Two issues though:
So the only realistic approach I see -- especially because of 2. -- is to hide the JSDom parser behind a featureflag. Maybe display JSDom in the frontend always, but greyed out with a note that JSDom is only available when hosting Dom-Explorer yourself. I suppose that the kind of people looking into JSDom parsing differentials are fine with self-hosting Dom-Explorer. @B-i-t-K let me know what your thoughts on that are. If you are fine with these trade-offs I'll look into cleaning up my code and opening up a PR. I would also look into adding a setting for the DOMPurify pipe to run it with JSDom serverside. |
I have pushed my current patches to https://github.com/jonasheschl/Dom-Explorer-JSDom |
Thoughts @B-i-t-K ? |
Sorry for the delay, I like the way you added JsDom, but I want to be able to publish dom-explorer as a github page which remove the possibility for backend pipe like this one. I don't know yet if I want to add a compilation flag or maybe two different branches for people who are self hosting. |
I can fully understand that. I have some research coming up where I might continue to develop my fork. If you want to merge it (or parts of it) into the mainline lmk. |
Uh oh!
There was an error while loading. Please reload this page.
Currently the DOMPurify pipe will always run its purification using the browser. It would be useful to have an option in the DOMPurify pipe to use JSDom instead.
In addition, while there is a pipe for parse5, there is no pipe for JSDom. Even though JSDom uses parse5, it can sometimes exhibit parsing differentials to parse5 itself.
The pipe for JSDom could look something like this, where HTML_STRING is the HTML to be parsed.
The text was updated successfully, but these errors were encountered: