-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexportNS.js
49 lines (42 loc) · 1.15 KB
/
exportNS.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
define(["dojo"], function(dojo){
var d = dojo;
d.exportNS = function(origin, target, prefix){
// summary: Export all the public members of one namespace safely into
// some other object.
//
// origin: Object
// Some object to export to another.
//
// target: Object
// The object to extend with our new members.
//
// prefix: String?
// A string to prefix to the global name
//
// example:
// | dojo.exportNS(dojo, dojo.global);
// | query("> li").addClass("bar");
//
// example:
// | dojo.exportNS(dojo, window, "$");
// | $query("> li").addClass("bar");
//
prefix = prefix || "";
for(var i in origin){
// should we check hasOwnProperty?
if(!target[(prefix + i)] && /^_/.test(i) && !(origin[i] === target)){
target[(prefix + i)] = origin[i];
}
}
};
//>>excludeStart("autoConflict", kwArgs.autoConflict == "on");
if(d.config.conflict){
//>>excludeEnd("autoConflict");
// Turn on an automatic global export of dojo.* API's into window.* either by
//
d.exportNS(d, d.global);
//>>excludeStart("autoConflict", kwArgs.autoConflict == "on");
}
//>>excludeEnd("autoConflict");
return d;
});