Fix up whitespace and a couple of glitches.
[jquery.git] / src / manipulation.js
index 0c2753e..17cfa84 100644 (file)
@@ -32,6 +32,12 @@ if ( !jQuery.support.htmlSerialize ) {
 
 jQuery.fn.extend({
        text: function( text ) {
+               if(jQuery.isFunction(text)) {
+                       return this.each(function() {
+                               return jQuery(this).text( text.call(this) );
+                       });
+               }
+
                if ( typeof text !== "object" && text !== undefined ) {
                        return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
                }
@@ -87,7 +93,7 @@ jQuery.fn.extend({
                        }
                }).end();
        },
-       
+
        append: function() {
                return this.domManip(arguments, true, function(elem){
                        if ( this.nodeType === 1 ) {
@@ -277,13 +283,7 @@ function cloneCopyEvent(orig, ret) {
                        return;
                }
 
-               var events = jQuery.data( orig[i], "events" );
-
-               for ( var type in events ) {
-                       for ( var handler in events[ type ] ) {
-                               jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
-                       }
-               }
+               jQuery.data( this, jQuery.data( orig[i++] ) );
        });
 }