On Tue, Oct 16, 2012 at 3:38 PM, TheRave <
micha....@arcor.de> wrote:
> Hello,
>
> according my tests for removing an eventlistener definied for a anonymous
> function i found a solution, but i doesn't know why this works.
>
> var myExtension = {
> init: ....
>
> },
> onPageLoad: function(aEvent) {
>
> var test = "test";
>
> doc.addEventListener("textAreaEvent", afunc =
> function(evt){onChangeTextArea(evt, data);}, false);
>
>
Unless you have a 'var afunc' in a smaller scope, this sets 'afunc' in the
global scope.
So no surprise here.
> ....
> },
>
> onPageUnload: function(aEvent) {
> //alert(test); <---- of course unknown
>
> alert(afunc); <----Why is afunc known here?
>
> aEvent.originalTarget.removeEventListener("textAreaEvent",
> afunc, false);
>
> Can somebody give me an explanation why this workarround works and afunc
> is well known for onPageUnload? There is no global var afunc defined it was
> only done in addeventlistener.
> _______________________________________________
> dev-extensions mailing list
>
dev-ext...@lists.mozilla.org
>
https://lists.mozilla.org/listinfo/dev-extensions
>