From d02da246b5582643d5fcc0eebc3c65ef4adb9146 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 6 Jul 2021 18:59:54 +0200 Subject: [PATCH] MOBILE-3320 behat: Remove modern JS --- tests/behat/app_behat_runtime.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/behat/app_behat_runtime.js b/tests/behat/app_behat_runtime.js index 960603d82..40a71cdf7 100644 --- a/tests/behat/app_behat_runtime.js +++ b/tests/behat/app_behat_runtime.js @@ -296,7 +296,8 @@ } const labelledBy = currentNode.getAttribute('aria-labelledby'); - if (labelledBy && container.querySelector(`#${labelledBy}`)?.innerText?.includes(text)) { + const labelElement = labelledBy && container.querySelector(`#${labelledBy}`); + if (labelElement && labelElement.innerText && labelElement.innerText.includes(text)) { elements.push(currentNode); continue; @@ -361,7 +362,7 @@ * @return {HTMLElement} Parent element. */ var getParentElement = function(element) { - return element.parentElement ?? element.getRootNode()?.host ?? null; + return element.parentElement || (element.getRootNode() && element.getRootNode().host) || null; }; /** @@ -438,7 +439,7 @@ // may not work without doing this. const parentElement = getParentElement(element); - if (parentElement?.matches('ion-button, ion-back-button')) { + if (parentElement && parentElement.matches('ion-button, ion-back-button')) { element = parentElement; }