Re: [heycam/webidl] Need pattern for feature detecting dictionary members (#107)

I had an idea today that I think might actually work. The main sticking point for me is how to avoid exposing the dictionary names to the web; they are currently unobservable, and IMO that is a nice property.

What if we made it easy for dictionary-accepting APIs to get a feature-detection method added to them? I am thinking the following JS code:

```js
createImageBitmap.supports("imageOrientation", "none")
navigator.share.supports("image");
```

These could be generated by Web IDL such as

```webidl
interface WindowOrWorkerGlobalScope {
  [WithDictionarySupports] Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options);
}

partial interface Navigator {
    [SecureContext, WithDictionarySupports] Promise<void> share(ShareData data);
};
```

The limitation of this is that it assumes a single dictionary argument. Hopefully that is all we'll ever need... You could imagine generalizations that allow more, but they get uglier to use.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/107#issuecomment-303915944

Received on Thursday, 25 May 2017 03:57:52 UTC