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

I didn't suggest the full "pass the exact same argument list" design because I do think the semantics are different.  We don't want to imply that the method is doing some arbitrary argument validation.  It's simply testing whether the dictionary (and enum) members are recognized or not.  I'm also fine with @domenic's simple 2-string-arg version if that's easier to get consensus on.

In terms of where this would be used, here's a specific list that I can keep updated of the specific APIs we know would benefit (and I'll update this comment if more are mentioned).

Interface | method | dictionary | notes
--------|--------|-------|----
EventTarget | addEventListener | AddEventListenerOptions | started this debate
Navigator | share | ShareData
ImageBitmapFactories | createImageBitmap | ImageBitmapOptions | needs enum values too
MediaStreamTrack | applyConstraints | MediaTrackConstraints | supercedes [getSupportedConstraints](https://w3c.github.io/mediacapture-main/#dom-mediadevices-getsupportedconstraints)


But I don't know how to find the exhaustive set of cases.  I guess it ultimately comes down to how often we extend a dictionary or add new dictionary-taking overloads in non-optional ways.  I can't think of any automated way to find those cases.

<details>
<summary>But in case it helps, here's a list of other `dictionary` types currently in blink (not necessarily all used by shipping APIs), excluding ones that I think probably wouldn't benefit (eg. initializer dictionaries - where you can just feature detect the type of object being initialized).  For many of these, if we ever have or want to in the future extend the dictionary, `supports` could be valuable.
</summary>

```
AnalyserOptions
AndroidPayMethodData
AndroidPayTokenization
AnimationEffectTimingProperties
AssignedNodesOptions
AudioBufferOptions
AudioBufferSourceOptions
AudioConfiguration
AudioContextOptions
AudioNodeOptions
AudioTimestamp
AuthenticationAssertionOptions
AuthenticationClientData
AuthenticationExtensions
BackgroundFetchOptions
BasicCardRequest
BlobPropertyBag
CacheQueryOptions
CanvasContextCreationAttributes
CanvasRenderingContext2DSettings
ClientQueryOptions
ComputedTimingProperties
ConstantSourceOptions
ConstrainBooleanParameters
ConstrainDOMStringParameters
ConstrainDoubleRange
ConstrainLongRange
ConstrainPoint2DParameters
CredentialCreationOptions
CredentialData
CredentialRequestOptions
CSSCalcDictionary
ElementCreationOptions
ElementDefinitionOptions
ElementRegistrationOptions
FaceDetectorOptions
FederatedCredentialRequestOptions
FilePropertyBag
FileSystemFlags
FontFaceDescriptors
ForeignFetchOptions
ForeignFetchResponse
FormDataOptions
GetNotificationOptions
GetRootNodeOptions
HitRegionOptions
IconDefinition
IDBIndexParameters
IDBObjectStoreParameters
IdleRequestOptions
ImageDataColorSettings
ImageEncodeOptions
InternalDictionaryDerived
InternalDictionaryDerivedDerived
KeyframeAnimationOptions
KeyframeEffectOptions
Landmark
LongRange
MediaConfiguration
MediaDecodingConfiguration
MediaElementAudioSourceOptions
MediaEncodingConfiguration
MediaImage
MediaKeySystemConfiguration
MediaKeySystemMediaCapability
MediaRecorderOptions
MediaStreamAudioSourceOptions
MediaStreamConstraints
MediaTrackCapabilities
MediaTrackConstraints
MediaTrackConstraintSet
MediaTrackSettings
MediaTrackSupportedConstraints
MIDIOptions
MidiPermissionDescriptor
NavigationPreloadState
NFCMessage
NFCPushOptions
NFCRecord
NFCWatchOptions
NotificationAction
NotificationOptions
PannerOptions
PasswordCredentialData
PaymentAppRequest
PaymentAppResponse
PaymentCurrencyAmount
PaymentDetailsBase
PaymentDetailsModifier
PaymentDetailsUpdate
PaymentInstrument
PaymentItem
PaymentMethodData
PaymentOptions
PaymentShippingOption
PerformanceObserverInit
PeriodicWaveConstraints
PeriodicWaveOptions
PermissionDescriptor
PhotoSettings
Point2D
PositionOptions
PropertyDescriptor
PushPermissionDescriptor
RegistrationOptions
RelyingPartyAccount
RequestDeviceOptions
RTCAnswerOptions
RTCConfiguration
RTCIceServer
RTCOfferAnswerOptions
RTCOfferOptions
ScopedCredentialDescriptor
ScopedCredentialOptions
ScopedCredentialParameters
ScrollOptions
ScrollToOptions
SensorOptions
StorageEstimate
TextDecodeOptions
TextDecoderOptions
USBControlTransferParameters
USBDeviceFilter
USBDeviceRequestOptions
VideoConfiguration
VRLayer
WebGLContextAttributes
WorkletOptions
```
</details>

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

Received on Thursday, 25 May 2017 21:05:58 UTC