File tree Expand file tree Collapse file tree
src/test/java/org/jsoup/nodes Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77import org .jsoup .select .NodeVisitor ;
88import org .junit .jupiter .api .Test ;
99
10+ import java .util .Collections ;
1011import java .util .List ;
1112
1213import 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 ();
You can’t perform that action at this time.
0 commit comments