From 6f5a1497af47409467f5f249e891ea70acf06270 Mon Sep 17 00:00:00 2001 From: Cosmin Popovici Date: Sun, 9 Oct 2022 03:10:31 +0300 Subject: [PATCH] refactor: remove inline background color transformer --- src/transformers/removeInlineBackgroundColor.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/transformers/removeInlineBackgroundColor.js b/src/transformers/removeInlineBackgroundColor.js index df38d482..a6496575 100644 --- a/src/transformers/removeInlineBackgroundColor.js +++ b/src/transformers/removeInlineBackgroundColor.js @@ -1,6 +1,7 @@ const posthtml = require('posthtml') const {get, isEmpty} = require('lodash') const parseAttrs = require('posthtml-attrs-parser') +const {toStyleString} = require('../utils/helpers') module.exports = async (html, config = {}, direct = false) => { const posthtmlOptions = get(config, 'build.posthtml.options', {}) @@ -40,9 +41,11 @@ const removeInlineBGColor = (options = {}) => tree => { }) if (attrs.style && attrs.style['background-color']) { - attrs.bgcolor = attrs.style['background-color'] + node.attrs.bgcolor = attrs.style['background-color'] + delete attrs.style['background-color'] - node.attrs = attrs.compose() + + node.attrs.style = toStyleString(attrs.style) } return node