{"action":"created","comment":{"url":"https://api.github.com/repos/StileEducation/Squire/pulls/comments/31684167","id":31684167,"diff_hunk":"@@ -2104,26 +2142,33 @@ var keyHandlers = {\n         // Test conditions for selection being at the start of the textnode.\n         var validNodes = !!(anchorNode && anchorPreviousNode);\n         var caretAtStartOfNode = selection.anchorOffset === 0;\n-\n+        var isMathjaxIOS, isMathjaxIE, isMathjax;\n         // Test is SPAN and has mathjax class.\n-        var isMathjaxIOS = !!(validNodes && anchorPreviousNode.webkitMatchesSelector && anchorPreviousNode.webkitMatchesSelector('span.mathjax'));\n-        var isMathjaxIE = !!(validNodes && anchorPreviousNode.msMatchesSelector && anchorPreviousNode.msMatchesSelector('span.mathjax'));\n-        var isMathjax  = !!(validNodes && anchorPreviousNode.matches && anchorPreviousNode.matches('span.mathjax'));\n+        isMathjaxIOS = !!(validNodes && anchorPreviousNode.webkitMatchesSelector && anchorPreviousNode.webkitMatchesSelector('span.mathjax'));\n+        isMathjaxIE = !!(validNodes && anchorPreviousNode.msMatchesSelector && anchorPreviousNode.msMatchesSelector('span.mathjax'));\n+        isMathjax  = !!(validNodes && anchorPreviousNode.matches && anchorPreviousNode.matches('span.mathjax'));\n+\n+        // create a range to set the selection to.\n+        var leftRange = self._doc.createRange();\n \n         if (caretAtStartOfNode && (isMathjax || isMathjaxIE || isMathjaxIOS)) {\n             // this is a mathjax equation, prevent defualt.\n             event.preventDefault();\n \n             // create a new range\n-            var leftRange = self._doc.createRange();\n             leftRange.setStartBefore(anchorPreviousNode);\n             leftRange.setEndBefore(anchorPreviousNode);\n-            \n+\n+            if (isGecko && anchorPreviousNode.previousSibling && anchorPreviousNode.previousSibling.textContent) {\n+                var beforePreviousNode = anchorPreviousNode.previousSibling;\n+                leftRange.setStart(beforePreviousNode, beforePreviousNode.textContent.length);\n+                leftRange.setEnd(beforePreviousNode, beforePreviousNode.textContent.length);\n+            }\n+\n             // set a selection.\n             self.setSelection(leftRange);\n+            return;","path":"source/Editor.js","position":87,"original_position":87,"commit_id":"3bb273cc13d22c0a9b7062eeee39f8c7843b0ced","original_commit_id":"3bb273cc13d22c0a9b7062eeee39f8c7843b0ced","user":{"login":"KJTsanaktsidis","id":1418177,"avatar_url":"https://avatars.githubusercontent.com/u/1418177?v=3","gravatar_id":"","url":"https://api.github.com/users/KJTsanaktsidis","html_url":"https://github.com/KJTsanaktsidis","followers_url":"https://api.github.com/users/KJTsanaktsidis/followers","following_url":"https://api.github.com/users/KJTsanaktsidis/following{/other_user}","gists_url":"https://api.github.com/users/KJTsanaktsidis/gists{/gist_id}","starred_url":"https://api.github.com/users/KJTsanaktsidis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KJTsanaktsidis/subscriptions","organizations_url":"https://api.github.com/users/KJTsanaktsidis/orgs","repos_url":"https://api.github.com/users/KJTsanaktsidis/repos","events_url":"https://api.github.com/users/KJTsanaktsidis/events{/privacy}","received_events_url":"https://api.github.com/users/KJTsanaktsidis/received_events","type":"User","site_admin":false},"body":"This looks pretty redundant","created_at":"2015-06-04T00:20:44Z","updated_at":"2015-06-04T00:20:44Z","html_url":"https://github.com/StileEducation/Squire/pull/11#discussion_r31684167","pull_request_url":"https://api.github.com/repos/StileEducation/Squire/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/StileEducation/Squire/pulls/comments/31684167"},"html":{"href":"https://github.com/StileEducation/Squire/pull/11#discussion_r31684167"},"pull_request":{"href":"https://api.github.com/repos/StileEducation/Squire/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/StileEducation/Squire/pulls/11","id":36823344,"html_url":"https://github.com/StileEducation/Squire/pull/11","diff_url":"https://github.com/StileEducation/Squire/pull/11.diff","patch_url":"https://github.com/StileEducation/Squire/pull/11.patch","issue_url":"https://api.github.com/repos/StileEducation/Squire/issues/11","number":11,"state":"open","locked":false,"title":"Fix Firefox Bugs","user":{"login":"matthewborden","id":2132506,"avatar_url":"https://avatars.githubusercontent.com/u/2132506?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewborden","html_url":"https://github.com/matthewborden","followers_url":"https://api.github.com/users/matthewborden/followers","following_url":"https://api.github.com/users/matthewborden/following{/other_user}","gists_url":"https://api.github.com/users/matthewborden/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewborden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewborden/subscriptions","organizations_url":"https://api.github.com/users/matthewborden/orgs","repos_url":"https://api.github.com/users/matthewborden/repos","events_url":"https://api.github.com/users/matthewborden/events{/privacy}","received_events_url":"https://api.github.com/users/matthewborden/received_events","type":"User","site_admin":false},"body":"Fix Firefox issues:\r\n- Not being able to use arrow keys to navigate past equations.\r\n- Fix backspace (again, firefox wasn't buying into any of the old hacks).","created_at":"2015-06-03T11:39:17Z","updated_at":"2015-06-04T00:20:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"65fce3deff5af16b7ce8bab642eaa544a6c17394","assignee":{"login":"KJTsanaktsidis","id":1418177,"avatar_url":"https://avatars.githubusercontent.com/u/1418177?v=3","gravatar_id":"","url":"https://api.github.com/users/KJTsanaktsidis","html_url":"https://github.com/KJTsanaktsidis","followers_url":"https://api.github.com/users/KJTsanaktsidis/followers","following_url":"https://api.github.com/users/KJTsanaktsidis/following{/other_user}","gists_url":"https://api.github.com/users/KJTsanaktsidis/gists{/gist_id}","starred_url":"https://api.github.com/users/KJTsanaktsidis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KJTsanaktsidis/subscriptions","organizations_url":"https://api.github.com/users/KJTsanaktsidis/orgs","repos_url":"https://api.github.com/users/KJTsanaktsidis/repos","events_url":"https://api.github.com/users/KJTsanaktsidis/events{/privacy}","received_events_url":"https://api.github.com/users/KJTsanaktsidis/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/StileEducation/Squire/pulls/11/commits","review_comments_url":"https://api.github.com/repos/StileEducation/Squire/pulls/11/comments","review_comment_url":"https://api.github.com/repos/StileEducation/Squire/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StileEducation/Squire/issues/11/comments","statuses_url":"https://api.github.com/repos/StileEducation/Squire/statuses/3bb273cc13d22c0a9b7062eeee39f8c7843b0ced","head":{"label":"StileEducation:fix-firefox-hell","ref":"fix-firefox-hell","sha":"3bb273cc13d22c0a9b7062eeee39f8c7843b0ced","user":{"login":"StileEducation","id":2775114,"avatar_url":"https://avatars.githubusercontent.com/u/2775114?v=3","gravatar_id":"","url":"https://api.github.com/users/StileEducation","html_url":"https://github.com/StileEducation","followers_url":"https://api.github.com/users/StileEducation/followers","following_url":"https://api.github.com/users/StileEducation/following{/other_user}","gists_url":"https://api.github.com/users/StileEducation/gists{/gist_id}","starred_url":"https://api.github.com/users/StileEducation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StileEducation/subscriptions","organizations_url":"https://api.github.com/users/StileEducation/orgs","repos_url":"https://api.github.com/users/StileEducation/repos","events_url":"https://api.github.com/users/StileEducation/events{/privacy}","received_events_url":"https://api.github.com/users/StileEducation/received_events","type":"Organization","site_admin":false},"repo":{"id":31943870,"name":"Squire","full_name":"StileEducation/Squire","owner":{"login":"StileEducation","id":2775114,"avatar_url":"https://avatars.githubusercontent.com/u/2775114?v=3","gravatar_id":"","url":"https://api.github.com/users/StileEducation","html_url":"https://github.com/StileEducation","followers_url":"https://api.github.com/users/StileEducation/followers","following_url":"https://api.github.com/users/StileEducation/following{/other_user}","gists_url":"https://api.github.com/users/StileEducation/gists{/gist_id}","starred_url":"https://api.github.com/users/StileEducation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StileEducation/subscriptions","organizations_url":"https://api.github.com/users/StileEducation/orgs","repos_url":"https://api.github.com/users/StileEducation/repos","events_url":"https://api.github.com/users/StileEducation/events{/privacy}","received_events_url":"https://api.github.com/users/StileEducation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StileEducation/Squire","description":"HTML5 rich text editor. Try the demo integration at","fork":true,"url":"https://api.github.com/repos/StileEducation/Squire","forks_url":"https://api.github.com/repos/StileEducation/Squire/forks","keys_url":"https://api.github.com/repos/StileEducation/Squire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StileEducation/Squire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StileEducation/Squire/teams","hooks_url":"https://api.github.com/repos/StileEducation/Squire/hooks","issue_events_url":"https://api.github.com/repos/StileEducation/Squire/issues/events{/number}","events_url":"https://api.github.com/repos/StileEducation/Squire/events","assignees_url":"https://api.github.com/repos/StileEducation/Squire/assignees{/user}","branches_url":"https://api.github.com/repos/StileEducation/Squire/branches{/branch}","tags_url":"https://api.github.com/repos/StileEducation/Squire/tags","blobs_url":"https://api.github.com/repos/StileEducation/Squire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StileEducation/Squire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StileEducation/Squire/git/refs{/sha}","trees_url":"https://api.github.com/repos/StileEducation/Squire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StileEducation/Squire/statuses/{sha}","languages_url":"https://api.github.com/repos/StileEducation/Squire/languages","stargazers_url":"https://api.github.com/repos/StileEducation/Squire/stargazers","contributors_url":"https://api.github.com/repos/StileEducation/Squire/contributors","subscribers_url":"https://api.github.com/repos/StileEducation/Squire/subscribers","subscription_url":"https://api.github.com/repos/StileEducation/Squire/subscription","commits_url":"https://api.github.com/repos/StileEducation/Squire/commits{/sha}","git_commits_url":"https://api.github.com/repos/StileEducation/Squire/git/commits{/sha}","comments_url":"https://api.github.com/repos/StileEducation/Squire/comments{/number}","issue_comment_url":"https://api.github.com/repos/StileEducation/Squire/issues/comments{/number}","contents_url":"https://api.github.com/repos/StileEducation/Squire/contents/{+path}","compare_url":"https://api.github.com/repos/StileEducation/Squire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StileEducation/Squire/merges","archive_url":"https://api.github.com/repos/StileEducation/Squire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StileEducation/Squire/downloads","issues_url":"https://api.github.com/repos/StileEducation/Squire/issues{/number}","pulls_url":"https://api.github.com/repos/StileEducation/Squire/pulls{/number}","milestones_url":"https://api.github.com/repos/StileEducation/Squire/milestones{/number}","notifications_url":"https://api.github.com/repos/StileEducation/Squire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StileEducation/Squire/labels{/name}","releases_url":"https://api.github.com/repos/StileEducation/Squire/releases{/id}","created_at":"2015-03-10T07:26:41Z","updated_at":"2015-05-06T00:11:57Z","pushed_at":"2015-06-03T11:39:18Z","git_url":"git://github.com/StileEducation/Squire.git","ssh_url":"git@github.com:StileEducation/Squire.git","clone_url":"https://github.com/StileEducation/Squire.git","svn_url":"https://github.com/StileEducation/Squire","homepage":"http://neilj.github.io/Squire/","size":2025,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"StileEducation:master","ref":"master","sha":"126d40ed4d8198b642570dc4f9758f3440a29b09","user":{"login":"StileEducation","id":2775114,"avatar_url":"https://avatars.githubusercontent.com/u/2775114?v=3","gravatar_id":"","url":"https://api.github.com/users/StileEducation","html_url":"https://github.com/StileEducation","followers_url":"https://api.github.com/users/StileEducation/followers","following_url":"https://api.github.com/users/StileEducation/following{/other_user}","gists_url":"https://api.github.com/users/StileEducation/gists{/gist_id}","starred_url":"https://api.github.com/users/StileEducation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StileEducation/subscriptions","organizations_url":"https://api.github.com/users/StileEducation/orgs","repos_url":"https://api.github.com/users/StileEducation/repos","events_url":"https://api.github.com/users/StileEducation/events{/privacy}","received_events_url":"https://api.github.com/users/StileEducation/received_events","type":"Organization","site_admin":false},"repo":{"id":31943870,"name":"Squire","full_name":"StileEducation/Squire","owner":{"login":"StileEducation","id":2775114,"avatar_url":"https://avatars.githubusercontent.com/u/2775114?v=3","gravatar_id":"","url":"https://api.github.com/users/StileEducation","html_url":"https://github.com/StileEducation","followers_url":"https://api.github.com/users/StileEducation/followers","following_url":"https://api.github.com/users/StileEducation/following{/other_user}","gists_url":"https://api.github.com/users/StileEducation/gists{/gist_id}","starred_url":"https://api.github.com/users/StileEducation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StileEducation/subscriptions","organizations_url":"https://api.github.com/users/StileEducation/orgs","repos_url":"https://api.github.com/users/StileEducation/repos","events_url":"https://api.github.com/users/StileEducation/events{/privacy}","received_events_url":"https://api.github.com/users/StileEducation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StileEducation/Squire","description":"HTML5 rich text editor. Try the demo integration at","fork":true,"url":"https://api.github.com/repos/StileEducation/Squire","forks_url":"https://api.github.com/repos/StileEducation/Squire/forks","keys_url":"https://api.github.com/repos/StileEducation/Squire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StileEducation/Squire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StileEducation/Squire/teams","hooks_url":"https://api.github.com/repos/StileEducation/Squire/hooks","issue_events_url":"https://api.github.com/repos/StileEducation/Squire/issues/events{/number}","events_url":"https://api.github.com/repos/StileEducation/Squire/events","assignees_url":"https://api.github.com/repos/StileEducation/Squire/assignees{/user}","branches_url":"https://api.github.com/repos/StileEducation/Squire/branches{/branch}","tags_url":"https://api.github.com/repos/StileEducation/Squire/tags","blobs_url":"https://api.github.com/repos/StileEducation/Squire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StileEducation/Squire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StileEducation/Squire/git/refs{/sha}","trees_url":"https://api.github.com/repos/StileEducation/Squire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StileEducation/Squire/statuses/{sha}","languages_url":"https://api.github.com/repos/StileEducation/Squire/languages","stargazers_url":"https://api.github.com/repos/StileEducation/Squire/stargazers","contributors_url":"https://api.github.com/repos/StileEducation/Squire/contributors","subscribers_url":"https://api.github.com/repos/StileEducation/Squire/subscribers","subscription_url":"https://api.github.com/repos/StileEducation/Squire/subscription","commits_url":"https://api.github.com/repos/StileEducation/Squire/commits{/sha}","git_commits_url":"https://api.github.com/repos/StileEducation/Squire/git/commits{/sha}","comments_url":"https://api.github.com/repos/StileEducation/Squire/comments{/number}","issue_comment_url":"https://api.github.com/repos/StileEducation/Squire/issues/comments{/number}","contents_url":"https://api.github.com/repos/StileEducation/Squire/contents/{+path}","compare_url":"https://api.github.com/repos/StileEducation/Squire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StileEducation/Squire/merges","archive_url":"https://api.github.com/repos/StileEducation/Squire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StileEducation/Squire/downloads","issues_url":"https://api.github.com/repos/StileEducation/Squire/issues{/number}","pulls_url":"https://api.github.com/repos/StileEducation/Squire/pulls{/number}","milestones_url":"https://api.github.com/repos/StileEducation/Squire/milestones{/number}","notifications_url":"https://api.github.com/repos/StileEducation/Squire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StileEducation/Squire/labels{/name}","releases_url":"https://api.github.com/repos/StileEducation/Squire/releases{/id}","created_at":"2015-03-10T07:26:41Z","updated_at":"2015-05-06T00:11:57Z","pushed_at":"2015-06-03T11:39:18Z","git_url":"git://github.com/StileEducation/Squire.git","ssh_url":"git@github.com:StileEducation/Squire.git","clone_url":"https://github.com/StileEducation/Squire.git","svn_url":"https://github.com/StileEducation/Squire","homepage":"http://neilj.github.io/Squire/","size":2025,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StileEducation/Squire/pulls/11"},"html":{"href":"https://github.com/StileEducation/Squire/pull/11"},"issue":{"href":"https://api.github.com/repos/StileEducation/Squire/issues/11"},"comments":{"href":"https://api.github.com/repos/StileEducation/Squire/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/StileEducation/Squire/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/StileEducation/Squire/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StileEducation/Squire/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/StileEducation/Squire/statuses/3bb273cc13d22c0a9b7062eeee39f8c7843b0ced"}}}}