fix(web-sys): authoritative expansion model for stable/unstable WebIDL overrides#4964
Merged
guybedford merged 9 commits intomainfrom Feb 19, 2026
Merged
fix(web-sys): authoritative expansion model for stable/unstable WebIDL overrides#4964guybedford merged 9 commits intomainfrom
guybedford merged 9 commits intomainfrom
Conversation
logan-gatlin
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#[cfg(web_sys_unstable_apis)]gating on stable method signatures that share a WebIDL operation with unstable overloadsPromise<T>,Array<T>,Function<fn(...)>, etc.) to all unstable API methodsPhotoCapabilities,PhotoSettings,MediaSettingsRange,Point2D,RedEyeReduction,FillLightMode,MeteringModeProblem
When a WebIDL operation like
read(optional ClipboardUnsanitizedFormats formats = {})expands, the 0-argread()doesn't use any unstable types, so it's a valid stable API. But the old code saw that unstable signatures existed for the same JS name (read) and incorrectly gated all signatures — including the stable 0-arg version — with#[cfg(web_sys_unstable_apis)].This affected
Clipboard.read(), WebGLtexImage2D/texSubImage2D/texImage3D/texSubImage3D(VideoFrame overloads),Performance.measure(),Window/WorkerGlobalScopetimer methods, and others.Solution
The new authoritative expansion model treats stable and unstable WebIDL expansions as independent, authoritative sets:
read()is a sibling ofread(options))#[cfg(not(web_sys_unstable_apis))]#[cfg(web_sys_unstable_apis)]Additional Fixes
Promise<T>,Array<T>,Function<fn(...)>) regardless of the generics compatibility mode for stable APIsPhotoCapabilities,PhotoSettings,MediaSettingsRange,Point2D,RedEyeReduction,FillLightMode,MeteringModefrom the W3C Image Capture spec — these were referenced but never defined, causing methods to be silently skippedforEachcallback type names are now per-interface ({Interface}MapLikeForEachCallback) instead of global singletons that overwrote each otherArrayTupletype conversion now propagates errors instead of silently falling back toJsValueSignaturederivesEq/Hash: Replaced*const Signaturepointer identity with proper structural equality viaHashSet<&Signature>Key Files Changed
crates/webidl/src/util.rs— authoritative expansion model increate_imports()crates/webidl/src/generator.rs—same_signature(),generics_compatlogic for unstable APIscrates/webidl/src/lib.rs—OptionswithCell<bool>, generics_compat in dictionary/const/namespace/iterable codecrates/webidl/src/first_pass.rs— Phase 0 registration, per-interface callback names,Eq/HashonSignaturecrates/webidl/src/wbg_type.rs— error propagation inArrayTuplecrates/web-sys/webidls/unstable/ImageCapture.webidl— added missing types from W3C speccrates/web-sys/src/features/— regenerated bindingsTesting
just test-web-idl-tests— stable mode tests passjust test-web-idl-tests-unstable— unstable mode tests passjust test-web-idl-tests-next— next mode tests passjust generate-web-sys— regenerated bindings verified