diff --git a/src/transformers/sixHex.js b/src/transformers/sixHex.js index 74d638d1..966fb033 100644 --- a/src/transformers/sixHex.js +++ b/src/transformers/sixHex.js @@ -1,6 +1,5 @@ const {get} = require('lodash') const posthtml = require('posthtml') -const parseAttrs = require('posthtml-attrs-parser') const {conv} = require('color-shorthand-hex-to-six-digit') module.exports = async (html, config = {}) => { @@ -13,18 +12,16 @@ module.exports = async (html, config = {}) => { } const sixHex = () => tree => { - const process = node => { - const attrs = parseAttrs(node.attrs) - - const targets = ['bgcolor', 'color'] + const targets = new Set(['bgcolor', 'color']) - targets.forEach(attribute => { - if (attrs[attribute]) { - attrs[attribute] = conv(attrs[attribute]) - } - }) - - node.attrs = attrs.compose() + const process = node => { + if (node.attrs) { + Object.entries(node.attrs).forEach(([name, value]) => { + if (targets.has(name) && node.attrs[name]) { + node.attrs[name] = conv(value) + } + }) + } return node }