Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    String.replaceAll doesn't allow to use callback as a replacement

    ISC_Core.js overwrites String.prototype.replaceAll with its own implementation, which is incompatible with native implementation - it doesn't support passing a callback as "replacement".

    This code:
    Code:
    "a1b2a3b".replaceAll(/\d/g, (match) => `-${match}-`)
    should result in
    Code:
    a-1-b-2-a-3-b
    but currently it generates:
    Code:
    a(match) => `-${match}-`b(match) => `-${match}-`a(match) => `-${match}-`b
    MDN docs: https://developer.mozilla.org/en-US/...ll#replacement

    Current SmartClient implementation (v13.0p_2024-04-08/AllModules Development Only):
    Code:
    replaceAll : function (source, find, replacement) {
        return source.split(find).join(replacement);
    },

    #2
    Thanks for pointing this out. We've made an adjustment to avoid replacing the native browser's String.prototype.replaceAll(). This has been back ported to SC 12.1 and will be in the nightly builds dated 2024-04-10 and beyond.

    Comment

    Working...
    X