Fixed Uncaught TypeError: a.replace is not a function


Well-known member
Affected version
jquery-3.5.1.min.js?_v=864c504b:formatted:1505 Uncaught TypeError: a.replace is not a function
    at Object.appBadgeUpdate (core-compiled.js?_v=864c504b:formatted:1117)
    at Object.updateVisitorCounts (core-compiled.js?_v=864c504b:formatted:1038)
    at Object.updateVisitorCountsOnLoad (core-compiled.js?_v=864c504b:formatted:1053)
    at HTMLDocument.onPageLoad (core-compiled.js?_v=864c504b:formatted:924)
    at e (jquery-3.5.1.min.js?_v=864c504b:formatted:1423)
    at t (jquery-3.5.1.min.js?_v=864c504b:formatted:1434)

This seems to be caused by
newCount = parseInt(newCount.replace(/[,. ]/g, ''));
in XF.appBadgeUpdate().

This does assume that newCount is a string, but this might not necessarily be the case - on initial page load this is XF.visitorCounts.total_unread which is an integer:
$.extend(XF, {
    config: {
        userId: null,
        enablePush: false,
        skipServiceWorkerRegistration: false,
        skipPushNotificationSubscription: false,
        skipPushNotificationCta: false,
        pushAppServerKey: null,
        csrf: $('html').data('csrf'),
        time: {
            now: 0,
            today: 0,
            todayDow: 0,
            tomorrow: 0,
            yesterday: 0,
            week: 0
        cookie: {
            path: '/',
            domain: '',
            prefix: 'xf_'
        url: {
            fullBase: '/',
            basePath: '/',
            css: '',
            keepAlive: ''
        css: {},
        js: {},
        jsState: {},
        speed: {
            xxfast: 50,
            xfast: 100,
            fast: 200,
            normal: 400,
            slow: 600
        job: {
            manualUrl: ''
        borderSizeFeature: '3px',
        fontAwesomeWeight: 'r',
        enableRtnProtect: true,
        enableFormSubmitSticky: true,
        visitorCounts: {
            conversations_unread: 0,
            alerts_unviewed: 0,
            total_unread: 0,
            title_count: false,
            icon_indicator: false
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.5).

Change log:
Prevent a JS error related to app badge updates if the input value isn't the expected type.
There may be a delay before changes are rolled out to the XenForo Community.
Top Bottom