[
https://issues.apache.org/jira/browse/CB-633?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Filip Maj resolved CB-633.
--------------------------
Resolution: Fixed
Fixed in
[6cb6e6|https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=commit;h=6cb6e6cfb5d85017d2b2f24203d9078f1be775a8].
Thanks for the suggestion Hugo, but your solution fails in another case: where
you have some handlers subscribed, but you call unsubscribe with a
non-subscribed ID or function.
I've added tests for both cases, and tweaked the solution to first check for
the existence of the handler with the passed-in ID.
> overriding backbutton is broken when removeEventListener() is called before
> addEventListener()
> ----------------------------------------------------------------------------------------------
>
> Key: CB-633
> URL: https://issues.apache.org/jira/browse/CB-633
> Project: Apache Cordova
> Issue Type: Bug
> Components: CordovaJS
> Affects Versions: 1.6.1, 1.7.0
> Reporter: Hugo
> Assignee: Filip Maj
> Labels: android, backbutton
> Fix For: 1.8.0
>
>
> If document.removeEventListener("backbutton", function(){}, false) is called
> before the addEventListener(), the backbutton default behavior isn't
> overriden.
> To reproduce:
> document.removeEventListener("backbutton", function(){}, false)
> document.addEventListener("backbutton", function(){}, false)
> // ..backbutton default behavior should be overridden (but it's not)
> On the other hand the following will work as expected:
> document.addEventListener("backbutton", function(){}, false)
> // ..ok, backbutton default behavior is overridden
> This is a bigger problem than it looks because developers don't (and
> shouldn't) keep track of how many times removeEventListener() was called
> before calling addEventListener().
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira