Confirmed users
746
edits
(added last paragraph to Background) |
m (damn you, wikitext vs markdown) |
||
| Line 2: | Line 2: | ||
When we say "getFeature" we are generally talking about feature detection writ large. This involves two APIs: <code>hasFeature</code> and <code>getFeature</code>. In order to use either of these APIs, an app must be using the 'feature-detection' permission (which is specified in the app's manifest). | When we say "getFeature" we are generally talking about feature detection writ large. This involves two APIs: <code>hasFeature</code> and <code>getFeature</code>. In order to use either of these APIs, an app must be using the 'feature-detection' permission (which is specified in the app's manifest). | ||
Both <code>hasFeature</code> and <code>getFeature</code> are similar in that they return information about the device. But they differ in that <code>hasFeature</code> simply returns a boolean if the feature exists, whereas <code>getFeature</code> returns a value about that feature; as such, they're intended for slightly different use -- when you need to know | Both <code>hasFeature</code> and <code>getFeature</code> are similar in that they return information about the device. But they differ in that <code>hasFeature</code> simply returns a boolean if the feature exists, whereas <code>getFeature</code> returns a value about that feature; as such, they're intended for slightly different use -- when you need to know '''IF''' something exists vs '''THE EXTENT''' of something. ''Example: hasFeature("camera") vs getFeature("hardware.memory").'' | ||
While it has been said that "getFeature" landed in 2.0, many people have not understood this discrepancy, and assumed that meant both <code>getFeature</code> and <code>hasFeature</code> landed. They [https://bugzilla.mozilla.org/show_bug.cgi?id=1009645#c41 did not]; only <code>getFeature</code> did land. Therefore, complete feature detection is not possible in 2.0. | While it has been said that "getFeature" landed in 2.0, many people have not understood this discrepancy, and assumed that meant both <code>getFeature</code> and <code>hasFeature</code> landed. They [https://bugzilla.mozilla.org/show_bug.cgi?id=1009645#c41 did not]; only <code>getFeature</code> did land. Therefore, complete feature detection is not possible in 2.0. | ||
| Line 8: | Line 8: | ||
Another point of confusion is the wiki page on <code>hasFeature</code> speaks of [https://wiki.mozilla.org/WebAPI/Navigator.hasFeature#.22manifest.22_namespace values for the manifest namespace that can be used with <code>hasFeature</code>]; but these were actually implemented on <code>getFeature</code> -- which makes sense if you know that <code>hasFeature</code> is not implemented, but is incorrect according to the spec. | Another point of confusion is the wiki page on <code>hasFeature</code> speaks of [https://wiki.mozilla.org/WebAPI/Navigator.hasFeature#.22manifest.22_namespace values for the manifest namespace that can be used with <code>hasFeature</code>]; but these were actually implemented on <code>getFeature</code> -- which makes sense if you know that <code>hasFeature</code> is not implemented, but is incorrect according to the spec. | ||
<code>hasFeature</code> | <code>hasFeature</code> '''does''' exist in 2.1, though it has the [https://bugzilla.mozilla.org/show_bug.cgi?id=1098470 bug where it returns ''undefined'' for manifest.* tests]. There is no plan to backport support of <code>hasFeature</code> to 2.0. | ||
= Overview = | = Overview = | ||