-
Notifications
You must be signed in to change notification settings - Fork 240
Feature parity between the browser and Node.js #94
Description
I'm creating this task since I didn't see a proper one for it.
So, we decided already that everything supported in the browser should also work when using the module with Node. Right now only .replace is supported.There are loads of issues and PRs related to this. This would also fix other issues like the bug where the emoji isn't found in <p>:)</p>.
I've already added a few tests for Node usage. We need to write tests for all features. Or even better, have tests that can easily be ran in either environment.
My idea for the implementation was to do everything with Node in mind first (i.e. just operating on strings). So using cheerio (or something like it) to do all the element type checking, etc. and then use whatever logic is used in .replace on any text. Then we'd compile it into one JS files for browser usage using browserify / webpack / an alternative.
@trevorah has split the parsing off into a separate module (see #93). He has an example using jsdom. I assumed we'd go with cheerio instead of jsdom to begin with because I heard jsdom is v heavy and cheerio has a nice API. Correct me if I'm wrong.
But #93 got me thinking anyway, if we do this, what happens in the browser when an emoji is found? Is the element re-created? (Maybe we'd have to take the root element, work on any text and then in the end we'd have a string again so we'd have to replace the root element?) Would the user lose their event handlers bound to the element? So, does it even make sense to use jsdom / cheerio at all?
Maybe we should have an API that underneath uses cheerio (for Node) / jQuery (for the browser) or something like that? Maybe jsdom does something like this already and I just don't know about it.
To do
- Test all features on Node / tests that run in both environments
- Implementation that works in both environments (every feature)