Replace brittle custom function with lodash implementation (#11188)

This commit is contained in:
Michael Telatynski 2023-07-06 09:22:43 +01:00 committed by GitHub
parent d7677c7e21
commit b467d0700f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,20 +20,10 @@ import { diff_match_patch as DiffMatchPatch } from "diff-match-patch";
import { DiffDOM, IDiff } from "diff-dom";
import { IContent } from "matrix-js-sdk/src/models/event";
import { logger } from "matrix-js-sdk/src/logger";
import { unescape } from "lodash";
import { bodyToHtml, checkBlockNode, IOptsReturnString } from "../HtmlUtils";
const decodeEntities = (function () {
let textarea: HTMLTextAreaElement | undefined;
return function (str: string): string {
if (!textarea) {
textarea = document.createElement("textarea");
}
textarea.innerHTML = str;
return textarea.value;
};
})();
function textToHtml(text: string): string {
const container = document.createElement("div");
container.textContent = text;
@ -153,7 +143,7 @@ function adjustRoutes(diff: IDiff, remainingDiffs: IDiff[]): void {
}
function stringAsTextNode(string: string): Text {
return document.createTextNode(decodeEntities(string));
return document.createTextNode(unescape(string));
}
function renderDifferenceInDOM(originalRootNode: Node, diff: IDiff, diffMathPatch: DiffMatchPatch): void {