Skip to content

Commit 22f9670

Browse files
committed
Unit test for Ticket #5986 - replaceWith mishandles strings
1 parent ca6993f commit 22f9670

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ <h2 id="qunit-userAgent"></h2>
5252
<p id="sndp">Everything inside the red border is inside a div with <code>id="foo"</code>.</p>
5353
<p lang="en" id="en">This is a normal link: <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p>
5454
<p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
55-
5655
</div>
56+
<div id="bar"><div id="baz">Foo</div></div>
5757
<span id="name+value"></span>
5858
<p id="first">Try them out:</p>
5959
<ul id="firstUL"></ul>

test/unit/manipulation.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
650650
});
651651

652652
var testReplaceWith = function(val) {
653-
expect(15);
653+
expect(17);
654654
jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' ));
655655
ok( jQuery("#replace")[0], 'Replace element with string' );
656656
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
@@ -660,6 +660,11 @@ var testReplaceWith = function(val) {
660660
ok( jQuery("#first")[0], 'Replace element with element' );
661661
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
662662

663+
reset();
664+
jQuery('#baz').replaceWith("Baz");
665+
equals( jQuery("#bar").text(),"Baz", 'Replace element with text' );
666+
ok( !jQuery("#baz")[0], 'Verify that original element is gone, after element' );
667+
663668
reset();
664669
jQuery('#yahoo').replaceWith(val( [document.getElementById('first'), document.getElementById('mark')] ));
665670
ok( jQuery("#first")[0], 'Replace element with array of elements' );
@@ -721,7 +726,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
721726
test("replaceWith(Function)", function() {
722727
testReplaceWith(functionReturningObj);
723728

724-
expect(16);
729+
expect(18);
725730

726731
var y = jQuery("#yahoo")[0];
727732

0 commit comments

Comments
 (0)