From 8c14d2116b352fcbabfd8ca9d16f575484a8322b Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Wed, 13 Jun 2018 11:22:29 -0700 Subject: [PATCH 1/2] Adding TVMLKit support --- src/browser.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/browser.js b/src/browser.js index f18d63e7..33ff11fe 100644 --- a/src/browser.js +++ b/src/browser.js @@ -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) {} } From 7a5a90b7ecd1ca024c7230d23ceaf2a24e6fc8f1 Mon Sep 17 00:00:00 2001 From: Frank Febbraro Date: Thu, 21 Jun 2018 09:20:32 -0700 Subject: [PATCH 2/2] removed the check for window/navigationDocument, instead relying on localStorage in the global context on all 'browser' based platforms --- src/browser.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/browser.js b/src/browser.js index 33ff11fe..5b7063e3 100644 --- a/src/browser.js +++ b/src/browser.js @@ -169,11 +169,8 @@ 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; + // The Browser also has localStorage in the global context. + return localStorage; } catch (e) {} }