From 671973461f635ac2ba34518cee75861ffe123cdc Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Tue, 26 Jul 2022 13:04:50 +0200 Subject: [PATCH] Unbreak in-app permalink tooltips (#9100) * Unbreak in-app permalink tooltips Fixes: vector-im/element-web#22874 Signed-off-by: Johannes Marbach * Appease the linter * Fix the tests --- src/utils/tooltipify.tsx | 4 ++-- test/utils/tooltipify-test.tsx | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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', () => {