You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Web APIs are relying more and more on dictionaries. And doing feature detection of such members requires ugly and unnecessary complicated code. Following WICG/EventListenerOptions#31, #491, and many more over the years, I'm proposing WebIDL allows us to expose interfaces under a specific "namespace/scope" to avoid polluting the global scope.
Current state for an API called MyAPI
A dictionary makes it unnecessarily hard to detect its members.
dictionary MyDictionaryOptions {
boolean foo;
};
An interface pollutes global scope as window.MyDictionaryOptions now unnecessarily exists.
if("foo"inwindow.MyAPI.MyDictionaryOptions){// 1. It's easy to detect foo exists in MyDictionaryOptions // 2. Detecting it does not pollute global scope// 3. It does not require executing some methods to test it.}
What do you folks think about this?
The text was updated successfully, but these errors were encountered:
Do you mean to say that you'd like to conclude the discussion on whatwg/webidl#107 first? Or move the issues to that repo? Or that you would like François and I to both copy/paste our proposals into that specific thread as-is and continue there?
Web APIs are relying more and more on dictionaries. And doing feature detection of such members requires ugly and unnecessary complicated code. Following WICG/EventListenerOptions#31, #491, and many more over the years, I'm proposing WebIDL allows us to expose interfaces under a specific "namespace/scope" to avoid polluting the global scope.
Current state for an API called
MyAPI
window.MyDictionaryOptions
now unnecessarily exists.Proposal
Use interfaces instead of dictionaries when possible and expose them under a specific member of the API.
What do you folks think about this?
The text was updated successfully, but these errors were encountered: