admin管理员组文章数量:1122833
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(hmentReplyTitleId)
, 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.
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.
Share Improve this question edited Aug 25, 2020 at 9:48 Ionică Bizău asked Aug 23, 2020 at 17:26 Ionică BizăuIonică Bizău 3213 gold badges4 silver badges20 bronze badges 1 |1 Answer
Reset to default 0This was fixed in 5.5.1, commit 48877:
Correct the check for reply element existence in
comment-reply.js.
document.getElementById()
returnsnull
if no matching element was found, so the previous comparison didn't work as expected.
本文标签: phpUncaught TypeError Cannot read property 39firstChild39 of null after upgrading to WordPress 55
版权声明:本文标题:php - Uncaught TypeError: Cannot read property 'firstChild' of null after upgrading to WordPress 5.5 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283428a1926964.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
( null != replyElement )
. Go ahead and raise a trac ticket? – Rup Commented Aug 23, 2020 at 17:54