Copy Modernizr's more robust sessionStorage feature detection.

This commit is contained in:
Max Goodman
2012-07-27 23:53:05 -07:00
parent e5853f189d
commit a186e5e7e9

View File

@@ -113,10 +113,10 @@ r.analytics = {
}
r.analytics.breadcrumbs = {
hasSessionStorage: 'sessionStorage' in window,
selector: '.thing, .side, .sr-list, .srdrop, .tagline, .md, .organic-listing, .gadget, a, button, input',
init: function() {
this.hasSessionStorage = this._checkSessionStorage()
this.data = this._load()
var refreshed = this.data[0] && this.data[0]['url'] == window.location
@@ -129,6 +129,17 @@ r.analytics.breadcrumbs = {
}, this))
},
_checkSessionStorage: function() {
// Via modernizr.com's sessionStorage check.
try {
sessionStorage.setItem('__test__', 'test')
sessionStorage.removeItem('__test__')
return true
} catch(e) {
return false
}
},
_load: function() {
if (!this.hasSessionStorage) {
return [{stored: false}]