[jQuery] re-assignable document object

[jQuery] re-assignable document object


Hi folks,
I'm trying to write a quick Firefox extension making use of jQuery.
I'd like to use jQuery on both sides of the chrome/unsafe "barrier".
All the code runs from (or is generated from) the chrome side.
I've found that one has to pass around an "unsafe" document object and
supply it to most jQuery traversal/selector methods (at least the
first one in a chain), like so:
var doc = gContextMenu.target.ownerDocument.wrappedJSObject;
$('#someDiv',doc).foo().bar().baz();
... and that one has to use [doc].createElement directly, instead of
simpler string-based jQuery methods.
It'd be nice if I could do something like
u$ = $.reParent(doc);
and the use u$ for manipulations in the "unsafe" document from that
point on.
Am I missing something?
-David