From 3f9e1f4df1dbe194da95f32a0688a5c0f9bac126 Mon Sep 17 00:00:00 2001
From: Paul Adenot
Date: Tue, 8 Sep 2026 14:39:08 +0200
Subject: [PATCH] Make SpeechGrammarList.item() nullable.
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.
---
index.bs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/index.bs b/index.bs
index fb37066..e06cdf0 100644
--- a/index.bs
+++ b/index.bs
@@ -256,7 +256,7 @@ interface SpeechRecognitionAlternative {
[SecureContext, Exposed=Window]
interface SpeechRecognitionResult {
readonly attribute unsigned long length;
- getter SpeechRecognitionAlternative item(unsigned long index);
+ getter SpeechRecognitionAlternative? item(unsigned long index);
readonly attribute boolean isFinal;
};
@@ -264,7 +264,7 @@ interface SpeechRecognitionResult {
[SecureContext, Exposed=Window]
interface SpeechRecognitionResultList {
readonly attribute unsigned long length;
- getter SpeechRecognitionResult item(unsigned long index);
+ getter SpeechRecognitionResult? item(unsigned long index);
};
// A full response, which could be interim or final, part of a continuous response or not
@@ -292,7 +292,7 @@ interface SpeechGrammar {
interface SpeechGrammarList {
constructor();
readonly attribute unsigned long length;
- getter SpeechGrammar item(unsigned long index);
+ getter SpeechGrammar? item(unsigned long index);
undefined addFromURI(DOMString src,
optional float weight = 1.0);
undefined addFromString(DOMString string,
@@ -769,7 +769,7 @@ This structure has the following attributes:
The length attribute represents how many grammars are currently in the array.
item(index) getter
- The item getter returns a SpeechGrammar from the index into an array of grammars.
+ The item getter returns the SpeechGrammar at index in the array of grammars, or null if index is greater than or equal to the length attribute.
The user agent must ensure that the length attribute is set to the number of elements in the array.
The user agent must ensure that the index order from smallest to largest matches the order in which grammars were added to the array.