{"action":"opened","issue":{"url":"https://api.github.com/repos/canjs/canjs/issues/2371","repository_url":"https://api.github.com/repos/canjs/canjs","labels_url":"https://api.github.com/repos/canjs/canjs/issues/2371/labels{/name}","comments_url":"https://api.github.com/repos/canjs/canjs/issues/2371/comments","events_url":"https://api.github.com/repos/canjs/canjs/issues/2371/events","html_url":"https://github.com/canjs/canjs/issues/2371","id":148728049,"number":2371,"title":"Clarify canjs' dependency on the DOM","user":{"login":"matthewp","id":361671,"avatar_url":"https://avatars.githubusercontent.com/u/361671?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewp","html_url":"https://github.com/matthewp","followers_url":"https://api.github.com/users/matthewp/followers","following_url":"https://api.github.com/users/matthewp/following{/other_user}","gists_url":"https://api.github.com/users/matthewp/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewp/subscriptions","organizations_url":"https://api.github.com/users/matthewp/orgs","repos_url":"https://api.github.com/users/matthewp/repos","events_url":"https://api.github.com/users/matthewp/events{/privacy}","received_events_url":"https://api.github.com/users/matthewp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-15T18:07:30Z","updated_at":"2016-04-15T18:07:30Z","closed_at":null,"body":"This issue is about what canjs' dependency on the DOM will be in 3.0. For the sake of language let's break out the various types of dependencies:\r\n\r\n* Implicit global dependencies\r\n* Explicit module loader dependencies\r\n* Run-time dependencies (aka when you call `stache(template)` )\r\n\r\nMy motivation for this issue is server-side rendering. Currently we force jquery to be a global and depend on `can/util/vdom/vdom` in order to load in SSR.  This makes it very hard to provide the ability for users to swap out DOM implementations.\r\n\r\nHere's a few options for how to address this:\r\n\r\n## No load-time dependency\r\n\r\nBest case scenario is that canjs doesn't need a DOM to load its code. Currently it does feature detection [here for example](https://github.com/canjs/canjs/blob/e0c3f0897fd7c5dd57626b0e72f7552174206557/view/target/target.js#L30). It May not be practical to remove this, I suspect can/util will always do this sort of thing..\r\n\r\nBut if not it would be very nice, because you could just set `can.document` to provide a DOM.\r\n\r\n## Depend on a module that provides a document\r\n\r\nWe could have a `can-document` that by default loads (what is currently `can/util/vdom/vdom`) and is provided as the document. In Node this is what you need, and in browsers you could provide a map for your module loader (the `browser` field in package.json should cover most cases)\r\n\r\n## Continue to implicitly depend on a global document\r\n\r\nIf we leave things the way it works now users could still do something like (in Node):\r\n\r\n```\r\nglobal.document = require(\"some-dom\");\r\nvar can = require(\"can\");\r\n```"}}