Skip to content

Commit 0cb661e

Browse files
committed
.clone(): Remove last example because it deals with rare edge case and can be confusing
1 parent 6df983d commit 0cb661e

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

entries/clone.xml

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -64,43 +64,6 @@
6464
]]></code>
6565
<html><![CDATA[
6666
<b>Hello</b><p>, how are you?</p>
67-
]]></html>
68-
</example>
69-
<example>
70-
<desc>When using <code>.clone()</code> to clone a collection of elements that are not attached to the DOM, their order when inserted into the DOM is not guaranteed. However, it may be possible to preserve sort order with a workaround, as demonstrated:</desc>
71-
<css><![CDATA[
72-
#orig, #copy, #copy-correct {
73-
float: left;
74-
width: 20%;
75-
}
76-
]]></css>
77-
<code><![CDATA[
78-
// sort order is not guaranteed here and may vary with browser
79-
$('#copy').append($('#orig .elem')
80-
.clone()
81-
.children('a')
82-
.prepend('foo - ')
83-
.parent()
84-
.clone());
85-
86-
// correct way to approach where order is maintained
87-
$('#copy-correct')
88-
.append($('#orig .elem')
89-
.clone()
90-
.children('a')
91-
.prepend('bar - ')
92-
.end());
93-
]]></code>
94-
<html><![CDATA[
95-
<div id="orig">
96-
<div class="elem"><a>1</a></div>
97-
<div class="elem"><a>2</a></div>
98-
<div class="elem"><a>3</a></div>
99-
<div class="elem"><a>4</a></div>
100-
<div class="elem"><a>5</a></div>
101-
</div>
102-
<div id="copy"></div>
103-
<div id="copy-correct"></div>
10467
]]></html>
10568
</example>
10669
<category slug="manipulation/copying"/>

0 commit comments

Comments
 (0)