Skip to content

Commit

Permalink
FIX: Make browser-update work with IE<11 (#10868)
Browse files Browse the repository at this point in the history
- classList is not available in IE<10
- noscript has no content in IE<8
  • Loading branch information
udan11 committed Oct 9, 2020
1 parent 5157e3b commit c91c600
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions vendor/assets/javascripts/browser-update.js.erb
Expand Up @@ -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') + "'" %>;

Expand Down

0 comments on commit c91c600

Please sign in to comment.