geolocation.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*!
  2. {
  3. "name": "Geolocation API",
  4. "property": "geolocation",
  5. "caniuse": "geolocation",
  6. "tags": ["media"],
  7. "notes": [{
  8. "name": "MDN Docs",
  9. "href": "https://developer.mozilla.org/en-US/docs/WebAPI/Using_geolocation"
  10. }],
  11. "polyfills": [
  12. "joshuabell-polyfill",
  13. "webshims",
  14. "geo-location-javascript",
  15. "geolocation-api-polyfill"
  16. ]
  17. }
  18. !*/
  19. /* DOC
  20. Detects support for the Geolocation API for users to provide their location to web applications.
  21. */
  22. define(['Modernizr'], function(Modernizr) {
  23. // geolocation is often considered a trivial feature detect...
  24. // Turns out, it's quite tricky to get right:
  25. //
  26. // Using !!navigator.geolocation does two things we don't want. It:
  27. // 1. Leaks memory in IE9: github.com/Modernizr/Modernizr/issues/513
  28. // 2. Disables page caching in WebKit: webk.it/43956
  29. //
  30. // Meanwhile, in Firefox < 8, an about:config setting could expose
  31. // a false positive that would throw an exception: bugzil.la/688158
  32. Modernizr.addTest('geolocation', 'geolocation' in navigator);
  33. });