[commit: haddock] master: Implement workaround for Chrome highlighting issues. (6cf5e45)
git at git.haskell.org
git at git.haskell.org
Wed Jul 8 08:40:33 UTC 2015
Repository : ssh://git@git.haskell.org/haddock
On branch : master
Link : http://git.haskell.org/haddock.git/commitdiff/6cf5e45135ad48f140a76054b38e13eb83491d2a
>---------------------------------------------------------------
commit 6cf5e45135ad48f140a76054b38e13eb83491d2a
Author: Łukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date: Sun Jun 28 23:13:05 2015 +0200
Implement workaround for Chrome highlighting issues.
>---------------------------------------------------------------
6cf5e45135ad48f140a76054b38e13eb83491d2a
haddock-api/resources/html/highlight.js | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/haddock-api/resources/html/highlight.js b/haddock-api/resources/html/highlight.js
index 639cf5d..a538fea 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];
More information about the ghc-commits
mailing list