{"action":"opened","issue":{"number":329,"created_at":"2011-10-09T10:15:52Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Hello,\r\n\r\nThe newest _.isEqual introduces an incompatibility with Backbone.Relational, but it could be more wide-spread. I'm not sure if this bug should go here or in Backbone, you can decide!\r\n\r\nThe new check in eq() introduces array comparisons:\r\n   if (a.length === +a.length || b.length === +b.length)\r\n\r\nBackbone.Collection reset() sets a length variable:\r\n   this.length = 0;\r\n\r\nAnd Backbone.Model set() checks for a change in attribute using:\r\n   if (!_.isEqual(now[attr], val))\r\n\r\nFinally, Backbone.Relational replaces the serialized json arrays with a collection using Backbone.Model set(), but with the new _isEqual and the length variable on the Collection, when you pass an empty array with length = 0, the set doesn't occur because _.isEqual incorrectly detects that they are equal, even though one is an array and the other is a Backbone.Collection.\r\n\r\nSo I think the new _isEqual will incorrectly say anything is equal with zero length because of the new test:\r\n   if (a.length === +a.length || b.length === +b.length)\r\n \r\nI'm really not sure what the right fix is. Is it introducing a special case for \"array-like\" objects of zero length? Is it adding a check that something is a \"pure\"-array like object (no properties)? \r\n\r\nEither way, there should be a test like equal(_.isEqual(new Backbone.Collection(), []), false, 'Backbone.Collection is array-like, but also has properties'), but without the dependency on Backbone.\r\n\r\nIf this isn't clear, please let me know.\r\n\r\nCheers!","comments":0,"title":"Newest _.isEqual creates incompatibility with Backbone.Relational (and more!)","updated_at":"2011-10-09T10:15:52Z","url":"https://api.github.com/repos/documentcloud/underscore/issues/329","id":1855583,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/e01e261ed76aa771af08ad836726e13a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/kmalakoff","id":756520,"login":"kmalakoff"},"html_url":"https://github.com/documentcloud/underscore/issues/329","labels":[],"state":"open"},"legacy":{"number":329,"action":"opened","issue":1855583}}