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

> In your "imageOrientation","none" example that's explicitly testing both that the dictionary member exists, and that the value is a valid member of the enum?

Yeah. Off the cuff, the one-argument version is useful for scenarios where the value space is either very specific (e.g. always a Blob) or very general (`any`, `DOMString`, etc.). While the two-argument form is useful for a limited value space. The clearest example of a limited value space is enum; in the enum case a supports() method could be code-generated with no additional information (either in spec prose or implementations).

>  Does supports also handle just checking enum members without any dictionary at all?

I suppose it could, although it makes the "only operates on one argument" issue worse. (I.e. now it doesn't work for methods which take one enumeration argument and one dictionary argument.) I think I'd stick with dictionaries for now? Unless we have a list of platform APIs that need this, in which case we could make a more informed decision.

> Would passing a dictionary possibly work better than strings?

Hmm, yeah, this might be better. It is more complicated; e.g. now we have to define what happens with partial support (presumably returns false), or the empty dictionary (presumably returns true). And I'm not sure about how you'd use it for web share; would it be `navigator.share.supports({ image: new Blob() })`? We should discuss further...

-- 
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-303918824

Received on Thursday, 25 May 2017 04:24:36 UTC