WebAPI/Navigator.hasFeature: Difference between revisions

no edit summary
No edit summary
Line 19: Line 19:


== Semantics ==
== Semantics ==
Both hasFeature and getFeature accept string arguments to denote the feature names.  getFeature reject the promise that they return if the feature name passed to them is unknown.  hasFeature will fullfill the promise with a true value if the feature exists on the "platform" (which means the current state and version of the hardware and the UA software) albeit hidden behind some runtime permissions, and it will fulfill the promise with a false value if the feature doesn't exist on the "platform" or if the feature name passed to it is unknown.  getFeature will resolve the promise with a value describing the feature name passed to the API.  The type of that value depends on the feature being queried.  The idea is that hasFeature should be used for mere existence tests, and getFeature should be used for queries involving asking more information about a feature, such as the size of something.
Both hasFeature and getFeature accept string arguments to denote the feature names.  getFeature resolves the promise with an undefined value if the feature name passed to them is unknown.  hasFeature will fullfill the promise with a true value if the feature exists on the "platform" (which means the current state and version of the hardware and the UA software) albeit hidden behind some runtime permissions, and it will fulfill the promise with a false value if the feature doesn't exist on the "platform" or if the feature name passed to it is unknown.  getFeature will resolve the promise with a value describing the feature name passed to the API.  The type of that value depends on the feature being queried.  The idea is that hasFeature should be used for mere existence tests, and getFeature should be used for queries involving asking more information about a feature, such as the size of something.


The feature name specifies a namespaced value in the following form:
The feature name specifies a namespaced value in the following form:
Confirmed users
657

edits