-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How will the spec address versioning / feature detection? #33
Comments
The nature of the way specs like this are engineered into products means that features tend to be added incrementally. It is necessary that we consider each feature addition/change on its own to make sure it can be featured detected. We don't need to have an issue open to consider this; feature detection patterns are well-known to web developers. Recommend closing this issue. |
What is the feature detection pattern that the browser API uses? I'm fine with closing one as long as we know which one we think we're going to use. |
My understanding is that feature detection would be done by inspecting the type system. |
If this is true, can we get that text into the spec? Perhaps a section on feature detection? |
Is that necessary? My understanding is that JS developers may know how to do this; e.g., I found this in the wikipedia: Ian |
How does one understand how to see if billing address is supported on a payment request using the link above? Note that I'm just plucking that one feature out of thin air, you could ask the same question for each capability in the payment request API. |
I will leave to those who know these things more than I do to show code. Ian |
And until that is done, and there is some spec text outlining a general approach to addressing this problem, we should keep the issue open. |
@ianbjacobs is correct. Stand to be corrected by @adrianba , @rsolomakhin or @adamroach but my assumption is that code like the following would be used. How to do this is not something I'd expect in the spec, this is a generic feature detection technique. if(PaymentOptions.requestShipping) //Check if get Shipping address feature is present
if(PaymentOptions.requestPayerEmail) //Check if get email feature is present
if(PaymentOptions.requestPayerPhone) //Check if get phone feature is present |
@adrianba and @adamroach: does |
No, you can't feature detect against dictionaries but you can/should against interfaces. This is general best practice for web APIs. So you can test against for the |
Thanks @adrianba and @rsolomakhin @msporny, if there are any features you feel can't be easily detected via presence of an interface member please log an issue specific to that feature so we can discuss a way to address that. |
Can you give us a code example of checking for this on PaymentRequest @adrianba? I think you're saying we need to instantiate a payment request before we can feature detect? |
Another way to address this is to copy the pattern employed by |
Something like
You don't need to create an instance. The problem with having |
@adrianba --
I agree in the general case, where the binding between feature names and specific function calls is only defined via specification, that this is true. When you're trying to figure out whether you can include a value in a dictionary and have it honored, using a dictionary with exact key names is 100% unambiguous. By contrast, what you're proposing -- using the presence of a member on a structure to infer the validity of a differently-name dictionary key on another -- actually has the same kind of problem that you're highlighting with |
To be clear, what I'm proposing would end up looking like: if(PaymentOptions.getSupportedOptions()['requestShipping']){
// can use 'requestShipping' in the dictionary
} ...as contrasted with: if(PaymentRequest.prototype.hasOwnProperty("shippingAddress")){
// can use 'requestShipping' in the dictionary
} So you can see how one of these has a straight line (e.g., requestShipping -> requestShipping) while the other has an inference (e.g. shippingAddress -> requestShipping) |
We have had a number of conversations about extensibility. The spec supports payment method-specific data, for example. And we have discussed a companion spec about JSON-LD extensibility.
We expect to add features to future versions of the API. How will the API support feature detection? What are the individual features we will label in this version?
The text was updated successfully, but these errors were encountered: