[w3c/ServiceWorker] Editorial: clarify FetchEvent clientId, resultingClientId, and replacesClientId initialization (PR #1832)

## Summary

Aligns the [Create Fetch Event and Dispatch](https://w3c.github.io/ServiceWorker/#create-fetch-event-and-dispatch-algorithm) algorithm and the `FetchEvent.clientId` / `resultingClientId` attribute definitions with **actual browser behavior** (Chrome, Firefox, Safari) and MDN.

Fixes #1267.

## Changes

### 1. `FetchEvent.clientId` algorithm step

Previously the spec unconditionally initialized `clientId` from `request`'s client, including for navigations. However, all major browsers return an empty string for `clientId` on navigation requests. Per [@wanderview's suggestion](https://github.com/w3c/ServiceWorker/issues/1267#issuecomment-362298501):

> My inclination is to probably implement resultingClientId and keep navigation clientId empty at first.

**Before:**
> If |client| is not null, initialize |e|'s clientId attribute to |client|'s environment id.

**After:**
> If |request| is a subresource request and |client| is not null, initialize |e|'s clientId attribute to |client|'s environment id.

### 2. `FetchEvent.resultingClientId` algorithm step

Adds an explicit `reservedClient` null check and removes the redundant "and to the empty string otherwise" clause (the IDL default already provides `""`).

### 3. `FetchEvent.replacesClientId` algorithm step

Removes the redundant "and to the empty string otherwise" clause for consistency with the sibling attributes.

### 4. Explanatory notes

Added descriptive notes for both `FetchEvent.clientId` and `FetchEvent.resultingClientId` attribute sections, documenting all cases where the value is the empty string. These match MDN's documented behavior.


<!--
    This comment and the below content is programmatically generated.
    You may add a comma-separated list of anchors you'd like a
    direct link to below (e.g. #idl-serializers, #idl-sequence):

    Don't remove this comment or modify anything below this line.
    If you don't want a preview generated for this pull request,
    just replace the whole of this comment's content by "no preview"
    and remove what's below.
-->
***
<a href="https://pr-preview.s3.amazonaws.com/monica-ch/ServiceWorker/pull/1832.html" title="Last updated on Jul 13, 2026, 7:32 PM UTC (9eee8d2)">Preview</a> | <a href="https://pr-preview.s3.amazonaws.com/w3c/ServiceWorker/1832/e91ddff...monica-ch:9eee8d2.html" title="Last updated on Jul 13, 2026, 7:32 PM UTC (9eee8d2)">Diff</a>
You can view, comment on, or merge this pull request online at:

  https://github.com/w3c/ServiceWorker/pull/1832

-- Commit Summary --

  * Editorial: clarify FetchEvent clientId, resultingClientId, and replacesClientId initialization

-- File Changes --

    M index.bs (10)

-- Patch Links --

https://github.com/w3c/ServiceWorker/pull/1832.patch
https://github.com/w3c/ServiceWorker/pull/1832.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1832
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/pull/1832@github.com>

Received on Monday, 13 July 2026 19:32:39 UTC