From 56b2462f13db5ac9a57bce1b0bc8e18da55d9ce7 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 2 Jul 2021 18:28:29 -0400 Subject: CssStyleApplier updates (#1784) * Remove debug log * Remove style attribute if empty * Remove data-* attributes --- ext/js/dom/css-style-applier.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'ext/js') diff --git a/ext/js/dom/css-style-applier.js b/ext/js/dom/css-style-applier.js index 6de4bd2d..32d7ef0f 100644 --- a/ext/js/dom/css-style-applier.js +++ b/ext/js/dom/css-style-applier.js @@ -57,9 +57,6 @@ class CssStyleApplier { const {className} = element; if (className.length === 0) { continue; } let cssTextNew = ''; - if (className.indexOf('th') >= 0) { - console.log(className, this._getRulesForClass(className)); - } for (const {selectorText, styles} of this._getRulesForClass(className)) { if (!element.matches(selectorText)) { continue; } cssTextNew += this._getCssText(styles); @@ -69,7 +66,17 @@ class CssStyleApplier { } for (const {element, style} of elementStyles) { element.removeAttribute('class'); - element.setAttribute('style', style); + if (style.length > 0) { + element.setAttribute('style', style); + } else { + element.removeAttribute('style'); + } + } + for (const element of elements) { + const {dataset} = element; + for (const key of Object.keys(dataset)) { + delete dataset[key]; + } } } -- cgit v1.2.3