{"url":"https://api.github.com/gists/1365279","forks_url":"https://api.github.com/gists/1365279/forks","commits_url":"https://api.github.com/gists/1365279/commits","id":"1365279","node_id":"MDQ6R2lzdDEzNjUyNzk=","git_pull_url":"https://gist.github.com/1365279.git","git_push_url":"https://gist.github.com/1365279.git","html_url":"https://gist.github.com/mbostock/1365279","files":{"adopt.diff":{"filename":"adopt.diff","type":"text/plain","language":"Diff","raw_url":"https://gist.githubusercontent.com/mbostock/1365279/raw/26475e2aba29f673049f70066438a7d599d8eab3/adopt.diff","size":1978,"truncated":false,"content":"diff --git a/src/core/create.js b/src/core/create.js\nnew file mode 100644\nindex 0000000..a284a67\n--- /dev/null\n+++ b/src/core/create.js\n@@ -0,0 +1,5 @@\n+d3.create = function(name) {\n+  return d3.select((name = d3.ns.qualify(name)).local\n+      ? document.createElementNS(name.space, name.local)\n+      : document.createElement(name));\n+};\ndiff --git a/src/core/selection-adopt.js b/src/core/selection-adopt.js\nnew file mode 100644\nindex 0000000..d7eb884\n--- /dev/null\n+++ b/src/core/selection-adopt.js\n@@ -0,0 +1,5 @@\n+d3_selectionPrototype.adopt = function(selection) {\n+  return this.select(function(d, i, j) {\n+    return (d = selection[i]) && (d = d[j]) && this.appendChild(d);\n+  });\n+};\ndiff --git a/src/core/selection-select.js b/src/core/selection-select.js\nindex fea22b5..d7a65df 100644\n--- a/src/core/selection-select.js\n+++ b/src/core/selection-select.js\n@@ -12,7 +12,7 @@ d3_selectionPrototype.select = function(selector) {\n     subgroup.parentNode = (group = this[j]).parentNode;\n     for (var i = -1, n = group.length; ++i < n;) {\n       if (node = group[i]) {\n-        subgroup.push(subnode = selector.call(node, node.__data__, i));\n+        subgroup.push(subnode = selector.call(node, node.__data__, i, j));\n         if (subnode && \"__data__\" in node) subnode.__data__ = node.__data__;\n       } else {\n         subgroup.push(null);\ndiff --git a/src/core/selection-selectAll.js b/src/core/selection-selectAll.js\nindex c133c63..fb58ce0 100644\n--- a/src/core/selection-selectAll.js\n+++ b/src/core/selection-selectAll.js\n@@ -8,7 +8,7 @@ d3_selectionPrototype.selectAll = function(selector) {\n   for (var j = -1, m = this.length; ++j < m;) {\n     for (var group = this[j], i = -1, n = group.length; ++i < n;) {\n       if (node = group[i]) {\n-        subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i)));\n+        subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));\n         subgroup.parentNode = node;\n       }\n     }\n","encoding":"utf-8"}},"public":true,"created_at":"2011-11-14T21:45:23Z","updated_at":"2015-09-28T01:48:21Z","description":"d3.create + selection.adopt","comments":0,"user":null,"comments_enabled":true,"comments_url":"https://api.github.com/gists/1365279/comments","owner":{"login":"mbostock","id":230541,"node_id":"MDQ6VXNlcjIzMDU0MQ==","avatar_url":"https://avatars.githubusercontent.com/u/230541?v=4","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","user_view_type":"public","site_admin":false},"forks":[],"history":[{"user":{"login":"mbostock","id":230541,"node_id":"MDQ6VXNlcjIzMDU0MQ==","avatar_url":"https://avatars.githubusercontent.com/u/230541?v=4","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","user_view_type":"public","site_admin":false},"version":"ba21b030bc7d696071954202d8f8d0a751a1a885","committed_at":"2011-11-14T21:45:23Z","change_status":{"total":48,"additions":48,"deletions":0},"url":"https://api.github.com/gists/1365279/ba21b030bc7d696071954202d8f8d0a751a1a885"}],"truncated":false}