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

eql does not work to compare Nodes in Firefox #120

Closed
arv opened this issue Dec 12, 2012 · 4 comments
Closed

eql does not work to compare Nodes in Firefox #120

arv opened this issue Dec 12, 2012 · 4 comments

Comments

@arv
Copy link

arv commented Dec 12, 2012

eql uses Object.keys which only includes enumerable own properties. For DOM Nodes we have no own properties so they end up considered to be equal.

chai.expect(document.createTextNode('a')).to.not.eql(document.createTextNode('b'))

@domenic
Copy link
Contributor

domenic commented Dec 12, 2012

Hmm, definitely an oversight. I'm not sure what the state of the art for deep-equal algorithms is. Any advice on the DOM element case in particular?

@arv
Copy link
Author

arv commented Dec 12, 2012

The main reason I was using eql was to compare two arrays with nodes. For now I just ended up adding arrayEqual but I was told that eql was supposed to cover this use case.

I think there will be more cases like this in the future where people end up using getters on the prototype chain (like the DOM).

@domenic
Copy link
Contributor

domenic commented Dec 16, 2012

@logicalparadox any ideas on how we should modify the deep equal algorithm for this?

As @arv says, there are plenty of objects with getters in their prototype chain for which this might be important.

I believe QUnit.equiv compares DOM nodes in some way. Or maybe it just compares non-own properties, and that's how it catches this.

I guess my initial thought is to just expand our current algorithm to include non-own properties as well.

@logicalparadox
Copy link
Member

Agreed, it seems best to start with non-own properties and go from there; see if this satisfies the requirement. If we can avoid implementing different algorithms for different browsers, I think everyone involved would be much happier.

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

No branches or pull requests

3 participants