{"action":"created","comment":{"url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/comments/189767391","pull_request_review_id":122008610,"id":189767391,"diff_hunk":"@@ -163,8 +163,5 @@ export const findPositionOfNodeBefore = selection => {\n // ```\n export const findDomRefAtPos = (position, domAtPos) => {\n   const dom = domAtPos(position);\n-  if (dom.offset > 0) {\n-    return dom.node.childNodes[dom.offset - 1];\n-  }\n-  return dom.node;\n+  return dom.node.childNodes[dom.offset];","path":"src/selection.js","position":26,"original_position":26,"commit_id":"e17d3685666e2b924f15dd31acef73b980b2a9be","original_commit_id":"e17d3685666e2b924f15dd31acef73b980b2a9be","user":{"login":"5id","id":3411140,"avatar_url":"https://avatars3.githubusercontent.com/u/3411140?v=4","gravatar_id":"","url":"https://api.github.com/users/5id","html_url":"https://github.com/5id","followers_url":"https://api.github.com/users/5id/followers","following_url":"https://api.github.com/users/5id/following{/other_user}","gists_url":"https://api.github.com/users/5id/gists{/gist_id}","starred_url":"https://api.github.com/users/5id/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/5id/subscriptions","organizations_url":"https://api.github.com/users/5id/orgs","repos_url":"https://api.github.com/users/5id/repos","events_url":"https://api.github.com/users/5id/events{/privacy}","received_events_url":"https://api.github.com/users/5id/received_events","type":"User","site_admin":false},"body":"If we always want to return the dom ref (including the textnode) - then we could do\r\n```js\r\nconst node = dom.node.childNodes[dom.offset];\r\nreturn node ? node : dom.node\r\n```\r\n\r\nAs you noted, `node` will be undefined when `dom.node` points into a text node (at which point, the offset is the textOffset inside this node). If we care only about getting a `dom.node` for position (and we're not concerned about knowing the offset inside the text node, i.e. positoning a model at the cursor) this should work well :) ","created_at":"2018-05-22T03:06:50Z","updated_at":"2018-05-22T03:08:11Z","html_url":"https://github.com/atlassian/prosemirror-utils/pull/27#discussion_r189767391","pull_request_url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/comments/189767391"},"html":{"href":"https://github.com/atlassian/prosemirror-utils/pull/27#discussion_r189767391"},"pull_request":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27","id":189530900,"html_url":"https://github.com/atlassian/prosemirror-utils/pull/27","diff_url":"https://github.com/atlassian/prosemirror-utils/pull/27.diff","patch_url":"https://github.com/atlassian/prosemirror-utils/pull/27.patch","issue_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/27","number":27,"state":"open","locked":false,"title":"fix: always use offset in findDomRefAtPos","user":{"login":"eshvedai","id":26512812,"avatar_url":"https://avatars0.githubusercontent.com/u/26512812?v=4","gravatar_id":"","url":"https://api.github.com/users/eshvedai","html_url":"https://github.com/eshvedai","followers_url":"https://api.github.com/users/eshvedai/followers","following_url":"https://api.github.com/users/eshvedai/following{/other_user}","gists_url":"https://api.github.com/users/eshvedai/gists{/gist_id}","starred_url":"https://api.github.com/users/eshvedai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eshvedai/subscriptions","organizations_url":"https://api.github.com/users/eshvedai/orgs","repos_url":"https://api.github.com/users/eshvedai/repos","events_url":"https://api.github.com/users/eshvedai/events{/privacy}","received_events_url":"https://api.github.com/users/eshvedai/received_events","type":"User","site_admin":false},"body":"See #26 for more context","created_at":"2018-05-22T02:13:26Z","updated_at":"2018-05-22T03:08:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbc02a773ad02bf208dc0f63736d0eb00b3a9392","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27/commits","review_comments_url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27/comments","review_comment_url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/comments{/number}","comments_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/27/comments","statuses_url":"https://api.github.com/repos/atlassian/prosemirror-utils/statuses/e17d3685666e2b924f15dd31acef73b980b2a9be","head":{"label":"atlassian:findDomRefAtPos-fix","ref":"findDomRefAtPos-fix","sha":"e17d3685666e2b924f15dd31acef73b980b2a9be","user":{"login":"atlassian","id":168166,"avatar_url":"https://avatars3.githubusercontent.com/u/168166?v=4","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"repo":{"id":123996637,"name":"prosemirror-utils","full_name":"atlassian/prosemirror-utils","owner":{"login":"atlassian","id":168166,"avatar_url":"https://avatars3.githubusercontent.com/u/168166?v=4","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atlassian/prosemirror-utils","description":"⚒ Utils library for ProseMirror","fork":false,"url":"https://api.github.com/repos/atlassian/prosemirror-utils","forks_url":"https://api.github.com/repos/atlassian/prosemirror-utils/forks","keys_url":"https://api.github.com/repos/atlassian/prosemirror-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atlassian/prosemirror-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atlassian/prosemirror-utils/teams","hooks_url":"https://api.github.com/repos/atlassian/prosemirror-utils/hooks","issue_events_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/events{/number}","events_url":"https://api.github.com/repos/atlassian/prosemirror-utils/events","assignees_url":"https://api.github.com/repos/atlassian/prosemirror-utils/assignees{/user}","branches_url":"https://api.github.com/repos/atlassian/prosemirror-utils/branches{/branch}","tags_url":"https://api.github.com/repos/atlassian/prosemirror-utils/tags","blobs_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atlassian/prosemirror-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/atlassian/prosemirror-utils/languages","stargazers_url":"https://api.github.com/repos/atlassian/prosemirror-utils/stargazers","contributors_url":"https://api.github.com/repos/atlassian/prosemirror-utils/contributors","subscribers_url":"https://api.github.com/repos/atlassian/prosemirror-utils/subscribers","subscription_url":"https://api.github.com/repos/atlassian/prosemirror-utils/subscription","commits_url":"https://api.github.com/repos/atlassian/prosemirror-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/atlassian/prosemirror-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/atlassian/prosemirror-utils/contents/{+path}","compare_url":"https://api.github.com/repos/atlassian/prosemirror-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atlassian/prosemirror-utils/merges","archive_url":"https://api.github.com/repos/atlassian/prosemirror-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atlassian/prosemirror-utils/downloads","issues_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues{/number}","pulls_url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/atlassian/prosemirror-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/atlassian/prosemirror-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atlassian/prosemirror-utils/labels{/name}","releases_url":"https://api.github.com/repos/atlassian/prosemirror-utils/releases{/id}","deployments_url":"https://api.github.com/repos/atlassian/prosemirror-utils/deployments","created_at":"2018-03-06T00:26:55Z","updated_at":"2018-05-19T15:11:58Z","pushed_at":"2018-05-22T02:13:26Z","git_url":"git://github.com/atlassian/prosemirror-utils.git","ssh_url":"git@github.com:atlassian/prosemirror-utils.git","clone_url":"https://github.com/atlassian/prosemirror-utils.git","svn_url":"https://github.com/atlassian/prosemirror-utils","homepage":"","size":134,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3,"open_issues":4,"watchers":21,"default_branch":"master"}},"base":{"label":"atlassian:master","ref":"master","sha":"f096f81239164c2c8401c523d1a4a34a8fec8397","user":{"login":"atlassian","id":168166,"avatar_url":"https://avatars3.githubusercontent.com/u/168166?v=4","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"repo":{"id":123996637,"name":"prosemirror-utils","full_name":"atlassian/prosemirror-utils","owner":{"login":"atlassian","id":168166,"avatar_url":"https://avatars3.githubusercontent.com/u/168166?v=4","gravatar_id":"","url":"https://api.github.com/users/atlassian","html_url":"https://github.com/atlassian","followers_url":"https://api.github.com/users/atlassian/followers","following_url":"https://api.github.com/users/atlassian/following{/other_user}","gists_url":"https://api.github.com/users/atlassian/gists{/gist_id}","starred_url":"https://api.github.com/users/atlassian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atlassian/subscriptions","organizations_url":"https://api.github.com/users/atlassian/orgs","repos_url":"https://api.github.com/users/atlassian/repos","events_url":"https://api.github.com/users/atlassian/events{/privacy}","received_events_url":"https://api.github.com/users/atlassian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atlassian/prosemirror-utils","description":"⚒ Utils library for ProseMirror","fork":false,"url":"https://api.github.com/repos/atlassian/prosemirror-utils","forks_url":"https://api.github.com/repos/atlassian/prosemirror-utils/forks","keys_url":"https://api.github.com/repos/atlassian/prosemirror-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atlassian/prosemirror-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atlassian/prosemirror-utils/teams","hooks_url":"https://api.github.com/repos/atlassian/prosemirror-utils/hooks","issue_events_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/events{/number}","events_url":"https://api.github.com/repos/atlassian/prosemirror-utils/events","assignees_url":"https://api.github.com/repos/atlassian/prosemirror-utils/assignees{/user}","branches_url":"https://api.github.com/repos/atlassian/prosemirror-utils/branches{/branch}","tags_url":"https://api.github.com/repos/atlassian/prosemirror-utils/tags","blobs_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atlassian/prosemirror-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/atlassian/prosemirror-utils/languages","stargazers_url":"https://api.github.com/repos/atlassian/prosemirror-utils/stargazers","contributors_url":"https://api.github.com/repos/atlassian/prosemirror-utils/contributors","subscribers_url":"https://api.github.com/repos/atlassian/prosemirror-utils/subscribers","subscription_url":"https://api.github.com/repos/atlassian/prosemirror-utils/subscription","commits_url":"https://api.github.com/repos/atlassian/prosemirror-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/atlassian/prosemirror-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/atlassian/prosemirror-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/comments{/number}","contents_url":"https://api.github.com/repos/atlassian/prosemirror-utils/contents/{+path}","compare_url":"https://api.github.com/repos/atlassian/prosemirror-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atlassian/prosemirror-utils/merges","archive_url":"https://api.github.com/repos/atlassian/prosemirror-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atlassian/prosemirror-utils/downloads","issues_url":"https://api.github.com/repos/atlassian/prosemirror-utils/issues{/number}","pulls_url":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/atlassian/prosemirror-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/atlassian/prosemirror-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atlassian/prosemirror-utils/labels{/name}","releases_url":"https://api.github.com/repos/atlassian/prosemirror-utils/releases{/id}","deployments_url":"https://api.github.com/repos/atlassian/prosemirror-utils/deployments","created_at":"2018-03-06T00:26:55Z","updated_at":"2018-05-19T15:11:58Z","pushed_at":"2018-05-22T02:13:26Z","git_url":"git://github.com/atlassian/prosemirror-utils.git","ssh_url":"git@github.com:atlassian/prosemirror-utils.git","clone_url":"https://github.com/atlassian/prosemirror-utils.git","svn_url":"https://github.com/atlassian/prosemirror-utils","homepage":"","size":134,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":3,"open_issues":4,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27"},"html":{"href":"https://github.com/atlassian/prosemirror-utils/pull/27"},"issue":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/27"},"comments":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/atlassian/prosemirror-utils/statuses/e17d3685666e2b924f15dd31acef73b980b2a9be"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"5id"}}