Closed Explosion-Scratch closed 3 years ago
Ok, first thing first what doesn't work on node.js without JSDom, do they rely on document/window/dom and can't be used without them and does JSDom make these features work in node.js? Would these features be widely used and should be able to use these features without installing JSDom?
Ok, first thing first what doesn't work on node.js without JSDom,
Lots of functions, like parseHTML, fetch, formData and many others, just search for isNode
in bijou.js
to see all of them.
do they rely on document/window/dom and can't be used without them and does JSDom make these features work in node.js?
Yes. To my knowledge JSDom allows everything that client-side JS does.
Would these features be widely used and should be able to use these features without installing JSDom?
I don't know. As Bijou.js is still in the early stages it's quite possible that these would be used widely or not. Some things (Like a copy(text)
function) would be widely used but are useless in NodeJS, other things, (like syntaxHighlight
) rely on the DOM for manipulation of HTML elements, while more use event listeners and would be useless even if they worked in NodeJS (onScrollStop
, or addStyles
).
Lots of functions, like parseHTML, fetch, formData and many others, just search for
isNode
inbijou.js
to see all of them.
Ok, here is what won't work in node and these need the document element
Yes. To my knowledge JSDom allows everything that client-side JS does.
Really? Have you tried the above list using JSDom?
I don't know. As Bijou.js is still in the early stages it's quite possible that these would be used widely or not. Some things (Like a
copy(text)
function) would be widely used but are useless in NodeJS, other things, (likesyntaxHighlight
) rely on the DOM for manipulation of HTML elements, while more use event listeners and would be useless even if they worked in NodeJS (onScrollStop
, oraddStyles
).Fair point, this makes sense.
Yes. To my knowledge JSDom allows everything that client-side JS does.
Really? Have you tried the above list using JSDom?
No, I assuming.
Yes. To my knowledge JSDom allows everything that client-side JS does.
Really? Have you tried the above list using JSDom?
No, I assuming.
Makes enough sense, and most of these would be useless for node.js
@wgyt Also note that highlightel
is an internal function and cannot be used outside of the syntaxHighlight
scope.
@wgyt Also note that
highlightel
is an internal function and cannot be used outside of thesyntaxHighlight
scope.
Oh really? What does highlightel do?
@wgyt Also note that
highlightel
is an internal function and cannot be used outside of thesyntaxHighlight
scope.Oh really? What does highlightel do?
syntaxHighlight
returns the syntax highlighted HTML for a string of code (E.g. alert("hello")
), highlightel
syntax highlights an element and applies it to the element, an unfavorable alternative to highlighting a string, as it's less customize-able.
@wgyt Also note that
highlightel
is an internal function and cannot be used outside of thesyntaxHighlight
scope.Oh really? What does highlightel do?
syntaxHighlight
returns the syntax highlighted HTML for a string of code (E.g.alert("hello")
),highlightel
syntax highlights an element and applies it to the element, an unfavorable alternative to highlighting a string, as it's less customize-able.
oh ok makes sense
Take a look at https://github.com/TheColaber/Text2HTML it parses HTML without using dom parsers or innerHTML. It's useful if you're trying to submit a chrome extension or something that disallows innerHTML and dom parsers.
Here's an idea: add a dependency of jsdom.
Here's an idea: add a dependency of jsdom.
@Explosion-Scratch said:
Even though I suggest in the error thrown to use JSDom I don't want to make this dependent on it.
Here's an idea: add a dependency of jsdom.
Yeah, JSDom would enable some features that we have in vanilla JS, but so many would just be totally useless in NodeJS, like _$.copy("Hello")
, or notify()
. Instead of focusing on extending existing functions to work with NodeJS, I'd rather find new functions that are helpful to NodeJS.
hmmmmmmm
Currently a lot of the features of Bijou.js rely on DOM/window/document elements. This means that only about half of functions work in NodeJS. Even though I suggest in the error thrown to use JSDom I don't want to make this dependent on it. This means that we need new ideas! What snippets do people use frequently in Node? Comment below anything that you use/think is helpful! Thanks in advance!
--Explosion--