From 6cf5e45135ad48f140a76054b38e13eb83491d2a Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Sun, 28 Jun 2015 23:13:05 +0200 Subject: Implement workaround for Chrome highlighting issues. --- haddock-api/resources/html/highlight.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'haddock-api/resources/html') diff --git a/haddock-api/resources/html/highlight.js b/haddock-api/resources/html/highlight.js index 639cf5d5..a538feae 100644 --- a/haddock-api/resources/html/highlight.js +++ b/haddock-api/resources/html/highlight.js @@ -3,6 +3,10 @@ var styleForRule = function (rule) { var sheets = document.styleSheets; for (var s = 0; s < sheets.length; s++) { var rules = sheets[s].cssRules; + if (rules === null) { + return null; + } + for (var r = 0; r < rules.length; r++) { if (rules[r].selectorText == rule) { return rules[r].style; @@ -12,7 +16,13 @@ var styleForRule = function (rule) { }; var highlight = function () { - var color = styleForRule("a:hover")["background-color"]; + /* + * Chrome for security reasons disallows to read .cssRules property. + * So, we are forced to pick some color and set it as a highlight. + */ + var style = styleForRule("a:hover"); + var color = style !== null ? style["background-color"] : "#808080"; + var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { var that = links[i]; -- cgit v1.2.3