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

TypeError: target.ownerDocument.createRange is not a function #450

Closed
msawatzky75 opened this issue Apr 5, 2022 · 11 comments · Fixed by #525
Closed

TypeError: target.ownerDocument.createRange is not a function #450

msawatzky75 opened this issue Apr 5, 2022 · 11 comments · Fixed by #525
Assignees
Labels
enhancement New feature or request

Comments

@msawatzky75
Copy link

Using @testing-library/user-event@14.0.4

https://developer.mozilla.org/en-US/docs/Web/API/Range

@jiahong96
Copy link

jiahong96 commented Apr 25, 2022

Am using happy-dom in vitest. Having same error with @testing-library/user-event, specifically the clicks APIs.

"vitest": "^0.9.3"
"happy-dom": "^2.55.0"
"@testing-library/user-event": "^14.1.1"

@frankandrobot
Copy link

Having the same issue. It looks like happy-dom does not implement the Range class.
Any workarounds? Note: a working version is required because that's what user-event seems to use in order to make selections...

So then it appears that happy-dom cannot be used with user-event until this is resolved?

@hornta
Copy link

hornta commented May 22, 2022

I'm waiting for this as well. We want to use this through the vitest package and jsdom is too slow.

I made this issue in vitest for reference with an reproducible example: vitest-dev/vitest#1354

@capricorn86 capricorn86 self-assigned this May 23, 2022
@capricorn86
Copy link
Owner

I have started on implementing it now 🙂

@frankandrobot
Copy link

@capricorn86 let me know if there's anyway I can be of help. The company i'm working for has given us the budget to help on the effort since we use this :-)

@capricorn86
Copy link
Owner

@frankandrobot nice to hear! Its quite a lot of logic in Range, but it might at the same time be hard to split up the work. I will keep it in mind 🙂

@frankandrobot
Copy link

Howdy @capricorn86 , just wanted to know how the effort is going and offering help again if needed with the implementation :-)

@capricorn86
Copy link
Owner

@frankandrobot this is my main task that I am working on. Some of the logic is a bit tricky to get right. I would say that about half has been done 😅

@capricorn86
Copy link
Owner

Not sure if it is possible to collaborate on this one. It can be hard to work in the same files 😅

NuckChorris added a commit to hummingbird-me/kitsu-web that referenced this issue Jun 22, 2022
@testing-library/user-events has issues on happy-dom due to capricorn86/happy-dom#450. Once createRange is implemented we should be able to switch back to happy-dom and get much better test performance than with jsdom
capricorn86 added a commit that referenced this issue Jun 28, 2022
…ializeToString(). Fixes issue with HTMLTemplateElement.outerHTML.
capricorn86 added a commit that referenced this issue Jun 30, 2022
… for Document.getSelection(). Fixes issue preventing usage of multiple Window instances.
@capricorn86
Copy link
Owner

We finally have full support for document.createRange() and document.getSelection()! 😄

I am sorry that it took such a long time. It was a lot more complicated than I expected and a lot of code had to be written to support this.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v6.0.0

@frankandrobot
Copy link

frankandrobot commented Jul 1, 2022 via email

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

Successfully merging a pull request may close this issue.

5 participants