Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#8385 closed bug (fixed)

Widget: _bind() on elements such as document are dangerous

Reported by: Scott González Owned by:
Priority: blocker Milestone: git
Component: ui.widget Version: git (not yet released)
Keywords: Cc:
Blocked by: Blocking:

Description

If all instances of a widget are binding to a common element, such as document, then when one instance of destroyed all event handlers will be unbound. This is problematic and needs to be addressed somehow.

Change History (8)

comment:1 Changed 11 years ago by Scott González

Priority: minorblocker
Status: newopen

comment:2 Changed 11 years ago by Scott González

One thought is that we can just be aware of the problem and avoid doing this. It's not specific to _bind() anyway. We'd need to have a single event handler that manages all instances. We could potentially make this easier by having the widget factory automatically track all instances. This shouldn't be too bad in terms of memory since it's just an array of pointers. For example, right now we're tracking all droppable instances in the interactions rewrite. We could just automatically track this in $.ui.droppable.instances.

comment:3 Changed 11 years ago by Scott González

Suggestion from gnarf: Create a uuid for all instances and use the uuid in the namespace inside _bind().

comment:4 Changed 11 years ago by Jörn Zaefferer

Adding a uuid to the namespace is also what Backbone's delegateEvents method does: http://documentcloud.github.com/backbone/docs/backbone.html#section-156

Note eventName += '.delegateEvents' + this.cid;

comment:5 Changed 11 years ago by Jörn Zaefferer

comment:7 Changed 11 years ago by Jörn Zaefferer

Resolution: fixed
Status: openclosed

Generate a uuid for each widget for unique namespaces. Fixes #8385 - Widget: _bind() on elements such as document are dangerous

Changeset: 28b14ec47cfeb3c58e44f35170cdd8a9270aceae

comment:8 Changed 11 years ago by Scott González

Milestone: 1.9.0git
Note: See TracTickets for help on using tickets.