diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js
index fae92ee237..7398cc409e 100644
a
|
b
|
|
10 | 10 | */ |
11 | 11 | window.addComment = ( function( window ) { |
12 | 12 | // Avoid scope lookups on commonly used variables. |
13 | | var document = window.document; |
| 13 | var document; |
14 | 14 | |
15 | 15 | // Settings. |
16 | 16 | var config = { |
… |
… |
window.addComment = ( function( window ) { |
23 | 23 | }; |
24 | 24 | |
25 | 25 | // Cross browser MutationObserver. |
26 | | var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; |
| 26 | var MutationObserver; |
27 | 27 | |
28 | 28 | // Check browser cuts the mustard. |
29 | | var cutsTheMustard = 'querySelector' in document && 'addEventListener' in window; |
| 29 | var cutsTheMustard; |
30 | 30 | |
31 | | /* |
32 | | * Check browser supports dataset. |
33 | | * !! sets the variable to true if the property exists. |
34 | | */ |
35 | | var supportsDataset = !! document.body.dataset; |
| 31 | // Check browser supports dataset. |
| 32 | var supportsDataset; |
36 | 33 | |
37 | 34 | // For holding the cancel element. |
38 | 35 | var cancelElement; |
… |
… |
window.addComment = ( function( window ) { |
46 | 43 | // The mutation observer. |
47 | 44 | var observer; |
48 | 45 | |
49 | | // Initialise the events. |
50 | | init(); |
| 46 | if ( window.document && window.document.body ) { |
| 47 | ready(); |
| 48 | } else if ( window.addEventListener ) { |
| 49 | window.addEventListener( 'DOMContentLoaded', ready, false ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Sets up object variables after the DOM is ready. |
| 54 | * |
| 55 | * @since 5.1.0 |
| 56 | */ |
| 57 | function ready() { |
| 58 | document = window.document; |
| 59 | |
| 60 | MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; |
| 61 | |
| 62 | // Check browser cuts the mustard. |
| 63 | cutsTheMustard = 'querySelector' in document && 'addEventListener' in window; |
51 | 64 | |
52 | | // Set up a MutationObserver to check for comments loaded late. |
53 | | observeChanges(); |
| 65 | // !! sets the variable to true if the property exists. |
| 66 | supportsDataset = !! document.body.dataset; |
| 67 | |
| 68 | // Initialise the events. |
| 69 | init(); |
| 70 | |
| 71 | // Set up a MutationObserver to check for comments loaded late. |
| 72 | observeChanges(); |
| 73 | } |
54 | 74 | |
55 | 75 | /** |
56 | 76 | * Add events to links classed .comment-reply-link. |