Skip to content

Commit

Permalink
fix #1942 dont process head with cheerio
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcb777 committed Aug 11, 2020
1 parent 866c4df commit 0b9e2db
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions packages/mjml-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,23 @@ export default function mjml2html(mjml, options = {}) {
if (minify && minify !== 'false') {
content = minifyOutlookConditionnals(content)
}

if (!isEmpty(globalDatas.htmlAttributes)) {
const $ = cheerio.load(content, {
xmlMode: true, // otherwise it may move contents that aren't in any tag
decodeEntities: false, // won't escape special characters
})

each(globalDatas.htmlAttributes, (data, selector) => {
each(data, (value, attrName) => {
$(selector).each(function getAttr() {
$(this).attr(attrName, value)
})
})
})

content = $.root().html()
}

content = skeleton({
content,
Expand Down Expand Up @@ -341,23 +358,6 @@ export default function mjml2html(mjml, options = {}) {
})
}

if (!isEmpty(globalDatas.htmlAttributes)) {
const $ = cheerio.load(content, {
xmlMode: true, // otherwise it may move contents that aren't in any tag
decodeEntities: false, // won't escape special characters
})

each(globalDatas.htmlAttributes, (data, selector) => {
each(data, (value, attrName) => {
$(selector).each(function getAttr() {
$(this).attr(attrName, value)
})
})
})

content = $.root().html()
}

content = mergeOutlookConditionnals(content)

return {
Expand Down

0 comments on commit 0b9e2db

Please sign in to comment.