php – Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5


I am getting the following error from comment-reply.min.js (which seems to be a WordPress file):

Uncaught TypeError: Cannot read property 'firstChild' of null
    at comment-reply.min.js?ver=026d5828124b6319675d89d24f212b97:2
    at Object.moveForm (comment-reply.min.js?ver=026d5828124b6319675d89d24f212b97:2)
    at HTMLAnchorElement.a (comment-reply.min.js?ver=026d5828124b6319675d89d24f212b97:2)

Is this a known issue after upgrading to WordPress 5.5 or should I start debugging it?

What would be the best way to address it?

We have not changed the comments template but only upgraded to the latest version of WordPress.

The relevant part of the template is:

<?php comment_id_fields($_GET("post_id")); ?>
<?php do_action('comment_form', $_GET("post_id")); ?>
            
<div class="fl-comment-form-cancel">
   <?php cancel_comment_reply_link(); ?>
</div>

After a quick check, it seems it is searching for an element with the id wp-temp-form-div, which does not exist.

And the issue seems to be here:

, r = E(h.commentReplyTitleId)
, o = void 0 !== r ? r.firstChild.textContent : “”;

If commentReplyTitleId does not exist, r will be null, hence different than undefined, so it tries to get the firstChild.


A quick workaround I’m using:

(function () {
    var oldGet = document.getElementById.bind(document)
    document.getElementById = function (id) { return oldGet(id) || undefined; }
})();

But to me it seems like a bug in 5.5.