focus form items by following

This commit is contained in:
Shin'ya Ueoka 2017-09-17 18:21:07 +09:00
parent ba2022c465
commit 324cf32c5b
3 changed files with 33 additions and 19 deletions

View file

@ -125,20 +125,13 @@ export default class Follow {
}
static getTargetElements(doc) {
let all = doc.querySelectorAll('a');
let filtered = Array.prototype.filter.call(all, (e) => {
return Follow.isVisibleElement(e);
let all = doc.querySelectorAll('a,button,input,textarea');
let filtered = Array.prototype.filter.call(all, (element) => {
let style = window.getComputedStyle(element);
return style.display !== 'none' &&
style.visibility !== 'hidden' &&
element.type !== 'hidden';
});
return filtered;
}
static isVisibleElement(element) {
let style = window.getComputedStyle(element);
if (style.display === 'none') {
return false;
} else if (style.visibility === 'hidden') {
return false;
}
return true;
}
}