mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 21:55:31 +00:00
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
var JSAN = {
|
|
global: this,
|
|
use: function (module, symbols) {
|
|
var components = module.split(/\./);
|
|
var fn = components.join('/') + '.js';
|
|
var o = JSAN.global;
|
|
var i, c;
|
|
for (i = 0; i < components.length; i++) {
|
|
o = o[components[i]];
|
|
if (typeof(o) == 'undefined') {
|
|
break;
|
|
}
|
|
}
|
|
if (typeof(o) != 'undefined') {
|
|
return o;
|
|
}
|
|
|
|
load(fn);
|
|
o = JSAN.global;
|
|
for (i = 0; i < components.length; i++) {
|
|
o = o[components[i]];
|
|
if (typeof(o) == 'undefined') {
|
|
return undefined;
|
|
}
|
|
}
|
|
if (!symbols) {
|
|
var tags = o.EXPORT_TAGS;
|
|
if (tags) {
|
|
symbols = tags[':common'] || tags[':all'];
|
|
}
|
|
}
|
|
if (symbols) {
|
|
for (i = 0; i < symbols.length; i++) {
|
|
c = symbols[i];
|
|
JSAN.global[c] = o[c];
|
|
}
|
|
}
|
|
return o;
|
|
}
|
|
};
|