From 0bc6b1f1b3a55d28718995cd3bc257ea56d2122c Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 5 Aug 2018 22:41:21 +1000 Subject: =?UTF-8?q?Fix=20issue=20where=20enter=20key=20wasn=E2=80=99t=20se?= =?UTF-8?q?tting=20focus=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/utils/elements.js | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/js/utils/elements.js') diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js index 3a3dfcfd..a6722da2 100644 --- a/src/js/utils/elements.js +++ b/src/js/utils/elements.js @@ -116,11 +116,7 @@ export function emptyElement(element) { // Replace element export function replaceElement(newChild, oldChild) { - if ( - !is.element(oldChild) || - !is.element(oldChild.parentNode) || - !is.element(newChild) - ) { + if (!is.element(oldChild) || !is.element(oldChild.parentNode) || !is.element(newChild)) { return null; } @@ -195,7 +191,7 @@ export function toggleHidden(element, hidden) { let hide = hidden; if (!is.boolean(hide)) { - hide = !element.hasAttribute('hidden'); + hide = !element.hidden; } if (hide) { @@ -263,10 +259,7 @@ export function trapFocus(element = null, toggle = false) { return; } - const focusable = getElements.call( - this, - 'button:not(:disabled), input:not(:disabled), [tabindex]', - ); + const focusable = getElements.call(this, 'button:not(:disabled), input:not(:disabled), [tabindex]'); const first = focusable[0]; const last = focusable[focusable.length - 1]; @@ -290,14 +283,7 @@ export function trapFocus(element = null, toggle = false) { } }; - toggleListener.call( - this, - this.elements.container, - 'keydown', - trap, - toggle, - false, - ); + toggleListener.call(this, this.elements.container, 'keydown', trap, toggle, false); } // Set focus and tab focus class -- cgit v1.2.3