[analyzer] Add support for IE of keyboard and mouse navigation in HTML report

IE throws errors while using key and mouse navigation through the error path tips.
querySelectorAll method returns NodeList. NodeList belongs to browser API. IE doesn't have forEach among NodeList's methods. At the same time Array is a JavaScript object and can be used instead. The fix is in the converting NodeList into Array and keeps using forEach method as before.

Checked in IE11, Chrome and Opera.

Differential Revision: https://reviews.llvm.org/D80444
This commit is contained in:
Denys Petrov 2020-05-22 18:01:53 +03:00
parent 9f69d3d0bc
commit 6bbaa62d26
1 changed files with 7 additions and 2 deletions

View File

@ -1070,8 +1070,13 @@ StringRef HTMLDiagnostics::generateKeyboardNavigationJavascript() {
<script type='text/javascript'>
var digitMatcher = new RegExp("[0-9]+");
var querySelectorAllArray = function(selector) {
return Array.prototype.slice.call(
document.querySelectorAll(selector));
}
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll(".PathNav > a").forEach(
querySelectorAllArray(".PathNav > a").forEach(
function(currentValue, currentIndex) {
var hrefValue = currentValue.getAttribute("href");
currentValue.onclick = function() {
@ -1091,7 +1096,7 @@ var findNum = function() {
};
var scrollTo = function(el) {
document.querySelectorAll(".selected").forEach(function(s) {
querySelectorAllArray(".selected").forEach(function(s) {
s.classList.remove("selected");
});
el.classList.add("selected");