Skip to content

Conversation

@DiogoDoreto
Copy link
Contributor

An HTMLCollection assumes all items are Elements, a NodeList however may also include Nodes such as Text and Comment, which does not include the getAttributeNames method.

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)

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
@DiogoDoreto
Copy link
Contributor Author

Hi @43081j , would this simple fix be acceptable to you?

@keithamus
Copy link
Member

I think I'd prefer to see more work done in inspectHTML to switch on the node type. inspectHTML should probably be typed so that the first argument is instead node: Node and follow on from there.

@43081j
Copy link
Contributor

43081j commented Mar 18, 2025

main...node-lists-and-such

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

@DiogoDoreto
Copy link
Contributor Author

@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 :)

@DiogoDoreto
Copy link
Contributor Author

@43081j just placed your changes within my previously failing tests and it's all good

@43081j
Copy link
Contributor

43081j commented Mar 18, 2025

@keithamus let me know what you think and ill push it to this branch if all is good

@DiogoDoreto thanks for reviewing 🙏

@keithamus
Copy link
Member

Looks good but I think perhaps all inspectList calls in the html.ts file should use inspectNode, no?

@43081j
Copy link
Contributor

43081j commented Mar 18, 2025

you're right, i've simplified it by removing the HTMLCollection stuff entirely and using inspectNodeCollection for both

@43081j
Copy link
Contributor

43081j commented Apr 8, 2025

i've merged my changes into this branch

@keithamus if you can re-review, we can probably merge this

Copy link
Member

@keithamus keithamus left a 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.

@keithamus keithamus enabled auto-merge (squash) April 8, 2025 15:38
@keithamus keithamus merged commit fc78a8b into chaijs:main Apr 8, 2025
7 checks passed
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

Successfully merging this pull request may close these issues.

3 participants