Workers - Event and EventTarget spec compliance improvements
- Announced
- Tags
- Workers
- Severity
- info, set by
reef/rss-rule-v1 - Source
- https://developers.cloudflare.com/changelog/post/2026-08-19-event-spec-compliance/
<p>Several improvements bring the Workers runtime's <code>Event</code>, <code>EventTarget</code>, and related APIs closer to their web platform specifications.</p> <div tabindex="-1" class="heading-wrapper level-h4"><h4 id="istrusted-is-now-correct-for-user-constructed-events"><code>isTrusted</code> is now correct for user-constructed events</h4><a class="anchor-link" href="#istrusted-is-now-correct-for-user-constructed-events"><span aria-hidden="true" class="anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24"><path fill="currentcolor" d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 0 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 1 0-1.42-1.42Zm8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 0 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 1 0 1.42 1.42l3.88-3.89a4.49 4.49 0 0 0 0-6.33ZM8.83 15.17a1 1 0 0 0 1.1.22 1 1 0 0 0 .32-.22l4.92-4.92a1 1 0 0 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42Z"></path></svg></span></a></div> <p>User-constructed event subclasses (<code>new MessageEvent(...)</code>, <code>new CustomEvent(...)</code>, <code>new ErrorEvent(...)</code>, <code>new CloseEvent(...)</code>) now correctly report <code>isTrusted</code> as <code>false</code>. Previously, these incorrectly reported <code>isTrusted</code> as <code>true</code>.</p> <div tabindex="-1" class="heading-wrapper level-h4"><h4 id="ontype-handlers-fire-in-registration-order"><code>on<type></code> handlers fire in registration order</h4><a class="anchor-link" href="#ontype-handlers-fire-in-registration-order"><span aria-hidden="true" class="anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24"><path fill="currentcolor" d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 0 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 1 0-1.42-1.42Zm8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 0 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 1 0 1.42 1.42l3.88-3.89a4.49 4.49 0 0 0 0-6.33ZM8.83 15.17a1 1 0 0 0 1.1.22 1 1 0 0 0 .32-.22l4.92-4.92a1 1 0 0 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42Z"></path></svg></span></a></div> <p>Event handler attributes such as <code>onmessage</code> and <code>onabort</code> now fire in their registration order relative to <code>addEventListener()</code> calls, matching browser behavior. Previously, <code>on<type></code> handlers always fired before any <code>addEventListener()</code> listeners regardless of when they were assigned.</p> <div tabindex="-1" class="heading-wrapper level-h4"><h4 id="messageevent-constructor-improvements"><code>MessageEvent</code> constructor improvements</h4><a class="anchor-link" href="#messageevent-constructor-improvements"><span aria-hidden="true" class="anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24"><path fill="currentcolor" d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 0 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 1 0-1.42-1.42Zm8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 0 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 1 0 1.42 1.42l3.88-3.89a4.49 4.49 0 0 0 0-6.33ZM8.83 15.17a1 1 0 0 0 1.1.22 1 1 0 0 0 .32-.22l4.92-4.92a1 1 0 0 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42Z"></path></svg></span></a></div> <p><code>new MessageEvent(type)</code> now works without providing an init object — <code>data</code> defaults to <code>null</code> per spec. The <code>MessageEventInit</code> dictionary also now supports the full spec surface: <code>origin</code>, <code>lastEventId</code>, <code>source</code>, and <code>ports</code>, in addition to <code>data</code>.</p> <div tabindex="-1" class="heading-wrapper level-h4"><h4 id="closeevent-and-errorevent-constructor-improvements"><code>CloseEvent</code> and <code>ErrorEvent</code> constructor improvements</h4><a class="anchor-link" href="#closeevent-and-errorevent-constructor-improvements"><span aria-hidden="true" class="anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24"><path fill="currentcolor" d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 0 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 1 0-1.42-1.42Zm8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 0 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 1 0 1.42 1.42l3.88-3.89a4.49 4.49 0 0 0 0-6.33ZM8.83 15.17a1 1 0 0 0 1.1.22 1 1 0 0 0 .32-.22l4.92-4.92a1 1 0 0 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42Z"></path></svg></span></a></div> <p>The <code>CloseEventInit</code> and <code>ErrorEventInit</code> dictionaries now accept the standard <code>EventInit</code> members <code>bubbles</code>, <code>cancelable</code>, and <code>composed</code>.</p> <div tabindex="-1" class="heading-wrapper level-h4"><h4 id="messageport-starts-on-any-message-listener"><code>MessagePort</code> starts on any <code>message</code> listener</h4><a class="anchor-link" href="#messageport-starts-on-any-message-listener"><span aria-hidden="true" class="anchor-icon"><svg width="16" height="16" viewBox="0 0 24 24"><path fill="currentcolor" d="m12.11 15.39-3.88 3.88a2.52 2.52 0 0 1-3.5 0 2.47 2.47 0 0 1 0-3.5l3.88-3.88a1 1 0 0 0-1.42-1.42l-3.88 3.89a4.48 4.48 0 0 0 6.33 6.33l3.89-3.88a1 1 0 1 0-1.42-1.42Zm8.58-12.08a4.49 4.49 0 0 0-6.33 0l-3.89 3.88a1 1 0 0 0 1.42 1.42l3.88-3.88a2.52 2.52 0 0 1 3.5 0 2.47 2.47 0 0 1 0 3.5l-3.88 3.88a1 1 0 1 0 1.42 1.42l3.88-3.89a4.49 4.49 0 0 0 0-6.33ZM8.83 15.17a1 1 0 0 0 1.1.22 1 1 0 0 0 .32-.22l4.92-4.92a1 1 0 0 0-1.42-1.42l-4.92 4.92a1 1 0 0 0 0 1.42Z"></path></svg></span></a></div> <p>Adding a <code>message</code> event listener to a <code>MessagePort</code> via <code>addEventListener("message", ...)</code> now starts the port, matching browser behavior. Previously, only assigning <code>onmessage</code> would start the port.</p>
The text above is the source's. reef added the severity, the dates it could read from the text, and the endpoints and scopes named in code.