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: selector.includes is not a function when using tippy.js #540
Comments
I also meet this error, and I confirm that's because the difference between happy-dom and a real browser: const button = document.createElement('button');
console.log({}.toString.call(button)); // '[object Object]' instead of '[object HTMLButtonElement]' I guess we should use |
jledentu
added a commit
to jledentu/happy-dom
that referenced
this issue
Oct 10, 2022
…ect.prototype.toString.call on implemented element classes.
capricorn86
added a commit
that referenced
this issue
Oct 10, 2022
#540@patch: Add toStringTag in Element class to handle Object.prototype.toString.call
Thanks to @jledentu there is now a fix in for this 🙂 You can read more about the release here: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, great work on this library! I've attempted to migrate tests in my project from jsdom to happy-dom and I was stunned by the results. Some tests seen over 20x improvement in performance!
However, I am running into some issues, and I am happy to help resolve them in some pull request, but first I'd like to understand if this should be fixed in happy-dom or some other place. Maybe you already have this on your radar.
I am using
tippy.js
(or - React version of it) and I have this error:I have a CodeSandbox that recreates this issue here: https://codesandbox.io/s/happy-dom-tippy-test-forked-54v9tg?file=/src/App.test.tsx
As far as I see, the problem happens in this function of tippy.js: https://github.com/atomiks/tippyjs/blob/ad85f6feb79cf6c5853c43bf1b2a50c4fa98e7a1/src/dom-utils.ts#L25
And it might seem to be an issue in this library, but it works fine in jsdom. It seems like in jsdom, the first
if
of this function, so:is resolving to true, but it is not when using happy-dom. As a result happy-dom code is then called for
querySelectorAll
, but the selector is not a string, so the call toincludes
fails of course.In the end, on tippy side, this code is being executed to verify the type of the element: https://github.com/atomiks/tippyjs/blob/ad85f6feb79cf6c5853c43bf1b2a50c4fa98e7a1/src/utils.ts#L29 and calling
toString
using jsdom gives this result:[object HTMLButtonElement]
, but in happy-dom it's just[object Object]
.I assume it might be related to this list of non implemented element classes (https://github.com/capricorn86/happy-dom/blob/117595ed2f7d30d7e99757aafb316ab309b86bfc/packages/happy-dom/src/config/NonImplemenetedElementClasses.ts) and adding the
Button
type should fix that, right?The text was updated successfully, but these errors were encountered: