Avoid JS errors if Sourcebuster library isn't loaded (#46723)

* Don't initialize or handle data if SBJS isn't loaded
This commit is contained in:
Justin Palmer 2024-04-19 12:24:10 +02:00 committed by GitHub
parent afc471d0ed
commit 2d71790b72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Add a bailout to prevent JavaScript errors if Sourcebuster isn't loaded

View File

@ -65,6 +65,8 @@
if ( ! allow ) {
// Reset cookies, and clear form data.
removeTrackingCookies();
} else if ( typeof sbjs === 'undefined' ) {
return; // Do nothing, as sourcebuster.js is not loaded.
} else {
// If not done yet, initialize sourcebuster.js which populates `sbjs.get` object.
sbjs.init( {