Last modified: 2014-03-13 17:45:19 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T59037, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 57037 - OOjs: EventEmitter#disconnect shouldn't throw if there are no bindings
OOjs: EventEmitter#disconnect shouldn't throw if there are no bindings
Status: RESOLVED WONTFIX
Product: OOjs
Classification: Unclassified
EventEmitter (Other open bugs)
unspecified
All All
: High major
: ---
Assigned To: Krinkle
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-13 23:19 UTC by Krinkle
Modified: 2014-03-13 17:45 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Krinkle 2013-11-13 23:19:12 UTC
surface.disconnect( this, { 'toolbarPosition': 'positionPhantoms' } );
This throws Uncaught TypeError: Cannot read property 'length' of undefined when no such event has been bound first.

oo.EventEmitter.prototype.disconnect = function ( context, methods ) {
    /* .. */
        for ( event in methods ) {
            method = methods[event];
            /* .. */
            bindings = this.bindings[event];
            i = bindings.length; /* ! */
It should silently skip it.


----
Moved from https://github.com/trevorparscal/oojs/issues/18.
Comment 1 Krinkle 2014-03-13 17:45:19 UTC
The no-op feature to allow calling disconnect() when no events are bound yet already exists. Change Ibe1d4747c05 adds tests to reflect this.

However when passing a host object that not only contains event handlers for events not (yet) bound, but explicitly specifying methods to unbind, then those methods have to exist (it's fine if they aren't bound as listeners, but they have to exist).

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links