mirror of
git://develop.git.wordpress.org/
synced 2025-04-27 23:53:02 +02:00
Comments: Allow for comment-reply.js
to be loaded in the HTML header.
Allows for themes or plugins setting the comment-reply JavaScript as a dependency of an HTML header script. This in turn causes `comment-reply.js` to be loaded early, requiring execution to be delayed. Props pento, peterwilsoncc, jorbin for feedback. Fixes #46280. git-svn-id: https://develop.svn.wordpress.org/trunk@44794 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e8fa2d66d0
commit
da4f8d0ffb
@ -32,7 +32,7 @@ window.addComment = ( function( window ) {
|
||||
* Check browser supports dataset.
|
||||
* !! sets the variable to true if the property exists.
|
||||
*/
|
||||
var supportsDataset = !! document.body.dataset;
|
||||
var supportsDataset = !! document.documentElement.dataset;
|
||||
|
||||
// For holding the cancel element.
|
||||
var cancelElement;
|
||||
@ -46,11 +46,24 @@ window.addComment = ( function( window ) {
|
||||
// The mutation observer.
|
||||
var observer;
|
||||
|
||||
// Initialise the events.
|
||||
init();
|
||||
if ( cutsTheMustard && document.readyState !== 'loading' ) {
|
||||
ready();
|
||||
} else if ( cutsTheMustard ) {
|
||||
window.addEventListener( 'DOMContentLoaded', ready, false );
|
||||
}
|
||||
|
||||
// Set up a MutationObserver to check for comments loaded late.
|
||||
observeChanges();
|
||||
/**
|
||||
* Sets up object variables after the DOM is ready.
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
function ready() {
|
||||
// Initialise the events.
|
||||
init();
|
||||
|
||||
// Set up a MutationObserver to check for comments loaded late.
|
||||
observeChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add events to links classed .comment-reply-link.
|
||||
@ -163,6 +176,14 @@ window.addComment = ( function( window ) {
|
||||
postId = getDataAttribute( replyLink, 'postid'),
|
||||
follow;
|
||||
|
||||
if ( ! commId || ! parentId || ! respondId || ! postId ) {
|
||||
/*
|
||||
* Theme or plugin defines own link via custom `wp_list_comments()` callback
|
||||
* and calls `moveForm()` either directly or via a custom event hook.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Third party comments systems can hook into this function via the global scope,
|
||||
* therefore the click event needs to reference the global scope.
|
||||
|
Loading…
x
Reference in New Issue
Block a user