define([
"require", "./_base/kernel", "./_base/lang", "./_base/array", "./_base/config", "./dom", "./_base/window",
"./_base/url", "./aspect", "./promise/all", "./date/stamp", "./Deferred", "./has", "./query", "./on", "./ready"
], function(require, dojo, dlang, darray, config, dom, dwindow, _Url, aspect, all, dates, Deferred, has, query, don, ready){
// module:
// dojo/parser
new Date("X"); // workaround for #11279, new Date("") == NaN
// data-dojo-props etc. is not restricted to JSON, it can be any javascript
function myEval(text){
return eval("(" + text + ")");
}
// Widgets like BorderContainer add properties to _Widget via dojo.extend().
// If BorderContainer is loaded after _Widget's parameter list has been cached,
// we need to refresh that parameter list (for _Widget and all widgets that extend _Widget).
var extendCnt = 0;
aspect.after(dlang, "extend", function(){
extendCnt++;
}, true);
function getNameMap(ctor){
// summary:
// Returns map from lowercase name to attribute name in class, ex: {onclick: "onClick"}
var map = ctor._nameCaseMap, proto = ctor.prototype;
// Create the map if it's undefined.
// Refresh the map if a superclass was possibly extended with new methods since the map was created.
if(!map || map._extendCnt < extendCnt){
map = ctor._nameCaseMap = {};
for(var name in proto){
if(name.charAt(0) === "_"){
continue;
} // skip internal properties
map[name.toLowerCase()] = name;
}
map._extendCnt = extendCnt;
}
return map;
}
// Map from widget name or list of widget names(ex: "dijit/form/Button,acme/MyMixin") to a constructor.
var _ctorMap = {};
function getCtor(/*String[]*/ types, /*Function?*/ contextRequire){
// summary:
// Retrieves a constructor. If the types array contains more than one class/MID then the
// subsequent classes will be mixed into the first class and a unique constructor will be
// returned for that array.
var ts = types.join();
if(!_ctorMap[ts]){
var mixins = [];
for(var i = 0, l = types.length; i < l; i++){
var t = types[i];
// TODO: Consider swapping getObject and require in the future
mixins[mixins.length] = (_ctorMap[t] = _ctorMap[t] || (dlang.getObject(t) || (~t.indexOf('/') &&
(contextRequire ? contextRequire(t) : require(t)))));
}
var ctor = mixins.shift();
_ctorMap[ts] = mixins.length ? (ctor.createSubclass ? ctor.createSubclass(mixins) : ctor.extend.apply(ctor, mixins)) : ctor;
}
return _ctorMap[ts];
}
var parser = {
// summary:
// The Dom/Widget parsing package
_clearCache: function(){
// summary:
// Clear cached data. Used mainly for benchmarking.
extendCnt++;
_ctorMap = {};
},
_functionFromScript: function(script, attrData){
// summary:
// Convert a ``
// into a function
// script: DOMNode
// The `` node,
// calls require() to load the specified modules and (asynchronously) assign them to the specified global
// variables, and returns a Promise for when that operation completes.
//
// In the example above, it is effectively doing a require(["acme/bar", ...], function(a){ bar = a; }).
var hash = myEval("{" + script.innerHTML + "}"), // can't use dojo/json::parse() because maybe no quotes
vars = [],
mids = [],
d = new Deferred();
var contextRequire = (options && options.contextRequire) || require;
for(var name in hash){
vars.push(name);
mids.push(hash[name]);
}
contextRequire(mids, function(){
for(var i = 0; i < vars.length; i++){
dlang.setObject(vars[i], arguments[i]);
}
d.resolve(arguments);
});
return d.promise;
},
_scanAmd: function(root, options){
// summary:
// Scans the DOM for any declarative requires and returns their values.
// description:
// Looks for `` node, calls require() to load the
// specified modules and (asynchronously) assign them to the specified global variables,
// and returns a Promise for when those operations complete.
// root: DomNode
// The node to base the scan from.
// options: Object?
// a kwArgs options object, see parse() for details
// Promise that resolves when all the