aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/manipulation.js6
-rw-r--r--test/unit/manipulation.js11
2 files changed, 13 insertions, 4 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 00e31201c..325f303a8 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 2fc6f1889..7b4f4d159 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( !/</.test( jQuery("#main").html() ), "Replace html with text." );
+ ok( jQuery("#main").html().length > 0, "Make sure text exists." );
});
test("html(Function) with incoming value", function() {