speced / speced/respec

WebIDL: How to define an extended/inherited interface?

Open
#5,457 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
806
Forks
434
Avg merge
1d 21h
Merged PRs (30d)
32

Description

I'm trying to define a new IDL interface that extends from an existing web interface.

interface MyInterface : WebInterface

The parent interface name does not resolve for HTML/DOM interfaces such as EventTarget or TextTrackCue, though this syntax does work if I substitute an interface defined within my own document.

I've not found an example of an inherited interface in the documentation and can't see how to resolve this issue. Please advise.

Example

In the following example, HTML TextTrackCue remains unresolved and causes an error.

    <section id='mycue-interface' data-dfn-for='MyCue'>
      <h2><dfn>MyCue</dfn> Interface</h2>
      <pre class='idl' title='MyCue Interface'>
        [Exposed=Window]
        interface MyCue : TextTrackCue {
          constructor(double startTime, unrestricted double endTime, any value);
          readonly attribute any value;
        };
      </pre>
      <dl>
        <dt>
          |cue| = new MyCue(startTime, endTime, value);
        </dt>
        <dd>
          Returns a new <a>MyCue</a> object.
        </dd>
        <dt>
          |cue|.<dfn>{{MyCue/value}}</dfn>
        </dt>
        <dd>
          Returns the value of a <a>MyCue</a> cue.
        </dd>
      </dl>
    </section>

Citing the parent interface as {{TextTrackCue}} doesn't fix the problem, and nor does adding pre class='idl no-link-warnings'. I'd welcome your guidance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example using an IDL interface inheriting from HTML's TextTrackCue or another DOM interface, then trace ReSpec's WebIDL resolution and linking behavior. Done means the inherited interface resolves correctly without requiring {{TextTrackCue}} or no-link-warnings, while locally defined parent interfaces continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.