Skip to content
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

Work with jsdom without global values #137

Open
vilicvane opened this issue Jan 13, 2024 · 2 comments
Open

Work with jsdom without global values #137

vilicvane opened this issue Jan 13, 2024 · 2 comments

Comments

@vilicvane
Copy link

vilicvane commented Jan 13, 2024

Trying to use diff-dom in non-test Node.js project with jsdom, I noticed the document option that allows manually specifying the value, but that option along does not work.

The issue is caused by DiffFInder doing a global typeof Element check that prevents the expected nodeToObj() conversion:

https://github.com/fiduswriter/diffDOM/blob/8f19b20a5e8e1f8d1db488a8b9e26e1fc745ec34/src/diffDOM/virtual/diff.ts#L42C1-L43

Workaround:

dd.diff(nodeToObj(elementA), nodeToObj(elementB));
@johanneswilm
Copy link
Member

Please provide minimal example @vilicvane

@kapouer
Copy link
Contributor

kapouer commented May 21, 2024

Got an error with that too.
The check here:

typeof element?.ownerDocument?.defaultView?.[elementTypeName] ===

assumes that element.ownerDocument is live.
However document.cloneNode().defaultView == null.

The test should fall back to nodeToObj in that case, cause it is impossible to check inheritance in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants