mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-24 22:38:09 -05:00
Copy Modernizr's more robust sessionStorage feature detection.
This commit is contained in:
@@ -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}]
|
||||
|
||||
Reference in New Issue
Block a user