From 6fdc01201b1db8b0513754028f7e75ba6ac7c533 Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 11 Sep 2018 17:39:43 +0300 Subject: [PATCH 1/2] FF: preserve sheet's disabled state in workaround for #461 --- content/apply.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/content/apply.js b/content/apply.js index c332fc11..ac0e03d3 100644 --- a/content/apply.js +++ b/content/apply.js @@ -333,11 +333,12 @@ (document.head || ROOT).appendChild(document.createElement('script')).text = ` document.currentScript.remove(); for (const {id, code} of ${JSON.stringify(pageContextQueue)}) { - ( - document.getElementById(id) || - document.querySelector('style.stylus[id="' + id + '"]') || - {} - ).textContent = code; + const el = document.getElementById(id) || + document.querySelector('style.stylus[id="' + id + '"]'); + if (!el) continue; + const {disabled} = el.sheet; + el.textContent = code; + el.sheet.disabled = disabled; } `; } catch (e) {} From e1284985185fff31acae36e0f0f1296c316fe83b Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 11 Sep 2018 17:40:36 +0300 Subject: [PATCH 2/2] code cosmetics: convert to a lintable template string --- content/apply.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/apply.js b/content/apply.js index ac0e03d3..d18b0a22 100644 --- a/content/apply.js +++ b/content/apply.js @@ -330,9 +330,9 @@ function setContentsInPageContext() { try { - (document.head || ROOT).appendChild(document.createElement('script')).text = ` + (document.head || ROOT).appendChild(document.createElement('script')).text = `(${queue => { document.currentScript.remove(); - for (const {id, code} of ${JSON.stringify(pageContextQueue)}) { + for (const {id, code} of queue) { const el = document.getElementById(id) || document.querySelector('style.stylus[id="' + id + '"]'); if (!el) continue; @@ -340,7 +340,7 @@ el.textContent = code; el.sheet.disabled = disabled; } - `; + }})(${JSON.stringify(pageContextQueue)})`; } catch (e) {} let failedSome; for (const {el, code} of pageContextQueue) {