Skip to content

Commit 2914e3c

Browse files
committed
Added a standards divergence warning to delegate.xml
Returning false in jQuery event handlers stops the propagation of the event, while returning false in native event listeners only prevents the default.
1 parent 1f302f5 commit 2914e3c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

entries/delegate.xml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ $( "table" ).on( "click", "td", function() {
6464
<p>Passing and handling event data works the same way as it does for <code>.on()</code>.</p>
6565
</longdesc>
6666
<note id="propagation-for-live-or-delegate" type="additional"/>
67+
<div class="warning"><strong>Note:</strong> the consequences of returning <code>false</code> from an event handler in jQuery differ from returning <code>false</code> in a native event handler (<code>element.addEventListener("click", function () { return false; })</code>) in that jQuery calls <code>event.preventDefault()</code> and <code>event.stopPropagation()</code> and a native event handler only calls <code>event.preventDefault()</code>.</div>
6768
<example>
6869
<desc>Click a paragraph to add another. Note that .delegate() attaches a click event handler to all paragraphs - even new ones.</desc>
6970
<code><![CDATA[

0 commit comments

Comments
 (0)