Fixed none shown hint labels by CSP headers #531.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 21 Nov 2018 22:21:01 +0000 (23:21 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 21 Nov 2018 22:25:11 +0000 (23:25 +0100)
The styling by elements style attribute might be forbidden by
Content-Security-Policy restrictions. But positioning of the elements by
the elements style object seems to work.

src/scripts/hints.js

index 32b4f06..c5acfd0 100644 (file)
@@ -173,13 +173,10 @@ var hints = Object.freeze((function(){
                 /* create the hint label with number/letters */
                 rect  = e.getClientRects()[0];
                 label = labelTmpl.cloneNode(false);
-                label.setAttribute(
-                    "style", [
-                        "display:none;",
-                        "left:", rect.left, "px;",
-                        "top:", rect.top, "px;"
-                    ].join("")
-                );
+
+                label.style.display = "none";
+                label.style.left    = rect.left + "px";
+                label.style.top     = rect.top + "px";
 
                 /* if hinted element is an image - show title or alt of the image in hint label */
                 /* this allows to see how to filter for the image */
@@ -226,7 +223,10 @@ var hints = Object.freeze((function(){
             /* append the fragment to the document */
             var hDiv = doc.createElement("div");
             hDiv.setAttribute(attr, "container");
-            hDiv.setAttribute("style", "position:fixed;top:0;left:0;z-index:225000;");
+            hDiv.style.position = "fixed";
+            hDiv.style.top      = "0";
+            hDiv.style.left     = "0";
+            hDiv.style.zIndex   = "225000";
             hDiv.appendChild(fragment);
             if (doc.body) {
                 doc.body.appendChild(hDiv);