diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js
index 71f997328e..7e147c17d5 100644
|
a
|
b
|
window.addComment = ( function( window ) { |
| 40 | 40 | // The respond element. |
| 41 | 41 | var respondElement; |
| 42 | 42 | |
| | 43 | // The mutation observer. |
| | 44 | var observer; |
| | 45 | |
| 43 | 46 | // Initialise the events. |
| 44 | 47 | init(); |
| 45 | 48 | |
| | 49 | // Set up a MutationObserver to check for comments loaded late. |
| | 50 | observeChanges(); |
| | 51 | |
| 46 | 52 | /** |
| 47 | 53 | * Add events to links classed .comment-reply-link. |
| 48 | 54 | * |
| … |
… |
window.addComment = ( function( window ) { |
| 164 | 170 | } |
| 165 | 171 | } |
| 166 | 172 | |
| | 173 | /** |
| | 174 | * Creates a mutation observer to check for newly inserted comments. |
| | 175 | */ |
| | 176 | function observeChanges() { |
| | 177 | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; |
| | 178 | var observerOptions = { |
| | 179 | characterData: false, |
| | 180 | childList: true, |
| | 181 | subTree: true, |
| | 182 | }; |
| | 183 | |
| | 184 | if ( ! MutationObserver ) { |
| | 185 | return; |
| | 186 | } |
| | 187 | |
| | 188 | observer = new MutationObserver( handleChanges ); |
| | 189 | observer.observe( document.body, observerOptions ); |
| | 190 | } |
| | 191 | |
| | 192 | /** |
| | 193 | * Handles DOM changes, passing added nodes to init(). |
| | 194 | * |
| | 195 | * @since 5.1.0 |
| | 196 | * |
| | 197 | * @param {MutationRecord} mutations Object containing changes to the DOM document. |
| | 198 | */ |
| | 199 | function handleChanges( mutations ) { |
| | 200 | init( mutations.addedNodes ); |
| | 201 | } |
| | 202 | |
| 167 | 203 | /** |
| 168 | 204 | * Backward compatible getter of data-* attribute. |
| 169 | 205 | * |