I'm asking this question here because this functionality is standard to all UI widgets, and is handled by the widget factory...
I have a jQuery plugin - which I will convert to a UI widget in the next version - but in the current, non-widget version I want to bind an Instance object/pointer to the widget-element(s) using .data(). In other words, I want to replicate what all UI widgets do, for example:
var Instance = $("#myDraggableElem").data("draggable");
Internally, my plug-in maintains static object pointers to the widget elements, so my concern/question is:
Will adding an instance pointer using .data() potentially create a memory leak since technically there would now be a circular reference between the element and the widget instance - each points to the other. Does the widget factory include special handling for these instance pointers OR is using jQuery .data() automatically safe from these types of issues?
I suspect the latter is true, but I'm hoping someone familiar with the inner workings both data() and UI widgets can confirm this before I do it. I would hate to create a nasty memory leak!
Thanks in advance for any input.