New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding TVMLKit support #579
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,7 @@ function save(namespaces) { | |
if (null == namespaces) { | ||
exports.storage.removeItem('debug'); | ||
} else { | ||
exports.storage.debug = namespaces; | ||
exports.storage.setItem('debug', namespaces); | ||
} | ||
} catch(e) {} | ||
} | ||
|
@@ -144,7 +144,7 @@ function save(namespaces) { | |
function load() { | ||
var r; | ||
try { | ||
r = exports.storage.debug; | ||
r = exports.storage.getItem('debug'); | ||
} catch(e) {} | ||
|
||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG | ||
|
@@ -168,6 +168,11 @@ function load() { | |
|
||
function localstorage() { | ||
try { | ||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context | ||
if (typeof window === 'undefined' && typeof navigationDocument !== 'undefined') { | ||
return localStorage; | ||
} | ||
|
||
return window.localStorage; | ||
} catch (e) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This try/catch is now unnecessary, isn't it? cc @TooTallNate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Old versions of IE don't support local storage, so this would throw when attempting to access it. |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could just change this line to
localStorage
and have noif
check?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would definitely work for the TVMLKit scenario, does that work for the general browser scenario as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window
is the global object in the web browser, so I can't really think of a scenario where it would be a problem. Only one way to find out though, haha.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I concur. That would work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll make that change