Ticket #8385 (closed bug: fixed)

Opened 12 months ago

Last modified 10 months ago

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

Reported by: scott.gonzalez Owned by:
Priority: blocker Milestone: git
Component: ui.widget Version: git
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 12 months ago by scott.gonzalez

  • Priority changed from minor to blocker
  • Status changed from new to open

comment:2 Changed 12 months ago by scott.gonzalez

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 12 months ago by scott.gonzalez

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

comment:4 Changed 12 months ago by joern.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 12 months ago by joern.zaefferer

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

  • Status changed from open to closed
  • Resolution set to fixed

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 10 months ago by scott.gonzalez

  • Milestone changed from 1.9.0 to git
Note: See TracTickets for help on using tickets.