[wp-trac] [WordPress Trac] #31590: Comment reply links can cause JS error on slow connections/large pages
WordPress Trac
noreply at wordpress.org
Fri May 15 00:10:32 UTC 2015
#31590: Comment reply links can cause JS error on slow connections/large pages
---------------------------+-----------------------------------
Reporter: peterwilsoncc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 2.7
Severity: normal | Resolution:
Keywords: has-patch | Focuses: javascript, template
---------------------------+-----------------------------------
Comment (by peterwilsoncc):
Few thoughts on my patch above:
* it works but is sub sub-optimal
* people have strong feelings about inline JavaScript, so lets not.
I've started reworking comment-reply.js to make it unobtrusive. Before
going to far, I wanted to check I was on the correct path and fitting with
core's preferred techniques, particularly around data attributes. My
thoughts are:
Reply link markup becomes:
{{{#!xml
<a class="comment-reply-link"
href="http://example.com/sample-post/?replytocom=1299#respond"
data-comment-id="1299"
data-comment-reply-to-text="Reply to [commenter name]"
aria-label="Reply to commenter" >
}}}
Comment-reply.js config data is created as:
{{{#!js
var _wpCommentReplySettings = {
"postId": 700,
"respondId" : "respond",
"addbelow" : "comment",
"replyText" : __( 'Reply' ),
"loginText" : __( 'Log in to Reply' )
};
}}}
Additionally, move into `window.wp.commentReply` name space. The init
function would run once the DOM is ready but also be globalised to allow
theme authors to re-run if they load the comment thread via JavaScript or
similar.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31590#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list