mirror of
https://github.com/element-hq/element-web
synced 2024-11-22 09:15:41 +03:00
Fix: Edit history modal crash (#10834)
* failing test * handle nodes without children in messagediffutils
This commit is contained in:
parent
eac548c25a
commit
41c96877d3
3 changed files with 36 additions and 2 deletions
|
@ -104,8 +104,10 @@ function diffTreeToDOM(desc: Text | HTMLElement): Node {
|
|||
for (const [key, value] of Object.entries(desc.attributes)) {
|
||||
node.setAttribute(key, value.value);
|
||||
}
|
||||
for (const childDesc of desc.childNodes) {
|
||||
node.appendChild(diffTreeToDOM(childDesc as Text | HTMLElement));
|
||||
if (desc.childNodes) {
|
||||
for (const childDesc of desc.childNodes) {
|
||||
node.appendChild(diffTreeToDOM(childDesc as Text | HTMLElement));
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ describe("editBodyDiffToHtml", () => {
|
|||
["attribute modifications", `<a href="#hi">hi</a>`, `<a href="#bye">hi</a>`],
|
||||
["attribute deletions", `<a href="#hi">hi</a>`, `<a>hi</a>`],
|
||||
["attribute additions", `<a>hi</a>`, `<a href="#/room/!123">hi</a>`],
|
||||
["handles empty tags", `<a>hi</a>`, `<a><h1></h1></a> hi`],
|
||||
])("renders %s", (_label, before, after) => {
|
||||
const { container } = renderDiff(before, after);
|
||||
expect(container).toMatchSnapshot();
|
||||
|
|
|
@ -365,6 +365,37 @@ exports[`editBodyDiffToHtml renders element replacements 1`] = `
|
|||
</div>
|
||||
`;
|
||||
|
||||
exports[`editBodyDiffToHtml renders handles empty tags 1`] = `
|
||||
<div>
|
||||
<span
|
||||
class="mx_EventTile_body markdown-body"
|
||||
dir="auto"
|
||||
>
|
||||
<a
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
<span>
|
||||
<span
|
||||
class="mx_EditHistoryMessage_deletion"
|
||||
>
|
||||
hi
|
||||
</span>
|
||||
<div
|
||||
class="mx_EditHistoryMessage_insertion"
|
||||
>
|
||||
<h1 />
|
||||
</div>
|
||||
</span>
|
||||
</a>
|
||||
<span
|
||||
class="mx_EditHistoryMessage_insertion"
|
||||
>
|
||||
hi
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`editBodyDiffToHtml renders inline element additions 1`] = `
|
||||
<div>
|
||||
<span
|
||||
|
|
Loading…
Reference in a new issue