Skip to content

Commit

Permalink
fix: remove excess div wrappers (#4528)
Browse files Browse the repository at this point in the history
* Removing superfluous div wrapping

It seems like standalone text is already wrapped in paragraph elements, so this code seems superfluous. Additionally, it adds div wrappers at every line break as described in #4524

* Fix for newlines and returns

This change skips newlines and returns to focus on unbounded text only.

* misc: fix indentation

* misc: fix indentation (2)

Co-authored-by: Nicolas Giard <github@ngpixel.com>
  • Loading branch information
broxen and NGPixel committed Oct 9, 2021
1 parent 525f758 commit 12aef93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/modules/rendering/html-core/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ module.exports = {
})

// --------------------------------
// Wrap root text nodes
// Wrap non-empty root text nodes
// --------------------------------

$('body').contents().toArray().forEach(item => {
if (item && item.type === 'text' && item.parent.name === 'body') {
if (item && item.type === 'text' && item.parent.name === 'body' && item.data !== `\n` && item.data !== `\r`) {
$(item).wrap('<div></div>')
}
})
Expand Down

0 comments on commit 12aef93

Please sign in to comment.