A common pattern that we see in review of Mozilla addons is code that looks like the following:
var myExtension = { saveMe: null, onLoad: function () { this.saveMe = “I am saved”; } } window.addEventListener(“load”, myExtension.onLoad);
Unfortunately the value of “this.saveMe” that is used in onLoad is the value from the global window, not the value from the myExtension object. Really the event listener is looking for an object of type nsIDOMEventListener, with a method handleEvent. When it does not find that, it applies some magic and just uses the entered function. Unfortunately, in the process the “this” does [...]

Recent Comments