{"action":"created","issue":{"url":"https://api.github.com/repos/videojs/video.js/issues/2037","labels_url":"https://api.github.com/repos/videojs/video.js/issues/2037/labels{/name}","comments_url":"https://api.github.com/repos/videojs/video.js/issues/2037/comments","events_url":"https://api.github.com/repos/videojs/video.js/issues/2037/events","html_url":"https://github.com/videojs/video.js/issues/2037","id":68614700,"number":2037,"title":"Window.xd instanceof test in min version","user":{"login":"snichini","id":1984452,"avatar_url":"https://avatars.githubusercontent.com/u/1984452?v=3","gravatar_id":"","url":"https://api.github.com/users/snichini","html_url":"https://github.com/snichini","followers_url":"https://api.github.com/users/snichini/followers","following_url":"https://api.github.com/users/snichini/following{/other_user}","gists_url":"https://api.github.com/users/snichini/gists{/gist_id}","starred_url":"https://api.github.com/users/snichini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snichini/subscriptions","organizations_url":"https://api.github.com/users/snichini/orgs","repos_url":"https://api.github.com/users/snichini/repos","events_url":"https://api.github.com/users/snichini/events{/privacy}","received_events_url":"https://api.github.com/users/snichini/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-15T08:37:08Z","updated_at":"2015-04-15T15:14:57Z","closed_at":null,"body":"Hello,\r\n\r\nWe encounter a problem during our testing with others javascript libraries.\r\n\r\nWe got an error raised by the setting and testing of the TOUCH_ENABLED property of videojs in the min version of videojs (4.12.5).\r\n\r\n```\r\nUncaught TypeError: Expecting a function in instanceof check, but got #<HTMLDocument>\r\n```\r\n\r\nin the dev version we have in the 4.12.5 on line 1108:\r\n```javascript\r\nvjs.TOUCH_ENABLED = !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch);\r\n``` \r\n\r\nIn the min version on line 17:\r\n```javascript\r\nt.Eb=!!(\"ontouchstart\"in window||window.xd&&document instanceof window.xd);\r\n```\r\nThe dev version works well because test property DocumentTouch is not override by the other javascript libraries.\r\n\r\nIn the min version, the \"window.DocumentTouch\" is changed to \"window.xd\".\r\nWe also could not understand where the \"window.xd\" was set in the code or maybe it's a known alias for the DocumentTouch property.\r\nAnyway, the problem here is that there is no test on the nature of window.xd. And \"instanceof\" accepts only a \"function\" type to test against.\r\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof\r\n\r\nSo we added the typeof function to ensure the nature of window.xd: \r\n```javacript\r\ntypeof window.xd == \"function\"\r\n```\r\n\r\nSo we have now this for the min version : \r\n```javascript\r\nt.Eb=!!(\"ontouchstart\"in window||window.xd&&typeof window.xd == \"function\" && document instanceof window.xd);\r\n```\r\nand for the dev version :\r\n```javascript\r\nvjs.TOUCH_ENABLED = !!(('ontouchstart' in window) || window.DocumentTouch && typeof window.DocumentTouch == \"function\" && document instanceof window.DocumentTouch);\r\n```\r\n\r\nMaybe we are wrong but I think this ensure a better testing of this window property\r\nThis fix helps us using the min version of videojs and solve the problem.\r\n\r\nThanks !"},"comment":{"url":"https://api.github.com/repos/videojs/video.js/issues/comments/93442650","html_url":"https://github.com/videojs/video.js/issues/2037#issuecomment-93442650","issue_url":"https://api.github.com/repos/videojs/video.js/issues/2037","id":93442650,"user":{"login":"gkatsev","id":535884,"avatar_url":"https://avatars.githubusercontent.com/u/535884?v=3","gravatar_id":"","url":"https://api.github.com/users/gkatsev","html_url":"https://github.com/gkatsev","followers_url":"https://api.github.com/users/gkatsev/followers","following_url":"https://api.github.com/users/gkatsev/following{/other_user}","gists_url":"https://api.github.com/users/gkatsev/gists{/gist_id}","starred_url":"https://api.github.com/users/gkatsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkatsev/subscriptions","organizations_url":"https://api.github.com/users/gkatsev/orgs","repos_url":"https://api.github.com/users/gkatsev/repos","events_url":"https://api.github.com/users/gkatsev/events{/privacy}","received_events_url":"https://api.github.com/users/gkatsev/received_events","type":"User","site_admin":false},"created_at":"2015-04-15T15:14:57Z","updated_at":"2015-04-15T15:14:57Z","body":"This is a minifcation issue. What happens is that Closure Compiler's advanced compliation mode that we currently use mangles all dot-accessed names. So, `window.DocumentTouch` gets changed to `window.xd` even though we don't want it to. We probably should release a patch for the current version that updates this line to read:\r\n```js\r\nvjs.TOUCH_ENABLED = !!(('ontouchstart' in window) || window['DocumentTouch' && document instanceof window['DocumentTouch']);\r\n```\r\nAlso, we're removing Closure Compiler and using uglify in a forthcoming version of videojs, so, hopefully, we won't have this issue in the future."}}