{"action":"created","issue":{"url":"https://api.github.com/repos/jquery/jquery/issues/2145","labels_url":"https://api.github.com/repos/jquery/jquery/issues/2145/labels{/name}","comments_url":"https://api.github.com/repos/jquery/jquery/issues/2145/comments","events_url":"https://api.github.com/repos/jquery/jquery/issues/2145/events","html_url":"https://github.com/jquery/jquery/issues/2145","id":61671860,"number":2145,"title":"$.each fails intermittently on iOS due to Safari bug","user":{"login":"osolo","id":664633,"avatar_url":"https://avatars.githubusercontent.com/u/664633?v=3","gravatar_id":"","url":"https://api.github.com/users/osolo","html_url":"https://github.com/osolo","followers_url":"https://api.github.com/users/osolo/followers","following_url":"https://api.github.com/users/osolo/following{/other_user}","gists_url":"https://api.github.com/users/osolo/gists{/gist_id}","starred_url":"https://api.github.com/users/osolo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osolo/subscriptions","organizations_url":"https://api.github.com/users/osolo/orgs","repos_url":"https://api.github.com/users/osolo/repos","events_url":"https://api.github.com/users/osolo/events{/privacy}","received_events_url":"https://api.github.com/users/osolo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jquery/jquery/labels/Core","name":"Core","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/jquery/jquery/milestones/2","html_url":"https://github.com/jquery/jquery/milestones/3.0.0","labels_url":"https://api.github.com/repos/jquery/jquery/milestones/2/labels","id":561714,"number":2,"title":"3.0.0","description":"","creator":{"login":"dmethvin","id":157858,"avatar_url":"https://avatars.githubusercontent.com/u/157858?v=3","gravatar_id":"","url":"https://api.github.com/users/dmethvin","html_url":"https://github.com/dmethvin","followers_url":"https://api.github.com/users/dmethvin/followers","following_url":"https://api.github.com/users/dmethvin/following{/other_user}","gists_url":"https://api.github.com/users/dmethvin/gists{/gist_id}","starred_url":"https://api.github.com/users/dmethvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmethvin/subscriptions","organizations_url":"https://api.github.com/users/dmethvin/orgs","repos_url":"https://api.github.com/users/dmethvin/repos","events_url":"https://api.github.com/users/dmethvin/events{/privacy}","received_events_url":"https://api.github.com/users/dmethvin/received_events","type":"User","site_admin":false},"open_issues":44,"closed_issues":77,"state":"open","created_at":"2014-02-07T02:09:56Z","updated_at":"2015-03-16T17:22:59Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-03-14T18:21:42Z","updated_at":"2015-03-18T12:10:33Z","closed_at":null,"body":"There is a timing bug in iOS8 that causes mobile Safari to incorrectly report a 'length' on objects that don't have one.\r\n\r\nTo the best of my knowledge, this happens on iOS8+, possibly only on 64-bit systems.  The bug is triggered for objects that have only numeric properties.  For example:\r\n```javascript\r\nfoo = { 1: 'a', 2: 'b', 3: 'c' } \r\n```\r\nIn this case, if you query `foo.length` then mobile Safari will *sometimes* return 4 (the highest property + 1).\r\n\r\nThis causes functions like `$.each()` to treat objects such as foo above as arrays instead of objects, and when it tries to iterate them as such it fails since there is no foo[0].\r\n\r\nThe problem can be fixed in the function `isArrayLike()`.  Instead of just checking for \r\n```javascript\r\ntypeof length === \"number\"\r\n```\r\nyou also need to check for\r\n```javascript\r\nobj.hasOwnProperty('length')\r\n```\r\n\r\nThe latter check is immune to the iOS bug.\r\n\r\nI realize this is a fix just for one browser, but it's a browser with a very large user base.\r\n\r\nYou can see more background and some repro steps at the following Stack Overflow discussion:\r\n\r\nhttp://stackoverflow.com/questions/28155841/misterious-failure-of-jquery-each-and-underscore-each-on-ios"},"comment":{"url":"https://api.github.com/repos/jquery/jquery/issues/comments/82940071","html_url":"https://github.com/jquery/jquery/issues/2145#issuecomment-82940071","issue_url":"https://api.github.com/repos/jquery/jquery/issues/2145","id":82940071,"user":{"login":"dmethvin","id":157858,"avatar_url":"https://avatars.githubusercontent.com/u/157858?v=3","gravatar_id":"","url":"https://api.github.com/users/dmethvin","html_url":"https://github.com/dmethvin","followers_url":"https://api.github.com/users/dmethvin/followers","following_url":"https://api.github.com/users/dmethvin/following{/other_user}","gists_url":"https://api.github.com/users/dmethvin/gists{/gist_id}","starred_url":"https://api.github.com/users/dmethvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmethvin/subscriptions","organizations_url":"https://api.github.com/users/dmethvin/orgs","repos_url":"https://api.github.com/users/dmethvin/repos","events_url":"https://api.github.com/users/dmethvin/events{/privacy}","received_events_url":"https://api.github.com/users/dmethvin/received_events","type":"User","site_admin":false},"created_at":"2015-03-18T12:10:33Z","updated_at":"2015-03-18T12:10:33Z","body":"Wow. I guess this must be rare enough that it doesn't occur that often? Plain object, only numeric indices, etc. There's a patch in https://github.com/jashkenas/underscore/pull/2094 that says it tries to work around this. We could do something similar but it seems like we're in the same situation as we were with the December release. Is it worth doing another minor-point release for this?"}}