From 54363b25bccb1696182dabe00ec3c03b10363a09 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Thu, 10 Oct 2024 23:56:42 +0200 Subject: [PATCH] Fixing issue with Replace All when replacement string includes source string. --- common/src/lib/polyfills/js.mjs | 5 +---- common/src/module/latex.mjs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/common/src/lib/polyfills/js.mjs b/common/src/lib/polyfills/js.mjs index 9bcf80c..b412716 100644 --- a/common/src/lib/polyfills/js.mjs +++ b/common/src/lib/polyfills/js.mjs @@ -64,10 +64,7 @@ function arrayFlatMap(callbackFn, thisArg) { * @return {String} */ function stringReplaceAll(from, to) { - let str = this - while(str.includes(from)) - str = str.replace(from, to) - return str + return this.split(from).join(to) } diff --git a/common/src/module/latex.mjs b/common/src/module/latex.mjs index 8fabee4..a0e8401 100644 --- a/common/src/module/latex.mjs +++ b/common/src/module/latex.mjs @@ -261,7 +261,7 @@ class LatexAPI extends Module { throw new EvalError("Unknown operator " + item.value + ".") } break - case Instruction.IOP3: // Thirdiary operator + case Instruction.IOP3: // Ternary operator n3 = nstack.pop() n2 = nstack.pop() n1 = nstack.pop()