Skip to content

Make SpeechGrammarList.item() nullable. - #212

Merged
padenot merged 1 commit into
mainfrom
nullable-grammar-item
Sep 9, 2026
Merged

Make SpeechGrammarList.item() nullable.#212
padenot merged 1 commit into
mainfrom
nullable-grammar-item

Conversation

@padenot

@padenot padenot commented Sep 8, 2026

Copy link
Copy Markdown
Member

The return type was non-nullable, so an index greater than or equal to length had no valid return value. Chromium declares it non-nullable too, but its implementation returns null for such an index, and other platform collections with an item() getter (NodeList, HTMLCollection, CSSRuleList, FileList) all declare it nullable, so specify null and match what ships.

I'm sending a Gecko patch that includes a WPT for this.


Preview | Diff

@padenot
padenot requested review from evanbliu and hoch September 8, 2026 12:44
Comment thread index.bs

@hoch hoch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The return type was non-nullable, so an index greater than or equal to
length had no valid return value. Chromium declares it non-nullable too,
but its implementation returns null for such an index, and other platform
collections with an item() getter (NodeList, HTMLCollection, CSSRuleList,
FileList) all declare it nullable, so specify null and match what ships.
@padenot
padenot force-pushed the nullable-grammar-item branch from 17decaa to 3f9e1f4 Compare September 8, 2026 16:48
@padenot
padenot merged commit 291cb48 into main Sep 9, 2026
1 check passed
github-actions Bot added a commit that referenced this pull request Sep 9, 2026
SHA: 291cb48
Reason: push, by padenot

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Sep 9, 2026
…dex is out of range. r=media-playback-reviewers,webidl,smaug,alwu

item() indexed straight into the array, so an out-of-range index crashed.
Blink's item() returns nullptr there and its bindings hand that to JS as
null, so make the WebIDL return type nullable and do the same.

WebAudio/web-speech-api#212 aligns the spec.

Differential Revision: https://phabricator.services.mozilla.com/D324284
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 10, 2026
…range.

item() indexed straight into the array, so an out-of-range index crashed.
Blink's item() returns nullptr there and its bindings hand that to JS as
null, so make the WebIDL return type nullable and do the same.

WebAudio/web-speech-api#212 aligns the spec.

Differential Revision: https://phabricator.services.mozilla.com/D324284

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=2068066
gecko-commit: 7345f092b989ee703ac09898eb0ae04ee434a111
gecko-commit-git: 15e65f9002f4193a1eff321726ff8983d413f829
gecko-reviewers: media-playback-reviewers, webidl, smaug, alwu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants