From 1354d17270961fff662d40f90521223f8fd0d73b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 14 Aug 2012 18:59:10 +0400 Subject: update dojo to 1.7.3 --- lib/dojo/parser.js | 558 +---------------------------------------------------- 1 file changed, 2 insertions(+), 556 deletions(-) (limited to 'lib/dojo/parser.js') diff --git a/lib/dojo/parser.js b/lib/dojo/parser.js index bd52030e0..a8c5428ba 100644 --- a/lib/dojo/parser.js +++ b/lib/dojo/parser.js @@ -4,559 +4,5 @@ see: http://dojotoolkit.org/license for details */ - -if(!dojo._hasResource["dojo.parser"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojo.parser"] = true; -dojo.provide("dojo.parser"); -dojo.require("dojo.date.stamp"); - - -new Date("X"); // workaround for #11279, new Date("") == NaN - -dojo.parser = new function(){ - // summary: - // The Dom/Widget parsing package - - var d = dojo; - - function val2type(/*Object*/ value){ - // summary: - // Returns name of type of given value. - - if(d.isString(value)){ return "string"; } - if(typeof value == "number"){ return "number"; } - if(typeof value == "boolean"){ return "boolean"; } - if(d.isFunction(value)){ return "function"; } - if(d.isArray(value)){ return "array"; } // typeof [] == "object" - if(value instanceof Date) { return "date"; } // assume timestamp - if(value instanceof d._Url){ return "url"; } - return "object"; - } - - function str2obj(/*String*/ value, /*String*/ type){ - // summary: - // Convert given string value to given type - switch(type){ - case "string": - return value; - case "number": - return value.length ? Number(value) : NaN; - case "boolean": - // for checked/disabled value might be "" or "checked". interpret as true. - return typeof value == "boolean" ? value : !(value.toLowerCase()=="false"); - case "function": - if(d.isFunction(value)){ - // IE gives us a function, even when we say something like onClick="foo" - // (in which case it gives us an invalid function "function(){ foo }"). - // Therefore, convert to string - value=value.toString(); - value=d.trim(value.substring(value.indexOf('{')+1, value.length-1)); - } - try{ - if(value === "" || value.search(/[^\w\.]+/i) != -1){ - // The user has specified some text for a function like "return x+5" - return new Function(value); - }else{ - // The user has specified the name of a function like "myOnClick" - // or a single word function "return" - return d.getObject(value, false) || new Function(value); - } - }catch(e){ return new Function(); } - case "array": - return value ? value.split(/\s*,\s*/) : []; - case "date": - switch(value){ - case "": return new Date(""); // the NaN of dates - case "now": return new Date(); // current date - default: return d.date.stamp.fromISOString(value); - } - case "url": - return d.baseUrl + value; - default: - return d.fromJson(value); - } - } - - var dummyClass = {}, instanceClasses = { - // map from fully qualified name (like "dijit.Button") to structure like - // { cls: dijit.Button, params: {label: "string", disabled: "boolean"} } - }; - - // 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). - // TODO: remove this in 2.0, when we stop caching parameters. - d.connect(d, "extend", function(){ - instanceClasses = {}; - }); - - function getProtoInfo(cls, params){ - // cls: A prototype - // The prototype of the class to check props on - // params: Object - // The parameters object to mix found parameters onto. - for(var name in cls){ - if(name.charAt(0)=="_"){ continue; } // skip internal properties - if(name in dummyClass){ continue; } // skip "constructor" and "toString" - params[name] = val2type(cls[name]); - } - return params; - } - - function getClassInfo(/*String*/ className, /*Boolean*/ skipParamsLookup){ - // summary: - // Maps a widget name string like "dijit.form.Button" to the widget constructor itself, - // and a list of that widget's parameters and their types - // className: - // fully qualified name (like "dijit.form.Button") - // returns: - // structure like - // { - // cls: dijit.Button, - // params: { label: "string", disabled: "boolean"} - // } - - var c = instanceClasses[className]; - if(!c){ - // get pointer to widget class - var cls = d.getObject(className), params = null; - if(!cls){ return null; } // class not defined [yet] - if(!skipParamsLookup){ // from fastpath, we don't need to lookup the attrs on the proto because they are explicit - params = getProtoInfo(cls.prototype, {}) - } - c = { cls: cls, params: params }; - - }else if(!skipParamsLookup && !c.params){ - // if we're calling getClassInfo and have a cls proto, but no params info, scan that cls for params now - // and update the pointer in instanceClasses[className]. This happens when a widget appears in another - // widget's template which still uses dojoType, but an instance of the widget appears prior with a data-dojo-type, - // skipping this lookup the first time. - c.params = getProtoInfo(c.cls.prototype, {}); - } - - return c; - } - - this._functionFromScript = function(script, attrData){ - // summary: - // Convert a - // into a function - // script: DOMNode - // The