From 3bbbda0819aaa82e230dde9367f9aa28ad3aecea Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sun, 11 Jan 2015 14:21:31 +0000 Subject: [PATCH] Allow callers of the bootprefix to determine browser status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This gives us finer control under node-webkit of whether the core thinks we’re running under the browser or node. --- boot/bootprefix.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/boot/bootprefix.js b/boot/bootprefix.js index bff9a2aa2..ae0712d4e 100644 --- a/boot/bootprefix.js +++ b/boot/bootprefix.js @@ -20,9 +20,15 @@ $tw = $tw || Object.create(null); $tw.boot = $tw.boot || Object.create(null); // Detect platforms -$tw.browser = typeof(window) !== "undefined" ? {} : null; -$tw.node = typeof(process) === "object" ? {} : null; -$tw.nodeWebKit = $tw.node && global.window && global.window.nwDispatcher ? {} : null; +if(!("browser" in $tw)) { + $tw.browser = typeof(window) !== "undefined" ? {} : null; +} +if(!("node" in $tw)) { + $tw.node = typeof(process) === "object" ? {} : null; +} +if(!("nodeWebKit" in $tw)) { + $tw.nodeWebKit = $tw.node && global.window && global.window.nwDispatcher ? {} : null; +} // Set default boot tasks $tw.boot.tasks = {