Make sure that the node exists before attempting to clone.
[jquery.git] / src / manipulation.js
index baab8c6..d5523dd 100644 (file)
@@ -32,11 +32,11 @@ 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(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 ) );
@@ -279,7 +279,7 @@ function cloneCopyEvent(orig, ret) {
        var i = 0;
 
        ret.each(function(){
-               if ( this.nodeName !== orig[i].nodeName ) {
+               if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
                        return;
                }