Update dependency html-react-parser to v6 (#33250)

* Update dependency html-react-parser to v6

* Fix renderer utils

* Fix CodeBlock similarly

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
renovate[bot]
2026-04-21 22:20:09 +00:00
committed by GitHub
parent 1a87865134
commit d01f40bf27
5 changed files with 31 additions and 20 deletions
+1 -1
View File
@@ -72,7 +72,7 @@
"glob-to-regexp": "^0.4.1",
"highlight.js": "^11.3.1",
"html-entities": "^2.0.0",
"html-react-parser": "^5.2.2",
"html-react-parser": "^6.0.0",
"is-ip": "^5.0.0",
"js-xxhash": "^5.0.0",
"jsrsasign": "^11.0.0",
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
import React, { type JSX, useState } from "react";
import classNames from "classnames";
import { type DOMNode, Element as ParserElement, domToReact } from "html-react-parser";
import { type DOMNode, type Element as ParserElement, domToReact } from "html-react-parser";
import { textContent, getInnerHTML } from "domutils";
import { CollapseIcon, CopyIcon, ExpandIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
@@ -113,7 +113,7 @@ const CodeBlock: React.FC<Props> = ({ preNode }) => {
let content = domToReact(preNode.children as DOMNode[]);
// Add code element if it's missing since we depend on it
if (!preNode.children.some((child) => child instanceof ParserElement && child.tagName.toUpperCase() === "CODE")) {
if (!preNode.children.some((child) => child.type === "tag" && child.tagName.toUpperCase() === "CODE")) {
content = <code>{content}</code>;
}
+2 -2
View File
@@ -6,7 +6,7 @@ Please see LICENSE files in the repository root for full details.
*/
import { type JSX } from "react";
import { type DOMNode, Element, type HTMLReactParserOptions, type Text } from "html-react-parser";
import { type DOMNode, type Element, type HTMLReactParserOptions, type Text } from "html-react-parser";
import { type MatrixEvent, type Room } from "matrix-js-sdk/src/matrix";
/**
@@ -89,7 +89,7 @@ export const combineRenderers =
if (result) return result;
}
}
if (node instanceof Element) {
if (node.type === "tag") {
const tagName = node.tagName.toLowerCase() as keyof HTMLElementTagNameMap;
for (const replacer of renderers) {
const result = replacer[tagName]?.(node, parametersWithReplace, index);