Conversation
|
|
||
| export const document = () => globalThis?.document; | ||
|
|
||
| export const document = /* @__PURE__ */ globalThis?.document; |
There was a problem hiding this comment.
Why is this a function now?
There was a problem hiding this comment.
previously this value was captured when the module graph was loaded - which is before any (non-top-level) code has had a chance to execute.
This means that in the test environment, where by default we do not have a global window object, our own document was always undefined. We also want to reset the document in between tests, so that's another reason why we can't have a stable reference here.
Initially I pulled out this constant as a server runtime size optimisation, since it avoids repeating the string document all over the bundle
| mount(reconciler, prev) | ||
| push(reconciler, diff.diff(events.new(), prev, next).patch) | ||
|
|
||
| should.equal(get_html(), element.to_string(next)) |
There was a problem hiding this comment.
would it be possible to get the virtualised domain instead of this, im not so comfortable comparing strings and hoping for the best.
There was a problem hiding this comment.
yeah I think we can also call virtualise again. I did the string because I felt like it was more focused, but it already relies on some details for it to pass currently (i.e. attribute order)
There was a problem hiding this comment.
Ok so we can't just use == because of fragments, and keys, and mappers --- these are all either completely or partially missing from the vdom we can recover using virtualise. I added a custom comparison function that handles these cases, but it's a tiny bit complicated itself.
dc7b6f0 to
b1ad6a8
Compare
Most of the tests are diff tests that I "automatically" converted.
happy-dom.ffi.mjsis the compiled output of runningnpm run buildin the happy-dom directory. It's a 1.7mb bundle. I didn't minify it because I think it makes testing easier.