Stop WordPress from stripping out custom element

I am using the Tatsu page builder and using their Code module to insert dotlottie code, such as:

<dotlottie-player src="https://lottie.host/******************.lottie" background="transparent" speed="1"  loop autoplay></dotlottie-player>

This works fine; however when I use the usual WordPress Update button for other reasons not related to the page builder, WordPress strips out this code.

I have tried adding the below code to functions.php, but it still got stripped.

function allow_lottie_tags($tags, $context) {
    // Add for all contexts
    $allowed_atts = array(
        'src' => true,
        'background' => true,
        'speed' => true,
        'loop' => true,
        'autoplay' => true,
        'class' => true,
        'id' => true,
        'style' => true
    );

    // Apply to both default and 'post' context
    if ($context === 'post' || $context === 'default') {
        $tags['dotlottie-player'] = $allowed_atts;
    }

    return $tags;
}

// Apply to multiple filters to catch different contexts
add_filter('wp_kses_allowed_html', 'allow_lottie_tags', 999, 2);
add_filter('post_allowed_html', 'allow_lottie_tags', 999, 2);

I then tried adding this, with no luck.

// Also try to force it globally
function hook_lottie_early() {
    global $allowedposttags, $allowedtags;

    $allowed_atts = array(
        'src' => true,
        'background' => true,
        'speed' => true,
        'loop' => true,
        'autoplay' => true,
        'class' => true,
        'id' => true,
        'style' => true
    );

    $allowedposttags['dotlottie-player'] = $allowed_atts;
    $allowedtags['dotlottie-player'] = $allowed_atts;
}
add_action('init', 'hook_lottie_early', 1);

What am I doing wrong? Should I go to a dynamic shortcode instead, or is there another way to handle this?