{"action":"created","issue":{"url":"https://api.github.com/repos/chaijs/chai/issues/628","repository_url":"https://api.github.com/repos/chaijs/chai","labels_url":"https://api.github.com/repos/chaijs/chai/issues/628/labels{/name}","comments_url":"https://api.github.com/repos/chaijs/chai/issues/628/comments","events_url":"https://api.github.com/repos/chaijs/chai/issues/628/events","html_url":"https://github.com/chaijs/chai/issues/628","id":135881599,"number":628,"title":"Failing to compare DOM Document structures","user":{"login":"ThomasBracher","id":2914331,"avatar_url":"https://avatars.githubusercontent.com/u/2914331?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasBracher","html_url":"https://github.com/ThomasBracher","followers_url":"https://api.github.com/users/ThomasBracher/followers","following_url":"https://api.github.com/users/ThomasBracher/following{/other_user}","gists_url":"https://api.github.com/users/ThomasBracher/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasBracher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasBracher/subscriptions","organizations_url":"https://api.github.com/users/ThomasBracher/orgs","repos_url":"https://api.github.com/users/ThomasBracher/repos","events_url":"https://api.github.com/users/ThomasBracher/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasBracher/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-23T22:06:09Z","updated_at":"2016-02-23T22:22:28Z","closed_at":"2016-02-23T22:22:28Z","body":"I use Chai to test some browser side code and i stumble a a weird bug : on Chrome, the Dom Document structure cannot be deepEqual'd or compare, the error is : `Error: Failed to read the 'cookie' property from 'Document': Access is denied for this document.`, on Edge : `Error: Unspecified error`, but it works fine on Firefox.\r\n\r\nYou can simply reproduce the bug with this snippet:\r\n\r\n```javascript\r\nchai.assert.deepEqual(new DOMParser().parseFromString('<div>Hello</div>', 'text/html'), new DOMParser().parseFromString('<div\r\ndiv>Hello</div>', 'text/html'));\r\n```\r\n\r\nI ended up using `isEqualNode` which works fines on chrome, firefox & edge.\r\n\r\n```javascript\r\nchai.assert.ok((new DOMParser().parseFromString('<div>Hello</div>', 'text/html')).isEqualNode(doc));\r\n```"},"comment":{"url":"https://api.github.com/repos/chaijs/chai/issues/comments/187942127","html_url":"https://github.com/chaijs/chai/issues/628#issuecomment-187942127","issue_url":"https://api.github.com/repos/chaijs/chai/issues/628","id":187942127,"user":{"login":"keithamus","id":118266,"avatar_url":"https://avatars.githubusercontent.com/u/118266?v=3","gravatar_id":"","url":"https://api.github.com/users/keithamus","html_url":"https://github.com/keithamus","followers_url":"https://api.github.com/users/keithamus/followers","following_url":"https://api.github.com/users/keithamus/following{/other_user}","gists_url":"https://api.github.com/users/keithamus/gists{/gist_id}","starred_url":"https://api.github.com/users/keithamus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithamus/subscriptions","organizations_url":"https://api.github.com/users/keithamus/orgs","repos_url":"https://api.github.com/users/keithamus/repos","events_url":"https://api.github.com/users/keithamus/events{/privacy}","received_events_url":"https://api.github.com/users/keithamus/received_events","type":"User","site_admin":false},"created_at":"2016-02-23T22:22:28Z","updated_at":"2016-02-23T22:22:28Z","body":"Hey @ThomasBracher thanks for the issue.\r\n\r\nThe `DOMParser` returns actual DOMElements which don't fit very well with deep equality, because they don't behave like plain javascript objects; most of their properties are non-enumerable and some properties can throw errors depending on their calling context, etc. You're seeing this with the error `Error: Failed to read the 'cookie' property from 'Document': Access is denied for this document.` - which is reproducible by the following code: `new DOMParser().parseFromString('<div>Hello</div>', 'text/html').cookie`.\r\n\r\nYou'd be much better off using a plugin that works with the DOM specifically, such as [chai-dom](https://github.com/nathanboktae/chai-dom). If it is missing assertions you'd like to see - I'd suggest filing issues with that plugin. \r\n\r\nHope this helps. I'm going to close this issue as Chai core isn't designed to work with the DOM, but if you find any more issues or if you run into any more troubles, feel free to file a new issue :smile: "}}