aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-23 20:10:05 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-23 20:10:05 +0900
commita57cdbd5b5f4efa94ecc61498fdb4039276f86f0 (patch)
treebbbb397223018d155fbe4e92bad5e681e78dff0b /src/content
parentccc81312a1d4d9a5cea7d7451c26ec25b2172aa8 (diff)
dom helper
Diffstat (limited to 'src/content')
-rw-r--r--src/content/components/common/follow.js6
-rw-r--r--src/content/components/common/input.js10
2 files changed, 10 insertions, 6 deletions
diff --git a/src/content/components/common/follow.js b/src/content/components/common/follow.js
index 5688da3..ce3d19c 100644
--- a/src/content/components/common/follow.js
+++ b/src/content/components/common/follow.js
@@ -1,5 +1,6 @@
import messages from 'shared/messages';
import Hint from './hint';
+import * as dom from 'shared/utils/dom';
const TARGET_SELECTOR = [
'a', 'button', 'input', 'textarea',
@@ -136,8 +137,9 @@ export default class Follow {
case 'button':
return element.click();
default:
- // it may contenteditable
- return element.focus();
+ if (dom.isContentEditable(element)) {
+ return element.focus();
+ }
}
}
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);
}
}