Skip to content

Commit

Permalink
Update trapTabKey.js
Browse files Browse the repository at this point in the history
added code to remove focusable elements that are hidden
  • Loading branch information
Sean Elliott authored Feb 22, 2017
1 parent 0937907 commit 89bc8ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions trapTabKey.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
var getFocusableElements = function(element) {
var focusElemString = "a[href],button:not([disabled]),area[href],input:not([disabled]):not([type=hidden]),select:not([disabled]),textarea:not([disabled]),iframe,object,embed,*:not(.is-draggabe)[tabindex],*[contenteditable]";
var focusableElements = element.querySelectorAll(focusElemString);
focusableElements = Array.prototype.slice.call(focusableElements);
var tempElements = element.querySelectorAll(focusElemString);
tempElements = Array.prototype.slice.call(tempElements);
var focusableElements = [];

for (var i = 0; i < tempElements.length; i++) {
if(tempElements[i].offsetHeight !== 0) focusableElements.push(tempElements[i])
};

var object = {
"all": focusableElements,
"first": focusableElements[0],
Expand Down

0 comments on commit 89bc8ca

Please sign in to comment.