From fe660672cb5030e0f780d273798eec894209bbfa Mon Sep 17 00:00:00 2001 From: Nick Colley Date: Wed, 11 Dec 2019 17:47:56 +0000 Subject: [PATCH] Fix *ElementSibiling polyfills In Internet Explorer 8 errors are thrown when checking the nodeType as nextSibiling is undefined, so to fix this issue we should first check if there is a next sibiling which matches the conditional in the while loop. Fixes https://github.com/alphagov/govuk-frontend/issues/1490 --- .../vendor/polyfills/Element/prototype/nextElementSibling.js | 2 +- .../polyfills/Element/prototype/previousElementSibling.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js b/src/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js index ec3c615496c..35592a91308 100644 --- a/src/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +++ b/src/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js @@ -18,7 +18,7 @@ import '../../Element' get: function(){ var el = this.nextSibling; while (el && el.nodeType !== 1) { el = el.nextSibling; } - return (el.nodeType === 1) ? el : null; + return (el && el.nodeType === 1) ? el : null; } }); diff --git a/src/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js b/src/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js index 1184a0a3e31..a211fd96f3e 100644 --- a/src/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +++ b/src/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js @@ -16,7 +16,7 @@ import '../../Element' get: function(){ var el = this.previousSibling; while (el && el.nodeType !== 1) { el = el.previousSibling; } - return (el.nodeType === 1) ? el : null; + return (el && el.nodeType === 1) ? el : null; } });