Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions src/nodes/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,9 @@ export function parse(data: string, options = {} as Partial<Options>) {
// this is wrong, becouse this will put the H3 outside the current right position which should be inside the current Html Element, see issue 152 for more info
if (options.parseNoneClosedTags !== true) {
oneBefore.removeChild(last);
reparentChildren(last, oneBefore.parentNode);
last.childNodes.forEach((child) => {
oneBefore.parentNode.appendChild(child);
});
stack.pop();
}
} else {
Expand All @@ -1328,7 +1330,9 @@ export function parse(data: string, options = {} as Partial<Options>) {
// eslint-disable-next-line no-lonely-if
if (options.parseNoneClosedTags !== true) {
oneBefore.removeChild(last);
reparentChildren(last, oneBefore);
last.childNodes.forEach((child) => {
oneBefore.appendChild(child);
});
}
}
} else {
Expand All @@ -1343,17 +1347,6 @@ export function parse(data: string, options = {} as Partial<Options>) {
return root;
}

function reparentChildren(source: HTMLElement, parent: HTMLElement) {
const children = source.childNodes;
source.childNodes = [];
for (const child of children) {
// Detach in bulk: appendChild() would otherwise filter the shrinking source
// array once per child, making repair quadratic in the number of siblings.
child.parentNode = null;
parent.appendChild(child);
}
}

/**
* Resolves a list of {@link NodeInsertable} to a list of nodes,
* and removes nodes from any potential parent.
Expand Down
78 changes: 0 additions & 78 deletions test/tests/issues/260-unclosed-tags.js

This file was deleted.

Loading