[wp-trac] [WordPress Trac] #48543: Uncaught TypeError in comment-reply.js when 'id_form' is not 'commentform'
WordPress Trac
noreply at wordpress.org
Sat Nov 9 01:02:22 UTC 2019
#48543: Uncaught TypeError in comment-reply.js when 'id_form' is not 'commentform'
--------------------------+-----------------------------
Reporter: raamdev | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: trunk
Severity: normal | Keywords: needs-patch
Focuses: javascript |
--------------------------+-----------------------------
When `comment_form()` is passed and `id_form` argument other than the
default of `commentform`, clicking the Reply link on a comment produces
the following error in the JavaScript console:
`Uncaught TypeError: Cannot read property 'addEventListener' of null`
This results in the page refreshing and defaulting to the non-JS behavior,
breaking the intended functionality of moving the comment reply form
underneath the comment being replied to.
It looks like this bug was introduced in r45790, where it's assumed that
`commentFormElement` contains a non-null reference to the comment form ID
(`config.commentFormId`), which is set to an ID of `commentform`. If the
ID is anything other than `commentform`, the Uncaught TypeError is
produced.
To reproduce the bug in trunk, you can modify `comment_form()` in
`twentynineteen/inc/template-tags.php` to specify a custom comment form
element id attribute (anything other than the default of `commentform`
produces the bug):
{{{#!php
<?php
comment_form(
array(
'logged_in_as' => null,
'title_reply' => null,
'id_form' => 'commentform-' . get_the_ID()
)
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48543>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list