Skip to content

Commit df404cf

Browse files
MicyToyjhy
authored andcommitted
test case for Issue #2212
1 parent 28db617 commit df404cf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/test/java/org/jsoup/nodes/NodeTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.jsoup.select.NodeVisitor;
88
import org.junit.jupiter.api.Test;
99

10+
import java.util.Collections;
1011
import java.util.List;
1112

1213
import static org.jsoup.parser.Parser.*;
@@ -175,6 +176,22 @@ public void handlesAbsOnProtocolessAbsoluteUris() {
175176
assertEquals("One <em>foo</em> three", p.html());
176177
}
177178

179+
/**
180+
* test case for
181+
* <a href="https://github.com/jhy/jsoup/issues/2212">Issue #2212</a>
182+
*/
183+
@Test public void testReplaceTwice() {
184+
Document doc = Jsoup.parse("<p><span>Child One</span><span>Child Two</span><span>Child Three</span><span>Child Four</span></p>");
185+
Elements children = doc.select("p").first().children();
186+
// first swap 0 and 1
187+
children.set(0, children.set(1, children.get(0)));
188+
// then swap 1 and 2
189+
children.set(2, children.set(1, children.get(2)));
190+
191+
assertEquals("Child TwoChild ThreeChild OneChild Four",
192+
TextUtil.stripNewlines(children.html()));
193+
}
194+
178195
@Test public void ownerDocument() {
179196
Document doc = Jsoup.parse("<p>Hello");
180197
Element p = doc.select("p").first();

0 commit comments

Comments
 (0)