{"action":"created","issue":{"url":"https://api.github.com/repos/philbooth/check-types.js/issues/52","labels_url":"https://api.github.com/repos/philbooth/check-types.js/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/philbooth/check-types.js/issues/52/comments","events_url":"https://api.github.com/repos/philbooth/check-types.js/issues/52/events","html_url":"https://github.com/philbooth/check-types.js/issues/52","id":103438812,"number":52,"title":"instance predicate returns false for objects","user":{"login":"philbooth","id":64367,"avatar_url":"https://avatars.githubusercontent.com/u/64367?v=3","gravatar_id":"","url":"https://api.github.com/users/philbooth","html_url":"https://github.com/philbooth","followers_url":"https://api.github.com/users/philbooth/followers","following_url":"https://api.github.com/users/philbooth/following{/other_user}","gists_url":"https://api.github.com/users/philbooth/gists{/gist_id}","starred_url":"https://api.github.com/users/philbooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philbooth/subscriptions","organizations_url":"https://api.github.com/users/philbooth/orgs","repos_url":"https://api.github.com/users/philbooth/repos","events_url":"https://api.github.com/users/philbooth/events{/privacy}","received_events_url":"https://api.github.com/users/philbooth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-27T06:34:07Z","updated_at":"2015-08-29T13:29:41Z","closed_at":null,"body":"Raised [elsewhere](https://github.com/philbooth/check-types.js/issues/38#issuecomment-135220534) by @euoia:\r\n\r\n>I have found a case where check.instance doesn't agree with instanceof. In Chrome and Safari:\r\n>```\r\n>document.getElementById('el') instanceof HTMLElement\r\n>> true\r\n>```\r\n>\r\n>But due to how the instance function in check-types.js checks that prototype is a function (see https://github.com/philbooth/check-types.js/blob/master/src/check-types.js#L151), the following returns false in Safari and true in Chrome:\r\n>```\r\n>check.assert.instance(document.getElementById('el'), HTMLElement);\r\n>```\r\n>\r\n>Due to this behaviour in Safari:\r\n>```\r\n>typeof HTMLElement\r\n>> \"object\"\r\n>```\r\n>\r\n>And this in Chrome:\r\n>```\r\n>typeof HTMLElement\r\n>> \"function\"\r\n>```\r\n>\r\n>So although this seems due to a browser implementation difference, it is at least surprising that check.instance doesn't agree with instanceof. Is it necessary for the instance function to check that prototype is a function?"},"comment":{"url":"https://api.github.com/repos/philbooth/check-types.js/issues/comments/135987384","html_url":"https://github.com/philbooth/check-types.js/issues/52#issuecomment-135987384","issue_url":"https://api.github.com/repos/philbooth/check-types.js/issues/52","id":135987384,"user":{"login":"euoia","id":1271216,"avatar_url":"https://avatars.githubusercontent.com/u/1271216?v=3","gravatar_id":"","url":"https://api.github.com/users/euoia","html_url":"https://github.com/euoia","followers_url":"https://api.github.com/users/euoia/followers","following_url":"https://api.github.com/users/euoia/following{/other_user}","gists_url":"https://api.github.com/users/euoia/gists{/gist_id}","starred_url":"https://api.github.com/users/euoia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/euoia/subscriptions","organizations_url":"https://api.github.com/users/euoia/orgs","repos_url":"https://api.github.com/users/euoia/repos","events_url":"https://api.github.com/users/euoia/events{/privacy}","received_events_url":"https://api.github.com/users/euoia/received_events","type":"User","site_admin":false},"created_at":"2015-08-29T13:29:41Z","updated_at":"2015-08-29T13:29:41Z","body":"Oh, I didn't realise you can do that. That's useful, thanks.\r\n\r\nI completely agree that predicates should never throw. It seems like for now special casing instance might be the best solution.\r\n\r\nThanks again for taking the time to respond to this."}}