-
Notifications
You must be signed in to change notification settings - Fork 16
fix: do not treat a NodeList as HTMLCollection #104
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
Conversation
An `HTMLCollection` assumes all items are `Element`s, a `NodeList` however may also include `Node`s such as `Text` and `Comment`, which does not include the `getAttributeNames` method. fixes chaijs/chai#1680
|
Hi @43081j , would this simple fix be acceptable to you? |
|
I think I'd prefer to see more work done in |
|
something like this was what i had in mind sorry i didnt give you chance to try write this yourself, i didn't know the answer until i started hacking away at it we can pull this into your PR here if we're all happy with it |
|
@43081j no worries, your solution is better than mine. My goal was just to prevent the error, and I'm happy to see this moving forward. Thanks for your time :) |
|
@43081j just placed your changes within my previously failing tests and it's all good |
|
@keithamus let me know what you think and ill push it to this branch if all is good @DiogoDoreto thanks for reviewing 🙏 |
|
Looks good but I think perhaps all |
|
you're right, i've simplified it by removing the |
|
i've merged my changes into this branch @keithamus if you can re-review, we can probably merge this |
keithamus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I think this looks good. We should probably add some more tests but can follow up with that.
An
HTMLCollectionassumes all items areElements, aNodeListhowever may also includeNodes such asTextandComment, which does not include thegetAttributeNamesmethod.Stops the error described here chaijs/chai#1680 but logging that div from inside the iframe changes the output a bit, logging it as a regular object (
HTMLDivElement{ …(1) }), but in a way that is still acceptable to me for now, until we wait for the proper fix described here: chaijs/chai#1680 (comment)