From 76bbf877db94664e8370afc2837148549529ca2b Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Wed, 21 Nov 2018 23:21:01 +0100 Subject: [PATCH] Fixed none shown hint labels by CSP headers #531. 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/scripts/hints.js b/src/scripts/hints.js index 32b4f06..c5acfd0 100644 --- a/src/scripts/hints.js +++ b/src/scripts/hints.js @@ -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); -- 2.20.1