diff --git a/src/manipulation.js b/src/manipulation.js index 00e31201..325f303a 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -248,10 +248,8 @@ jQuery.fn.extend({ } else if ( jQuery.isFunction( value ) ) { this.each(function(i){ - var self = jQuery(this), old = self.html(); - self.empty().append(function(){ - return value.call( this, i, old ); - }); + var self = jQuery(this); + self.html( value.call(this, i, self.html()) ); }); } else { diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 2fc6f188..7b4f4d15 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -955,6 +955,17 @@ test("html(String)", function() { test("html(Function)", function() { testHtml(functionReturningObj); + + expect(33); + + QUnit.reset(); + + jQuery("#main").html(function(){ + return jQuery(this).text(); + }); + + ok( !/ 0, "Make sure text exists." ); }); test("html(Function) with incoming value", function() {