mirror of https://github.com/vector-im/riot-web
Replace brittle custom function with lodash implementation (#11188)
parent
d7677c7e21
commit
b467d0700f
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue