Skip to content

Commit b52ca4e

Browse files
committed
fix(HTML): address some issues when wrapping text nodes
Let’s not use a fake <p> take to wrap them anymore as this could add some unintended styles to your rendering.
1 parent f5863da commit b52ca4e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/HTML.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ export default class HTML extends PureComponent {
216216
associateRawTexts (children) {
217217
for (let i = 0; i < children.length; i++) {
218218
const child = children[i];
219-
if ((child.wrapper === 'Text' && TEXT_TAGS_IGNORING_ASSOCIATION.indexOf(child.tagName) === -1) && children.length > 1 && (!child.parent || child.parent.name !== 'p')) {
219+
if (
220+
(child.wrapper === 'Text' && TEXT_TAGS_IGNORING_ASSOCIATION.indexOf(child.tagName) === -1) &&
221+
children.length > 1 &&
222+
(!child.parent || TEXT_TAGS_IGNORING_ASSOCIATION.indexOf(child.parent.name) === -1)
223+
) {
220224
// Texts outside <p> or not <p> themselves (with siblings)
221225
let wrappedTexts = [];
222226
for (let j = i; j < children.length; j++) {
@@ -238,7 +242,7 @@ export default class HTML extends PureComponent {
238242
nodeIndex: i,
239243
parent: child.parent,
240244
parentTag: child.parentTag,
241-
tagName: child.parent && child.parent.name === 'li' ? 'textwrapper' : 'p',
245+
tagName: 'textwrapper',
242246
wrapper: 'Text'
243247
};
244248
}

0 commit comments

Comments
 (0)