FIX: Make browser-update work with IE<11 (#10868)

- classList is not available in IE<10
- noscript has no content in IE<8
This commit is contained in:
Dan Ungureanu 2020-10-09 05:23:13 +03:00 committed by GitHub
parent 5157e3b6e3
commit c91c6006db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -18,17 +18,20 @@ var $buo = function() {
return; return;
} }
document.getElementsByTagName('body')[0].classList.add("crawler"); document.getElementsByTagName('body')[0].className += " crawler";
var mainElement = document.getElementById("main"); var mainElement = document.getElementById("main");
var noscriptElements = document.getElementsByTagName("noscript"); var noscriptElements = document.getElementsByTagName("noscript");
// find the element with the "data-path" attribute set // find the element with the "data-path" attribute set
for (var i = 0; i < noscriptElements.length; ++i) { for (var i = 0; i < noscriptElements.length; ++i) {
if (noscriptElements[i].getAttribute("data-path")) { if (noscriptElements[i].getAttribute("data-path")) {
// noscriptElements[i].innerHTML contains encoded HTML // noscriptElements[i].innerHTML contains encoded HTML
mainElement.innerHTML = noscriptElements[i].childNodes[0].nodeValue; if (noscriptElements[i].childNodes.length > 0) {
break; mainElement.innerHTML = noscriptElements[i].childNodes[0].nodeValue;
break;
}
} }
} }
// retrieve localized browser upgrade text // retrieve localized browser upgrade text
var t = <%= "'" + I18n.t('js.browser_update') + "'" %>; var t = <%= "'" + I18n.t('js.browser_update') + "'" %>;