{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/1473","labels_url":"https://api.github.com/repos/facebook/react-native/issues/1473/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/1473/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/1473/events","html_url":"https://github.com/facebook/react-native/issues/1473","id":83197101,"number":1473,"title":"[JS] Remove the global `document` variable","user":{"login":"oveddan","id":891755,"avatar_url":"https://avatars.githubusercontent.com/u/891755?v=3","gravatar_id":"","url":"https://api.github.com/users/oveddan","html_url":"https://github.com/oveddan","followers_url":"https://api.github.com/users/oveddan/followers","following_url":"https://api.github.com/users/oveddan/following{/other_user}","gists_url":"https://api.github.com/users/oveddan/gists{/gist_id}","starred_url":"https://api.github.com/users/oveddan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oveddan/subscriptions","organizations_url":"https://api.github.com/users/oveddan/orgs","repos_url":"https://api.github.com/users/oveddan/repos","events_url":"https://api.github.com/users/oveddan/events{/privacy}","received_events_url":"https://api.github.com/users/oveddan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-31T21:42:06Z","updated_at":"2015-06-08T15:55:33Z","closed_at":null,"body":"Having a global `document` variable without implementing all of its methods causes interop issues with other libraries that expect the global document to have those methods, if it exists.\r\n\r\nThis occurs, for example, when trying to require `jquery`, and it sees a global document and attempts to call `createElement` on it.  Use case and explaination of issue can be seen [here](https://github.com/jquery/jquery/issues/2349).\r\n\r\nAccording to @vjeux  \r\n> There is no good reason for react-native to have a global document variable with just a single key createElement: null. We need to remove document altogether, it was added as a workaround very early in the project and is not needed anymore.\r\n\r\nTherefore it seems the best solution would be to not attach the `react-native` specific document to global."},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/110052007","html_url":"https://github.com/facebook/react-native/issues/1473#issuecomment-110052007","issue_url":"https://api.github.com/repos/facebook/react-native/issues/1473","id":110052007,"user":{"login":"oveddan","id":891755,"avatar_url":"https://avatars.githubusercontent.com/u/891755?v=3","gravatar_id":"","url":"https://api.github.com/users/oveddan","html_url":"https://github.com/oveddan","followers_url":"https://api.github.com/users/oveddan/followers","following_url":"https://api.github.com/users/oveddan/following{/other_user}","gists_url":"https://api.github.com/users/oveddan/gists{/gist_id}","starred_url":"https://api.github.com/users/oveddan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oveddan/subscriptions","organizations_url":"https://api.github.com/users/oveddan/orgs","repos_url":"https://api.github.com/users/oveddan/repos","events_url":"https://api.github.com/users/oveddan/events{/privacy}","received_events_url":"https://api.github.com/users/oveddan/received_events","type":"User","site_admin":false},"created_at":"2015-06-08T15:55:33Z","updated_at":"2015-06-08T15:55:33Z","body":"@vjeux @spicyj I dug around for a while - we don't set GLOBAL or window.document anywhere, even in [InitializeJavaScriptAppEngine.js](https://github.com/facebook/react-native/blob/d796584b6c8122ecf6fc6f0de7f82131b2ed51d1/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js)\r\nAll that we do with global.document is [set createElement to null](https://github.com/facebook/react-native/blob/d796584b6c8122ecf6fc6f0de7f82131b2ed51d1/Libraries/JavaScriptAppEngine/polyfills/document.js#L28)\r\n\r\nI tried running `window.document = undefined;` but it doesn't work. This is because [window.document is a read method](https://developer.mozilla.org/en-US/docs/Web/API/Window/document).\r\n\r\nIf you try in the chrome or safari console to run the code:\r\n```javascript\r\nwindow.document = undefined;\r\nwindow.document;\r\n```\r\n\r\nYou will see that window.document still returns the document.\r\n\r\nThe better solution would not to override `document.createElement` to be null.  "}}