Unbreak in-app permalink tooltips (#9100)
* Unbreak in-app permalink tooltips Fixes: vector-im/element-web#22874 Signed-off-by: Johannes Marbach <johannesm@element.io> * Appease the linter * Fix the testspull/28217/head
parent
bbf28603ef
commit
671973461f
|
@ -53,11 +53,11 @@ export function tooltipifyLinks(rootNodes: ArrayLike<Element>, ignoredNodes: Ele
|
|||
const href = node.getAttribute("href");
|
||||
|
||||
const tooltip = <LinkWithTooltip tooltip={new URL(href, window.location.href).toString()}>
|
||||
<span dangerouslySetInnerHTML={{ __html: node.outerHTML }} />
|
||||
{ node.innerHTML }
|
||||
</LinkWithTooltip>;
|
||||
|
||||
ReactDOM.render(tooltip, container);
|
||||
node.parentNode.replaceChild(container, node);
|
||||
node.replaceChildren(container);
|
||||
containers.push(container);
|
||||
tooltipified = true;
|
||||
}
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
Loading…
Reference in New Issue