You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having to set up a global document before invoking morphdom is tricky when there are lots of tests which might use different doms.
Might I propose adding an option, e.g. morphdom(..., ..., document: dom.window.document) or something similar that allows us to inject this into the individual calls? Alternatively, maybe we can extract it from the first argument?
I found one way to work around this is pre-constructing the fragment, rather than providing HTML:
createDocumentFragment(html) {
return this.document.createRange().createContextualFragment(html);
}
update(id, html, options) {
let element = this.document.getElementById(id);
let fragment = this.createDocumentFragment(html);
morphdom(element, fragment);
This avoids morphdom having to interact with doc internally. Not sure if there are any performance problems with this approach?
Hi, thanks for creating morphdom.
It looks like testing morphdom with jsdom is quite tricky, e.g. https://runkit.com/autosponge/morphdom-jsdom-example
Having to set up a global document before invoking
morphdom
is tricky when there are lots of tests which might use differentdom
s.Might I propose adding an option, e.g.
morphdom(..., ..., document: dom.window.document)
or something similar that allows us to inject this into the individual calls? Alternatively, maybe we can extract it from the first argument?I see some additional discussion here: #98
Another idea is to introduce a class which contains the state.
e.g.
In my own code, I have something like this:
This makes testing using jsdom extremely easy.
The text was updated successfully, but these errors were encountered: