> > $.extend(foo) merely returns a reference to foo. It doesn't 
> > clone foo.
> >
> > $.extend( {}, foo ) creates a new object and copies all of foo's 
> > properties into it (doing a shallow copy).
> >
> > So in theory you may be able to use $.extend( {}, $ ) - or more 
> > properly, jQuery( {}, jQuery ) - to clone the jQuery constructor. I 
> > wouldn't promise that this would work, though - it depends on what 
> > assumptions the jQuery code makes.

>    This also doesn't work. I have tried both $.extend({}, $) 
> and $.extend(true, {}, $). This results in $D('body') is not 
> a function error. Seems that it doesn't copy really.

That's what I get for posting late at night. Of course that wouldn't work,
because you need to clone the jQuery constructor function itself - which {}
doesn't do.

This would have a better chance of working:

  $D = eval( '' + jQuery );
  $D.prototype = jQuery.extend( {}, jQuery.prototype );

A quick test seems to work - but I'm not sure about cross-browser support,
and there could be issues because of assumptions made inside the jQuery
code.

I still don't understand the need for this, though. You mentioned
performance, and a solution involving event delegation. Event delegation is
the first thing I turn toward when there are performance problems caused by
too many event handlers - and you don't need a special version of jQuery to
use it.

-Mike

Reply via email to