[whatwg/webidl] Fix "inclusive inherited interfaces" to walk the inheritance chain (PR #1658)

<!--
Thank you for contributing to the Web IDL Standard! Please describe the change you are making and complete the checklist below if your change is not editorial.

When you submit this PR, and each time you edit this comment (including checking a checkbox through the UI!), PR Preview will run and update it. As such make any edits in one go and only after PR Preview has run.

If you think your PR is ready to land, please double-check that the build is passing and the checklist is complete before pinging.
-->

The [inherited interfaces](https://webidl.spec.whatwg.org/#dfn-inherited-interfaces) of an interface are defined recursively: the interface it directly inherits from, plus all of *that* interface's inherited interfaces. So [inclusive inherited interfaces](https://webidl.spec.whatwg.org/#interface-inclusive-inherited-interfaces) should walk the whole inheritance chain.

But step 3.2 advances from the fixed input |I| instead of the loop variable |interface|:

> Set |interface| to the interface that |I| inherits from, if any, and null otherwise.

So after the first iteration, |interface| is always |I|'s direct parent and never becomes null. The loop never ends for any interface that inherits from another. This PR changes |I| to |interface| so each iteration moves one level up the chain.

The algorithm is used by:
- [implements](https://webidl.spec.whatwg.org/#implements), which regular operations and attributes use to check their `this` value
- [internally create a new object implementing the interface](https://webidl.spec.whatwg.org/#internally-create-a-new-object-implementing-the-interface), which copies each ancestor's `[LegacyUnforgeable]` members onto the new instance.

For example, `CustomEvent` inherits from `Event`, which has a `[LegacyUnforgeable]` attribute:

```webidl
interface CustomEvent : Event { ... };

interface Event {
  ...
  [LegacyUnforgeable] readonly attribute boolean isTrusted;
  ...
};
```

Under the current text, `new CustomEvent("foo")` would never finish. With the fix, it returns an object with `isTrusted` as an own property whose value is `false`.

Implementations seems to behave this way. Chromium, Gecko, and WebKit pass dom/idlharness.any.js, which includes test for `new CustomEvent("foo")`, on wpt.fyi.

This PR only aligns the spec with existing behavior, so it needs no new tests and no implementation bugs.

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * … <!-- If these tests are tentative, link a PR to make them non-tentative. -->
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chromium: …
   * Gecko: …
   * WebKit: …
   * Deno: …
   * Node.js: …
   * webidl2.js: …
   * widlparser: …
- [ ] [MDN issue](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) is filed: …
- [ ] The top of this comment includes a [clear commit message](https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use. <!-- If you created this PR from a single commit, Github copied its message. Otherwise, you need to add a commit message yourself. -->

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)


<!--
    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://whatpr.org/webidl/1658.html" title="Last updated on Nov 2, 2026, 7:29 AM UTC (a5b9ddd)">Preview</a> | <a href="https://whatpr.org/webidl/1658/7b9f91b...a5b9ddd.html" title="Last updated on Nov 2, 2026, 7:29 AM UTC (a5b9ddd)">Diff</a>
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/webidl/pull/1658

-- Commit Summary --

  * Fix "inclusive inherited interfaces" to walk the inheritance chain

-- File Changes --

    M index.bs (4)

-- Patch Links --

https://github.com/whatwg/webidl/pull/1658.patch
https://github.com/whatwg/webidl/pull/1658.diff

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

Message ID: <whatwg/webidl/pull/1658@github.com>

Received on Monday, 2 November 2026 07:30:15 UTC