From 65e84dd22a5c888095a8e9105d85d426a2c3689d Mon Sep 17 00:00:00 2001 From: Azgaar Date: Tue, 23 Feb 2021 23:48:47 +0300 Subject: [PATCH] v1.5.51 - polyfill for replaceAll --- modules/utils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/utils.js b/modules/utils.js index 3e34336c..7d0b2ad6 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -510,6 +510,14 @@ function getComposedPath(node) { return [node]; }; +// polyfill for replaceAll +if (!String.prototype.replaceAll) { + String.prototype.replaceAll = function(str, newStr){ + if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') return this.replace(str, newStr); + return this.replace(new RegExp(str, 'g'), newStr); + }; +} + // get next unused id function getNextId(core, i = 1) { while (document.getElementById(core+i)) i++;