Skip to main content

Search and Top Navigation

#8385 closed bug (fixed)

Opened June 06, 2012 05:26PM UTC

Closed June 14, 2012 04:33PM UTC

Last modified August 01, 2012 06:04PM UTC

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

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

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.

Attachments (0)
Change History (8)

Changed June 06, 2012 05:26PM UTC by scottgonzalez comment:1

priority: minorblocker
status: newopen

Changed June 06, 2012 05:36PM UTC by scottgonzalez comment:2

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.

Changed June 06, 2012 05:53PM UTC by scottgonzalez comment:3

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

Changed June 07, 2012 10:35AM UTC by jzaefferer comment:4

Adding a uuid to the namespace is also what Backbone's delegateEvents method does:

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

Changed June 10, 2012 03:23PM UTC by jzaefferer comment:5

Changed June 10, 2012 06:58PM UTC by jzaefferer comment:6

Changed June 14, 2012 04:33PM UTC by Jörn Zaefferer comment:7

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

Changed August 01, 2012 06:04PM UTC by scottgonzalez comment:8

milestone: 1.9.0git