Skip to content

Commit

Permalink
refactor: remove inline background color transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Oct 9, 2022
1 parent 1eec925 commit 6f5a149
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions 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', {})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f5a149

Please sign in to comment.