Skip to content

Commit

Permalink
fix: handle undefined node.attrs in prevent widows transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Oct 9, 2022
1 parent 02e0e91 commit 4035533
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/preventWidows.js
Expand Up @@ -13,7 +13,7 @@ module.exports = async (html, config = {}) => {
}

const removeWidowsPlugin = options => tree => {
const {attrName = 'prevent-widows', ...removeWidowsOptions} = options
const {attrName = 'prevent-widows', ...removeWidowsOptions} = get(options, 'widowWords', options)

removeWidowsOptions.minWordCount = removeWidowsOptions.minWordCount || 3

Expand Down Expand Up @@ -66,7 +66,7 @@ const removeWidowsPlugin = options => tree => {
}

const process = node => {
if (node.attrs && node.attrs[attrName]) {
if (node.attrs && Object.keys(node.attrs).includes(attrName)) {
const widowsRemovedString = removeWidows(tree.render(node.content), removeWidowsOptions).res

node.content = tree.render(tree.parser(widowsRemovedString))
Expand Down

0 comments on commit 4035533

Please sign in to comment.