From 2693e5e2b614829c0e53afc9545474a7a542c91a Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Fri, 2 Oct 2020 14:30:10 +0100 Subject: [PATCH] Replace use of Array.from Array.from isn't supported by any version of IE. We still need to convert a nodelist to an array so we can either: 1. include the polyfill for Array.from from core-js 2. use [].slice We don't use Array.from anywhere else so this uses the second one. --- app/assets/javascripts/apiKey.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/apiKey.js b/app/assets/javascripts/apiKey.js index cdd7aaf0e..4d8658a7c 100644 --- a/app/assets/javascripts/apiKey.js +++ b/app/assets/javascripts/apiKey.js @@ -29,9 +29,10 @@ this.getRangeFromElement = function (keyElement) { const range = document.createRange(); + const childNodes = Array.prototype.slice.call(keyElement.childNodes); let prefixIndex = -1; - Array.from(keyElement.childNodes).forEach((el, idx) => { + childNodes.forEach((el, idx) => { if ((el.nodeType === 1) && el.classList.contains('govuk-visually-hidden')) { prefixIndex = idx; }