diff --git a/src/utils/tooltipify.tsx b/src/utils/tooltipify.tsx index ec698aa198..3f7042e157 100644 --- a/src/utils/tooltipify.tsx +++ b/src/utils/tooltipify.tsx @@ -53,11 +53,11 @@ export function tooltipifyLinks(rootNodes: ArrayLike, ignoredNodes: Ele const href = node.getAttribute("href"); const tooltip = - + { node.innerHTML } ; ReactDOM.render(tooltip, container); - node.parentNode.replaceChild(container, node); + node.replaceChildren(container); containers.push(container); tooltipified = true; } diff --git a/test/utils/tooltipify-test.tsx b/test/utils/tooltipify-test.tsx index b94c829faf..468cd059e1 100644 --- a/test/utils/tooltipify-test.tsx +++ b/test/utils/tooltipify-test.tsx @@ -41,9 +41,10 @@ describe('tooltipify', () => { const containers: Element[] = []; tooltipifyLinks([root], [], containers); expect(containers).toHaveLength(1); - const anchor = root.querySelector(".mx_TextWithTooltip_target a"); + const anchor = root.querySelector("a"); expect(anchor?.getAttribute("href")).toEqual("/foo"); - expect(anchor?.innerHTML).toEqual("click"); + const tooltip = anchor.querySelector(".mx_TextWithTooltip_target"); + expect(tooltip).toBeDefined(); }); it('ignores node', () => {