Racking my brain about stateful DOM elements and jQuery's .data()

Racking my brain about stateful DOM elements and jQuery's .data()

Hi,

I am new to jQuery and am about to embark on an intrepid venture to bend jQuery to my whim.  Before I do so, I thought I had better first ask the experts here for their considered opinion.  Here goes my cunning plan (almost real code):

function myStatefulObject( sthg ) {
// Parent:
var that= jQuery( sthg );        // "sthg" is any valid jQuery selector expression and "that" will
                                                  // become a new object *derived* from that selector.
// Private:
var someState;                     // This is what it's all about: I need to keep some XML data associated
                                                   // with the DOM element.
// Public:
that.method= function(...) {
// using private state data
};
that.data( "myInterface", that );
return that;
}

Two questions at this juncture.
(1)  I have some reservations about deriving from (as opposed to containing) the jQuery object.  I will  obviously need to make sure that my that.method()s don't clash with existing jQuery methods, which I can.  This doesn't though ward against future releases of jQuery using my names for completely different purposes.  Won't break my code, clearly, since it could not have relied on these functions at the time.  Might just look odd to future readers who by then will have different expectations...  Any views?
(2)  Please confirm to me that the line in BOLD is really really well and truly OK.  On the face of it, I am creating a circular reference.  I know the .data() manual says not to worry.  But I do.  Is it kosher?

I can now insert this stateful object into the DOM like so:

myStatefulObject("<div>")
.id( "myStatefulObject" )
.addClass( "ui-widget ui-content" )
.appendTo( $("body") );

Job done.  Easy.  Here comes the audacious proposal - fasten seat-belts:

$= function( sthg ) {                                 // Overloading trusty old $ - life's a box of chocolates
var jqo= jQuery( sthg );                    // So far so harmless - a mere indirection. 
var that= jqo.data( "myInterface" );    // Worth a shot ... "sthg" might just be one of mine
return that || jqo;
}

With that done, I should now be able to recover my stateful jQuery object using the usual moniker:

$("#myStatefulObject").method(...);

Does this make sense / seem like a good/awful idea?

Appreciate your input.