Skip to content

Commit e1a33e0

Browse files
mattlunnkswedberg
authored andcommitted
Added notes that replaceWith() and replaceAll() remove node data
1 parent fd64c7c commit e1a33e0

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

entries/replaceAll.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</signature>
1414
<desc>Replace each target element with the set of matched elements.</desc>
1515
<longdesc>
16-
<p>The <code>.replaceAll()</code> method is corollary to <code><a href="/replaceWith/">.replaceWith()</a></code>, but with the source and target reversed. Consider this DOM structure:</p>
16+
<p>The <code>.replaceAll()</code> method is similar to <code><a href="/replaceWith/">.replaceWith()</a></code>, but with the source and target reversed. Consider this DOM structure:</p>
1717
<pre><code>
1818
&lt;div class="container"&gt;
1919
&lt;div class="inner first"&gt;Hello&lt;/div&gt;
@@ -44,6 +44,7 @@ $( ".first" ).replaceAll( ".third" );
4444
</code></pre>
4545
<p>From this example, we can see that the selected element replaces the target by being moved from its old location, not by being cloned.</p>
4646
</longdesc>
47+
<note id="removes-data" type="additional" data-title=".replaceAll()"/>
4748
<example>
4849
<desc>Replace all the paragraphs with bold words.</desc>
4950
<code><![CDATA[

entries/replaceWith.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ $( "div.third" ).replaceWith( $( ".first" ) );
6464
<p>This example demonstrates that the selected element replaces the target by being moved from its old location, not by being cloned.</p>
6565
<p>The <code>.replaceWith()</code> method, like most jQuery methods, returns the jQuery object so that other methods can be chained onto it. However, it must be noted that the <em>original</em> jQuery object is returned. This object refers to the element that has been removed from the DOM, not the new element that has replaced it.</p>
6666
</longdesc>
67+
<note id="removes-data" type="additional" data-title=".replaceWith()"/>
6768
<note id="disconnected-manipulation" type="additional" data-title=".replaceWith()"/>
6869
<example>
6970
<desc>On click, replace the button with a div containing the same word.</desc>

notes.xsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<xsl:when test="@id = 'disconnected-manipulation'">
88
Prior to jQuery 1.9, <code><xsl:value-of select="@data-title"/></code> would attempt to add or change nodes in the current jQuery set if the first node in the set was not connected to a document, and in those cases return a new jQuery set rather than the original set. The method might or might not have returned a new result depending on the number or connectedness of its arguments! As of jQuery 1.9, <code>.after()</code>, <code>.before()</code>, and <code>.replaceWith()</code> always return the original unmodified set. Attempting to use these methods on a node without a parent has no effect—that is, neither the set nor the nodes it contains are changed.
99
</xsl:when>
10+
<xsl:when test="@id = 'removes-data'">
11+
The <code><xsl:value-of select="@data-title"/></code> method removes all data and event handlers associated with the removed nodes.
12+
</xsl:when>
1013
<xsl:when test="@id = 'document-order'">
1114
Selected elements are in the order of their appearance in the document.
1215
</xsl:when>

0 commit comments

Comments
 (0)