Make sure that wrapInner works on elements that have no contents. Fixes #3552.
[jquery.git] / src / manipulation.js
index 3db2c35..742ec25 100644 (file)
@@ -77,7 +77,14 @@ jQuery.fn.extend({
 
        wrapInner: function( html ) {
                return this.each(function() {
-                       jQuery( this ).contents().wrapAll( html );
+                       var self = jQuery( this ), contents = self.contents();
+
+                       if ( contents.length ) {
+                               contents.wrapAll( html );
+
+                       } else {
+                               self.append( html );
+                       }
                });
        },