Skip to content

All: Mark event aliases as deprecated #1223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1b00d2b
All: Mark event aliases as deprecated
mgol Apr 16, 2023
bff1493
All: Remove the detach-shorthand note
mgol Apr 17, 2023
bf1f218
ajaxStart: Mark the shorthand method as deprecated
mgol Apr 17, 2023
54f5c8e
All: Fix Additional Notes for all AJAX events
mgol Apr 17, 2023
df4a1c6
focus: Deprecate .focus(), tweak the blur page
mgol Apr 18, 2023
9c7639f
All: Separate blur & focus shorthand pages
mgol Apr 18, 2023
c696ca7
All: Tweak focus/blur, migrate focusin/focusout
mgol Apr 18, 2023
3b02e6b
All: Fix indentation of examples
mgol Apr 18, 2023
35b481f
hover: Deprecate the API
mgol Apr 20, 2023
a23ab44
All: Add individual descriptions back
mgol Apr 20, 2023
4f08883
resize: Deprecate the API
mgol Apr 20, 2023
8905219
All: Deprecate scroll, click & dblclick; fix resize
mgol Apr 21, 2023
a270b7a
All: De-indent entries on event pages for better Git history
mgol Apr 21, 2023
f4b077b
ajaxStart: separate the deprecated page
mgol Apr 21, 2023
611f3c7
All: Move descriptions in Ajax event pages up
mgol Apr 21, 2023
47c6e85
All: JavaScript event -> event
mgol Apr 21, 2023
e70bfa5
All: Deprecate mouse* shorthands
mgol Apr 21, 2023
e6d774d
All: Deprecate change & select
mgol Apr 21, 2023
2537bc7
All: Remove a few .click() uses
mgol Apr 21, 2023
db29f90
All: Deprecate other event shorthands
mgol Apr 23, 2023
027012f
All: Add separate shorthand pages for load/unload
mgol Apr 23, 2023
4f41f67
All: Link to shorthands from event pages
mgol Apr 23, 2023
ada6134
All: Add other AJAX shorthand pages
mgol Apr 23, 2023
6f41267
All: Migrare AJAX event pages
mgol Apr 23, 2023
6f9101b
All: Remove obsolete shortcut notes
mgol Apr 23, 2023
f6ac37a
error: Separate the event page, like for load & unload
mgol Apr 23, 2023
d0ef87b
All: Remove internal usage of deprecated event shorthands
mgol Apr 23, 2023
16ea4ad
All: Tweak wording on event pages on on/bind
mgol Apr 23, 2023
4205fd6
All: Remove internal ajax event shorthand usage
mgol Apr 23, 2023
fecc648
All: Add descriptions to ajax event shorthand pages
mgol Apr 23, 2023
65d3204
All: Tweak the warning on load/unload, add one for error
mgol Apr 24, 2023
a7fa37f
All: Add shorthand notes on AJAX event pages as well
mgol Apr 24, 2023
b4bc05e
All: Fix links to AJAX events on shorthand pages
mgol Apr 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
error: Separate the event page, like for load & unload
  • Loading branch information
mgol committed Apr 23, 2023
commit f6ac37a9504a7f1f52eab454297d00a32f71ed15
37 changes: 37 additions & 0 deletions entries/error-shorthand.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<entry type="method" name="error" return="jQuery" deprecated="1.8" removed="3.0">
<title>.error()</title>
<desc>Bind an event handler to the "error" event, or trigger that event on an element.</desc>
<signature>
<added>1.0</added>
<argument name="handler" type="Function">
<desc>A function to execute each time the event is triggered.</desc>
<argument name="eventObject" type="Event" />
</argument>
</signature>
<signature>
<added>1.4.3</added>
<argument name="eventData" type="Anything" optional="true">
<desc>An object containing data that will be passed to the event handler.</desc>
</argument>
<argument name="handler" type="Function">
<desc>A function to execute each time the event is triggered.</desc>
<argument name="eventObject" type="Event" />
</argument>
</signature>
<signature>
<added>1.0</added>
</signature>
<longdesc>
<div class="warning">
<p>This API has been removed in jQuery 3.0.</p>
<p>Instead of <code>.error( handler )</code> or <code>.error( eventData, handler )</code>, use <a href="/error/#on1"><code>.on( "error", handler )</code></a> or <a href="/error/#on1"><code>.on( "error", eventData, handler )</code></a>, respectively.</p>
<p>Instead of <code>.error()</code>, use <a href="/error/#trigger2"><code>.trigger( "error" )</code></a>.</p>
</div>
</longdesc>
<category slug="events/browser-events"/>
<category slug="version/1.0"/>
<category slug="version/1.4.3"/>
<category slug="deprecated/deprecated-1.8"/>
<category slug="removed"/>
</entry>
56 changes: 34 additions & 22 deletions entries/error.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0"?>
<entry type="method" name="error" return="jQuery" deprecated="1.8" removed="3.0">
<title>.error()</title>
<entries>
<desc>Bind an event handler to the "error" event, or trigger that event on an element.</desc>

