From 71031ea5b19edfa975aef9152dba4ccacae2757c Mon Sep 17 00:00:00 2001 From: Miau Lightouch <5199594+miaulightouch@users.noreply.github.com> Date: Sun, 12 Aug 2018 01:21:29 +0800 Subject: [PATCH] Adding TVMLKit support (visionmedia/debug#579) --- src/browser.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/browser.js b/src/browser.js index 1f206dc..552b44f 100644 --- a/src/browser.js +++ b/src/browser.js @@ -100,7 +100,7 @@ export function inject (createDebug) { load () { let namespaces try { - namespaces = createDebug.storage.debug + namespaces = createDebug.storage.getItem('debug') } catch (error) {} // If debug isn't set in LS, and we're in Electron/nwjs, try to load $DEBUG @@ -138,7 +138,7 @@ export function inject (createDebug) { if (namespaces == null) { createDebug.storage.removeItem('debug') } else { - createDebug.storage.debug = namespaces + createDebug.storage.setItem('debug', namespaces) } } catch (error) {} }, @@ -155,7 +155,9 @@ export function inject (createDebug) { */ storage: (() => { try { - return window.localStorage + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage } catch (error) {} })(),