Change global namespace logic to placehold with null

This commit is contained in:
Jonathan Frederic 2015-08-18 17:50:54 -07:00
parent b8f25eea2f
commit 81e0fb3194

View File

@ -6,8 +6,9 @@
var Jupyter = window.Jupyter || {}; var Jupyter = window.Jupyter || {};
var jprop = function(name, module_path) { var jprop = function(name, module_path) {
requirejs([module_path], function(loaded) { if (Jupyter[name] === undefined) {
if (!Jupyter.hasOwnProperty(name)) { Jupyter[name] = null;
requirejs([module_path], function(loaded) {
Object.defineProperty(Jupyter, name, { Object.defineProperty(Jupyter, name, {
get: function() { get: function() {
console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'")`'); console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'")`');
@ -16,15 +17,16 @@
enumerable: true, enumerable: true,
configurable: false configurable: false
}); });
} }, function(err) {
}, function(err) { console.warn('Jupyter.' + name + ' unavailable because "' + module_path + '" was not loaded.', err);
console.warn('Jupyter.' + name + ' unavailable because "' + module_path + '" was not loaded.', err); });
}); }
}; };
var jglobal = function(name, module_path){ var jglobal = function(name, module_path){
requirejs([module_path], function(loaded) { if (Jupyter[name] === undefined) {
if (!Jupyter.hasOwnProperty(name)) { Jupyter[name] = null;
requirejs([module_path], function(loaded) {
Object.defineProperty(Jupyter, name, { Object.defineProperty(Jupyter, name, {
get: function() { get: function() {
console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'").'+name+'`'); console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'").'+name+'`');
@ -33,10 +35,10 @@
enumerable: true, enumerable: true,
configurable: false configurable: false
}); });
} }, function(err) {
}, function(err) { console.warn('Jupyter.' + name + ' unavailable because "' + module_path + '" was not loaded.', err);
console.warn('Jupyter.' + name + ' unavailable because "' + module_path + '" was not loaded.', err); });
}); }
} }