<entry type="method" name="on" return="jQuery">
<title>error event</title>
<desc>Bind an event handler to the "error" event.</desc>
<signature>
<added>1.0</added>
<argument name="handler" type="Function">
<desc>A function to execute when the event is triggered.</desc>
<argument name="eventObject" type="Event" />
<added>1.7</added>
<argument name="&quot;error&quot;" type="string">
<desc>The string <code>"error"</code>.</desc>
</argument>
</signature>
<signature>
<added>1.4.3</added>
<argument name="eventData" type="Anything" optional="true">
<desc>An object containing data that will be passed to the event handler.</desc>
</argument>
Expand All @@ -20,9 +19,6 @@
</argument>
</signature>
<longdesc>
<div class="warning">
<p>Note: This API has been removed in jQuery 3.0; please use <code>.on( "error", handler )</code> instead of <code>.error( handler )</code> and <code>.trigger( "error" )</code> instead of <code>.error()</code>.</p>
</div>
<p>The <code>error</code> event is sent to elements, such as images, that are referenced by a document and loaded by the browser. It is called if the element was not loaded correctly.</p>
<p>For example, consider a page with a simple image element:</p>
<pre><code>
Expand All @@ -31,34 +27,50 @@
<p>The event handler can be bound to the image:</p>
<pre><code>
$( "#book" )
.error(function() {
alert( "Handler for .error() called." )
})
.on( "error", function() {
alert( "Handler for `error` called." )
} )
.attr( "src", "missing.png" );
</code></pre>
<p>If the image cannot be loaded (for example, because it is not present at the supplied URL), the alert is displayed:</p>
<p>
<samp>Handler for .error() called.</samp>
<samp>Handler for `error` called.</samp>
</p>
<div class="warning">
<p>The event handler <em>must</em> be attached before the browser fires the <code>error</code> event, which is why the example sets the <code>src</code> attribute after attaching the handler. Also, the <code>error</code> event may not be correctly fired when the page is served locally; <code>error</code> relies on HTTP status codes and will generally not be triggered if the URL uses the <code>file:</code> protocol.</p>
</div>
<p>Note: A jQuery <code>error</code> event handler should not be attached to the <code>window</code> object. The browser fires the <code>window</code>'s <code>error</code> event when a script error occurs. However, the window <code>error</code> event receives different arguments and has different return value requirements than conventional event handlers. Use <code>window.onerror</code> instead.</p>
</longdesc>
<example>
<desc>To replace all the missing images with another, you can update the <code>src</code> attribute inside the callback passed to <code>.error()</code>. Be sure that the replacement image exists; otherwise the <code>error</code> event will be triggered indefinitely.</desc>
<desc>To replace all the missing images with another, you can update the <code>src</code> attribute inside the <code>error</code> handler. Be sure that the replacement image exists; otherwise the <code>error</code> event will be triggered indefinitely.</desc>
<code><![CDATA[
// If missing.png is missing, it is replaced by replacement.png
$( "img" )
.error(function() {
.on( "error", function() {
$( this ).attr( "src", "replacement.png" );
})
} )
.attr( "src", "missing.png" );
]]></code>
</example>
<category slug="events/browser-events"/>
<category slug="version/1.0"/>
<category slug="version/1.4.3"/>
<category slug="deprecated/deprecated-1.8"/>
<category slug="removed"/>
<category slug="version/1.7"/>
</entry>

<entry type="method" name="trigger" return="jQuery">
<title>error event</title>
<desc>Trigger the "error" event on an element.</desc>
<signature>
<added>1.0</added>
<argument name="&quot;error&quot;" type="string">
<desc>The string <code>"error"</code>.</desc>
</argument>
</signature>
<longdesc>
<p>See the description for <a href="#on1"><code>.on( "error", ... )</code></a>.</p>
</longdesc>
<category slug="events/browser-events"/>
<category slug="version/1.0"/>
</entry>

</entries>