[wp-trac] [WordPress Trac] #46260: 5.1 Backwards Compatibility Issue: comment-reply.js

WordPress Trac noreply at wordpress.org
Fri Feb 15 21:56:14 UTC 2019


#46260: 5.1 Backwards Compatibility Issue: comment-reply.js
--------------------------+-----------------------------
 Reporter:  iCaleb        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 tl;dr -> The changes made to comment-reply.js for the 5.1 release cause BC
 issues when comments are loaded in after the initial page load (via ajax
 for example). The reply link does not work as expected anymore, and can
 break commenting completely depending on the implementation.

 == Issue Description

 In WP 5.0 and before, the comment reply links were hardcoded to the
 onclick event, seen here:
 https://github.com/WordPress/WordPress/commit/f617a2d6d932e658449cef1b7864fb77080ecd09
 #diff-3db08a6b98155b349c93a220bc903dceL1670

 But in 5.1+ (since https://core.trac.wordpress.org/ticket/31590),
 `comment-reply.js` initializes by binding these links to the event
 handler. The problem is though, these links won't exist yet when the
 script is first loaded since they come in later via ajax.

 == Replicating / Solutions

 I first replicated on a site using a custom ajax implementation, but you
 can get a similar result using a plugin like https://wordpress.org/plugins
 /ajax-comment-loading/. Test on 5.0 versus 5.1 and you can see the
 difference.

 To maintain backwards compatibility, the comment reply script should take
 into consideration that the links won't always be on the page right away
 when the script is first loaded.

 As a fix for individual sites/plugins though (in case somebody stumbles
 across this ticket), you can call `window.addComment.init();` at the end
 of your ajax callback to ensure the links get bound to the needed event
 handlers.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46260>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list