FIX: Find noscript element with crawler content (#10834)
There can be more than one noscript element on a page (from various plugins), but only the one with data-path attribute as set in application.html.erb contains the crawler content.
This commit is contained in:
parent
e175c467cc
commit
340d979357
|
@ -21,10 +21,14 @@ var $buo = function() {
|
|||
document.getElementsByTagName('body')[0].classList.add("crawler");
|
||||
var mainElement = document.getElementById("main");
|
||||
var noscriptElements = document.getElementsByTagName("noscript");
|
||||
// noscriptElements[0].innerHTML contains encoded HTML
|
||||
var innerHTML = noscriptElements[0].childNodes[0].nodeValue;
|
||||
mainElement.innerHTML = innerHTML;
|
||||
|
||||
// find the element with the "data-path" attribute set
|
||||
for (var i = 0; i < noscriptElements.length; ++i) {
|
||||
if (noscriptElements[i].dataset["path"]) {
|
||||
// noscriptElements[i].innerHTML contains encoded HTML
|
||||
mainElement.innerHTML = noscriptElements[i].childNodes[0].nodeValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// retrieve localized browser upgrade text
|
||||
var t = <%= "'" + I18n.t('js.browser_update') + "'" %>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue