◐ Shell
clean mode source ↗

Change inputSources getter from method to attrib. by toji · Pull Request #624 · immersive-web/webxr

Consulted with @bfgeek about this and he clarified the "custom indexable/iterable interface" option that @Manishearth mentioned earlier and which I had misunderstood. (Sorry!) For those of you who, like me, were not familiar with the pattern it's something that apparently shows up semi-commonly in web specs and has well understood IDL semantics. Changing to a custom iterable type in our IDL would look something like this:

interface XRInputSourceArray {
  iterable<XRInputSource>;
  readonly attribute unsigned long length;
  getter XRInputSource(unsigned long index);
};

partial interface XRSession {
  [SameObject] readonly attribute XRInputSourceArray inputSources;
}

Which isn't quite as bad as what I had imagined. It's still not ideal to have to define the array type ourselves, but I can see that being a reasonable path here and would like feedback from other members on their preference.