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
Node.isEqualNode() #656
Labels
enhancement
New feature or request
Comments
The method in the Node interface according to spec is There's also |
gangsthub
added a commit
to gangsthub/happy-dom
that referenced
this issue
Jan 23, 2023
capricorn86
added a commit
that referenced
this issue
Jan 28, 2023
#656@minor: Rename `nodeEquals` to `isEqualNode`.
Thanks for your contribution @gangsthub! 🙂 Your fix has been released. 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
Is your feature request related to a problem? Please describe.
I wanted to compare two happy-dom nodes in my tests, however the library does not implement the standard
Node.isEqualNode browser method.
Instead I noticed there is a static function (
nodeEquals
) that implements this functionality inNodeUtility
.The issue is I did not realise this functionality was available in the library until I dug through the source
code, and I had to do this import in order to use it:
Describe the solution you'd like
I was wondering if there was some design choice behind this that I haven't considered, or whether it
would be possible to add the method to the
INode
type, the same way it works in browsers?Additional context
I am actually using happy-dom to test a web framework I am developing, and it involves comparing
generated HTML trees, hence the above.
The official implementation makes this tricky sometimes because of whitespace between nodes. I have
actually implemented a wrapper function around
nodeEquals
which first strips the two node trees ofany text nodes only containing whitespace. This makes comparison between two node trees more
meaningful in a test environment for generated HTML.
I'm not sure if the above function would have any use in
NodeUtilities
as well?Happy to put in a pull request if any of the above seems desirable.
The text was updated successfully, but these errors were encountered: