New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do indexed getters ever return null? #532
Comments
Is this a question about practical usage in APIs right now? |
Yeah, I basically want to know if we want/can make this an invariant or whether I should change the IDL in https://dom.spec.whatwg.org/#interface-nodelist to say Node? rather than Node even though it can never be null. |
OK. So looking at Firefox, the indexed getters we have that return nullable things are:
(not all of these are defined in specs; I did check the two obvious non-spec ones in ChromeNodeList and TreeColumns and they don't return null). Also, I have no idea why HTMLAllCollection's anonymous indexed getter is defined to maybe return null. It can't, obviously. |
I tried going through that list, and it does seem like for all of them we never return null from the getter. So I guess the real question is whether we ever expect to support a list of "something-or-null"... |
That'd be interesting to know for whatwg/dom#284. At least whenever I use indexed getters for some legacy object I'm pretty sure that the properties always correspond to an object and not null. It's only the
item()
method that can return null.(If it turns out that they cannot return null, we should allow the types of iterables and indexed getters to slightly differ. Or perhaps say that the type of the indexed getter is the same as the method declaration it might share, minus nullability.)
The text was updated successfully, but these errors were encountered: