From c6663068a7fecd6511e9d08fbbf74e2839d9fc15 Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Tue, 9 May 2023 15:58:00 +0200 Subject: [PATCH] fix(ui): cleanup IE edge case in getAriaElementsInRightDomOrder --- .../utils/getAriaElementsInRightDomOrder.js | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/ui/components/form-core/src/utils/getAriaElementsInRightDomOrder.js b/packages/ui/components/form-core/src/utils/getAriaElementsInRightDomOrder.js index 5c0f99ed1..440e38d6d 100644 --- a/packages/ui/components/form-core/src/utils/getAriaElementsInRightDomOrder.js +++ b/packages/ui/components/form-core/src/utils/getAriaElementsInRightDomOrder.js @@ -1,6 +1,4 @@ /* eslint-disable no-bitwise */ -import { browserDetection } from '@lion/ui/core.js'; - const moveDownConditions = [ Node.DOCUMENT_POSITION_PRECEDING, Node.DOCUMENT_POSITION_CONTAINS, @@ -8,30 +6,25 @@ const moveDownConditions = [ ]; /** - * @desc Let the order of adding ids to aria element by DOM order, so that the screen reader + * Let the order of adding ids to aria element by DOM order, so that the screen reader * respects visual order when reading: * https://developers.google.com/web/fundamentals/accessibility/focus/dom-order-matters - * @param {HTMLElement[]} descriptionElements - holds references to description or label elements whose + * @param {Element[]} descriptionElements - holds references to description or label elements whose * id should be returned * @param {Object} opts * @param {boolean} [opts.reverse] - * @returns {HTMLElement[]} sorted set of elements based on dom order + * @returns {Element[]} sorted set of elements based on dom order */ export function getAriaElementsInRightDomOrder(descriptionElements, { reverse } = {}) { /** - * @param {HTMLElement} a - * @param {HTMLElement} b - * @return {-1|1} + * @param {Node} a + * @param {Node} b + * @returns {-1|1} */ const putPrecedingSiblingsAndLocalParentsFirst = (a, b) => { // https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition const pos = a.compareDocumentPosition(b); - - // Unfortunately, for IE, we have to switch the order (?) - if (moveDownConditions.includes(pos)) { - return browserDetection.isIE11 ? -1 : 1; - } - return browserDetection.isIE11 ? 1 : -1; + return moveDownConditions.includes(pos) ? 1 : -1; }; const descriptionEls = descriptionElements.filter(el => el); // filter out null references