Skip to content

Commit 5032b7f

Browse files
Merge pull request #285 from Yoast/QAK-2538-hotfix-error-on-term-pages
QAK-2538 hotfix error on term pages
2 parents e839eaf + dd8e765 commit 5032b7f

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

js/src/main.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
/* global jQuery, YoastSEO, wp, YoastACFAnalysis: true */
22
/* exported YoastACFAnalysis */
33

4-
var App = require( "./app.js" );
4+
const App = require( "./app.js" );
5+
6+
/**
7+
* Initializes the YoastACFAnalysis app.
8+
*
9+
* @returns {void}
10+
*/
11+
function initializeYoastACFAnalysis() {
12+
YoastACFAnalysis = new App();
13+
}
514

615
wp.domReady( function() {
7-
if ( "undefined" !== typeof YoastSEO ) {
8-
YoastACFAnalysis = new App();
16+
if ( ! ( YoastSEO && YoastSEO.app ) ) {
17+
// Give it one more attempt in 100ms.
18+
setTimeout( initializeYoastACFAnalysis, 100 );
19+
return;
920
}
21+
22+
initializeYoastACFAnalysis();
1023
} );

js/yoast-acf-analysis.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,25 @@ module.exports = {
398398
/* global jQuery, YoastSEO, wp, YoastACFAnalysis: true */
399399
/* exported YoastACFAnalysis */
400400

401-
var App = require( "./app.js" );
401+
const App = require( "./app.js" );
402+
403+
/**
404+
* Initializes the YoastACFAnalysis app.
405+
*
406+
* @returns {void}
407+
*/
408+
function initializeYoastACFAnalysis() {
409+
YoastACFAnalysis = new App();
410+
}
402411

403412
wp.domReady( function() {
404-
if ( "undefined" !== typeof YoastSEO ) {
405-
YoastACFAnalysis = new App();
413+
if ( ! ( YoastSEO && YoastSEO.app ) ) {
414+
// Give it one more attempt in 100ms.
415+
setTimeout( initializeYoastACFAnalysis, 100 );
416+
return;
406417
}
418+
419+
initializeYoastACFAnalysis();
407420
} );
408421

409422
},{"./app.js":1}],9:[function(require,module,exports){

0 commit comments

Comments
 (0)