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; } });