aboutsummaryrefslogtreecommitdiff
path: root/src/content/components/common
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-25 11:48:08 +0000
committerGitHub <noreply@github.com>2017-10-25 11:48:08 +0000
commitc6f380135d93ffecb192d30d7323888eb3d051f3 (patch)
tree1915cb4f3170fbf6c559b108a762b711177c62a3 /src/content/components/common
parentccc81312a1d4d9a5cea7d7451c26ec25b2172aa8 (diff)
parenta4b86bf3a06c9f4e78bd5a714ae4673066a2f23f (diff)
Merge pull request #93 from ueokande/improve-for-certain-pages
Improve for aberration pages
Diffstat (limited to 'src/content/components/common')
-rw-r--r--src/content/components/common/follow.js10
-rw-r--r--src/content/components/common/input.js10
2 files changed, 13 insertions, 7 deletions
diff --git a/src/content/components/common/follow.js b/src/content/components/common/follow.js
index 5688da3..65e0af9 100644
--- a/src/content/components/common/follow.js
+++ b/src/content/components/common/follow.js
@@ -1,9 +1,10 @@
import messages from 'shared/messages';
import Hint from './hint';
+import * as dom from 'shared/utils/dom';
const TARGET_SELECTOR = [
'a', 'button', 'input', 'textarea',
- '[contenteditable=true]', '[contenteditable=""]'
+ '[contenteditable=true]', '[contenteditable=""]', '[tabindex]'
].join(',');
const inViewport = (win, element, viewSize, framePosition) => {
@@ -136,8 +137,11 @@ export default class Follow {
case 'button':
return element.click();
default:
- // it may contenteditable
- return element.focus();
+ if (dom.isContentEditable(element)) {
+ return element.focus();
+ } else if (element.hasAttribute('tabindex')) {
+ return element.click();
+ }
}
}
diff --git a/src/content/components/common/input.js b/src/content/components/common/input.js
index f285b0c..ef5af29 100644
--- a/src/content/components/common/input.js
+++ b/src/content/components/common/input.js
@@ -1,3 +1,5 @@
+import * as dom from 'shared/utils/dom';
+
const modifierdKeyName = (name) => {
if (name.length === 1) {
return name.toUpperCase();
@@ -78,12 +80,12 @@ export default class InputComponent {
}
fromInput(e) {
+ if (!e.target) {
+ return false;
+ }
return e.target instanceof HTMLInputElement ||
e.target instanceof HTMLTextAreaElement ||
e.target instanceof HTMLSelectElement ||
- e.target instanceof HTMLElement &&
- e.target.hasAttribute('contenteditable') && (
- e.target.getAttribute('contenteditable').toLowerCase() === 'true' ||
- e.target.getAttribute('contenteditable').toLowerCase() === '');
+ dom.isContentEditable(e.target);
}
}