Skip to content

Track: drop the NodeRange patch in dom.kdl once browsers/BCD ship NodeRange #36

Open

Description

@uhyo

This tracks a temporary patch the fork carries in inputfiles/patches/dom.kdl. Remove it once browser-compat data catches up with the DOM spec. The patch fails silently: it won't break the build when it goes stale, so nothing else will remind us to remove it.

Problem

@webref/idl 3.87.0 picks up a DOM spec change. A new intermediate interface sits between AbstractRange and the concrete ranges, and the container attributes move into it:

[Exposed=Window]
interface AbstractRange {
  readonly attribute unsigned long startOffset;
  readonly attribute unsigned long endOffset;
  readonly attribute boolean collapsed;
};

[Exposed=Window]
interface NodeRange : AbstractRange {
  readonly attribute Node startContainer;
  readonly attribute Node endContainer;
};

interface StaticRange : NodeRange { ... };
interface Range : NodeRange { ... };

No browser ships NodeRange yet. @mdn/browser-compat-data 8.1.9 has no api.NodeRange entry and still records startContainer/endContainer under api.AbstractRange. The BCD filter therefore drops NodeRange, and the generated lib:

  • declares interface Range extends NodeRange and interface StaticRange extends NodeRange against a type that doesn't exist (TS2304: Cannot find name 'NodeRange'), and
  • loses startContainer/endContainer from Range/StaticRange, because they're no longer on AbstractRange.

This first broke the 2026-11-14 weekly update (#35).

Fork fix

inputfiles/patches/dom.kdl keeps the shape browsers actually ship:

  • re-adds startContainer/endContainer to AbstractRange, with MDN URLs (MDN still documents them there);
  • interface Range extends=AbstractRange and interface StaticRange extends=AbstractRange;
  • removals { interface NodeRange }. Baseline cuts need this: applyReferenceClosure runs before patches, still sees Range : NodeRange, and would otherwise keep NodeRange as an unused type-only interface in every cut.

The output for AbstractRange/Range/StaticRange is identical to the output before the IDL change.

Upstream status

Not checked. microsoft/TypeScript-DOM-lib-generator will hit the same failure when it updates to @webref/idl ≥ 3.87.0. If it patches this differently, prefer upstream's version so dom.kdl doesn't diverge at the next upstream merge.

How to check

  • Does BCD have api.NodeRange yet?
    node -e 'const b=require("@mdn/browser-compat-data"); console.log(b.__meta.version, !!b.api.NodeRange, Object.keys(b.api.AbstractRange))'
  • Has upstream inputfiles/patches/dom.kdl (or removedTypes.jsonc/overridingTypes.jsonc) got its own handling for NodeRange?
  • Did the spec revert or rename NodeRange? If @webref/idl no longer has it, the patch is a no-op and can simply go.

When it's time to remove

  • BCD adds api.NodeRange (browsers ship it): delete the AbstractRange/Range/StaticRange block and the interface NodeRange removal from dom.kdl. Otherwise the patch would wrongly strip a real, shipped interface and duplicate its members on AbstractRange. Then rebuild and review baselines/ plus every Baseline cut (npm run baseline-years). Older cuts where NodeRange isn't Baseline yet should get it back as a type-only interface through the reference closure. That's expected.
  • Upstream lands its own fix first: take upstream's version when merging and drop ours.

Close this issue once the patch is gone.

Activity

  1. uhyo commented on Nov 30, 2026

    @uhyo
    OwnerAuthor

    Upstream status (checked 2026-11-30, upstream main @ f7effdf)

    Upstream landed its own fix. Upstream updated to @webref/idl 3.87.0 in 8859ea0 (microsoft#2605) and added a near-identical patch, but in inputfiles/patches/html.kdl, not dom.kdl:

    // https://github.com/whatwg/dom/pull/1470 split these attributes to
    // AbstractRange into NodeRange, but only Blink supports it as of 2026-11
    interface AbstractRange {
      property endContainer exposed=Window readonly=#true mdnUrl="https://developer.mozilla.org/docs/Web/API/AbstractRange/endContainer" { type Node }
      property startContainer exposed=Window readonly=#true mdnUrl="https://developer.mozilla.org/docs/Web/API/AbstractRange/startContainer" { type Node }
    }
    interface Range extends=AbstractRange
    interface StaticRange extends=AbstractRange

    Upstream has no removals { interface NodeRange }; nothing under upstream inputfiles/ removes NodeRange explicitly. Upstream's full lib doesn't need it because the BCD filter drops NodeRange. Upstream's baselines/dom.generated.d.ts has Range/StaticRange extends AbstractRange and no NodeRange. Upstream's comment says Blink supports NodeRange, so BCD may add api.NodeRange soon. I did not run the BCD check from this issue.

    Next steps (from "When it's time to remove")

    • Upstream landed its own fix first: on the next upstream merge, take upstream's html.kdl version and drop our duplicate AbstractRange/Range/StaticRange block from dom.kdl. Otherwise both patches will add the same properties.
    • Keep removals { interface NodeRange } as fork-only (upstream doesn't have it). The Baseline cuts still need it because applyReferenceClosure runs before patches. Then rebuild and review baselines/ plus every Baseline cut.
    • This issue stays relevant after that: once BCD adds api.NodeRange, upstream's patch and our remaining removal both need to go.

    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions