Skip to content

Commit

Permalink
Early exit from event listener if webmonetization is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Oct 21, 2020
1 parent 1a472f4 commit 01de1a2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion webmonetization/lib/web/library_webmonetization.js
Expand Up @@ -9,6 +9,10 @@ var WebMonetizationLibrary = {
WebMonetization_PlatformSetEventListener: function(listener) {
Context.listener = listener;

if (document.monetization === undefined) {
return;
}

document.monetization.addEventListener("", event => {
dynCall("vii", Context.listener, [
allocate(intArrayFromString("monetizationpending"), "i8", ALLOC_STACK),
Expand Down Expand Up @@ -36,7 +40,7 @@ var WebMonetizationLibrary = {
},

WebMonetization_PlatformIsMonetized: function() {
return document.monetization != undefined && document.monetization.state == "started";
return document.monetization !== undefined && document.monetization.state == "started";
}

};
Expand Down

0 comments on commit 01de1a2

Please sign in to comment.