diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-12-28 16:20:54 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-28 16:20:54 +0900 |
commit | df18fb337fa070dcaf9b3818420921e8b7459032 (patch) | |
tree | 941749d37e2a33eac64ca151d9cb6cd782ba0a23 /src | |
parent | a1e5f9d49a381add081c624c1fbca48c3dc4b473 (diff) | |
parent | de7883329bb3d2a5a5a12cd278970b04107a0097 (diff) |
Merge pull request #291 from usk/feature/do-not-follow-link-which-has-aria-hidden-attribute-or-aria-disabled-attribute
do not follow link which has aria-hidden attribute or aria-disabled a…
Diffstat (limited to 'src')
-rw-r--r-- | src/content/components/common/follow.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/content/components/common/follow.js b/src/content/components/common/follow.js index 7717154..42dd897 100644 --- a/src/content/components/common/follow.js +++ b/src/content/components/common/follow.js @@ -30,6 +30,21 @@ const inViewport = (win, element, viewSize, framePosition) => { return true; }; +const isAriaHiddenOrAriaDisabled = (win, element) => { + if (!element || win.document.documentElement === element) { + return false; + } + for (let attr of ['aria-hidden', 'aria-disabled']) { + if (element.hasAttribute(attr)) { + let hidden = element.getAttribute(attr).toLowerCase(); + if (hidden === '' || hidden === 'true') { + return true; + } + } + } + return isAriaHiddenOrAriaDisabled(win, element.parentNode); +}; + export default class Follow { constructor(win, store) { this.win = win; @@ -171,6 +186,7 @@ export default class Follow { style.visibility !== 'hidden' && element.type !== 'hidden' && element.offsetHeight > 0 && + !isAriaHiddenOrAriaDisabled(win, element) && inViewport(win, element, viewSize, framePosition); }); return filtered; |