From c91c6006db79ff9138a2fb43be15df410ac975e5 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Fri, 9 Oct 2020 05:23:13 +0300 Subject: [PATCH] FIX: Make browser-update work with IE<11 (#10868) - classList is not available in IE<10 - noscript has no content in IE<8 --- vendor/assets/javascripts/browser-update.js.erb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vendor/assets/javascripts/browser-update.js.erb b/vendor/assets/javascripts/browser-update.js.erb index cabd0946383..eedfc713024 100644 --- a/vendor/assets/javascripts/browser-update.js.erb +++ b/vendor/assets/javascripts/browser-update.js.erb @@ -18,17 +18,20 @@ var $buo = function() { return; } - document.getElementsByTagName('body')[0].classList.add("crawler"); + document.getElementsByTagName('body')[0].className += " crawler"; var mainElement = document.getElementById("main"); var noscriptElements = document.getElementsByTagName("noscript"); // find the element with the "data-path" attribute set for (var i = 0; i < noscriptElements.length; ++i) { if (noscriptElements[i].getAttribute("data-path")) { // noscriptElements[i].innerHTML contains encoded HTML - mainElement.innerHTML = noscriptElements[i].childNodes[0].nodeValue; - break; + if (noscriptElements[i].childNodes.length > 0) { + mainElement.innerHTML = noscriptElements[i].childNodes[0].nodeValue; + break; + } } } + // retrieve localized browser upgrade text var t = <%= "'" + I18n.t('js.browser_update') + "'" %>;