Skip to content

Commit

Permalink
putting back some more closures which should not have been removed in…
Browse files Browse the repository at this point in the history
… r23032. !strict fixes #12098
  • Loading branch information
neonstalwart committed Dec 16, 2010
1 parent 5466ebd commit 0da1395
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
51 changes: 27 additions & 24 deletions NodeList-data.js
@@ -1,8 +1,9 @@
define("dojo/NodeList-data", ["dojo"], function(d) { define("dojo/NodeList-data", ["dojo"], function(dojo) {

(function(d){

/*===== /*=====
dojo.NodeList.prototype.data = function(key, value){ dojo.NodeList.prototype.data = function(key, value){
// summary: stash or get some arbitrary data on/from these nodes. // summary: stash or get some arbitrary data on/from these nodes.
// //
// description: // description:
// Stash or get some arbirtrary data on/from these nodes. This private _data function is // Stash or get some arbirtrary data on/from these nodes. This private _data function is
Expand All @@ -11,10 +12,10 @@ define("dojo/NodeList-data", ["dojo"], function(d) {
// returned. EVEN WHEN THE LIST IS length == 1. // returned. EVEN WHEN THE LIST IS length == 1.
// //
// A single-node version of this function is provided as `dojo._nodeData`, which follows // A single-node version of this function is provided as `dojo._nodeData`, which follows
// the same signature, though expects a String ID or DomNode reference in the first // the same signature, though expects a String ID or DomNode reference in the first
// position, before key/value arguments. // position, before key/value arguments.
// //
// node: String|DomNode // node: String|DomNode
// The node to associate data with // The node to associate data with
// //
// key: Object?|String? // key: Object?|String?
Expand All @@ -32,7 +33,7 @@ define("dojo/NodeList-data", ["dojo"], function(d) {
// | if(touched[0] == "touched"){ alert('win'); } // | if(touched[0] == "touched"){ alert('win'); }
// //
// example: // example:
// Get all the data items for a given node. // Get all the data items for a given node.
// | var list = dojo.query(".foo").data(); // | var list = dojo.query(".foo").data();
// | var first = list[0]; // | var first = list[0];
// //
Expand All @@ -43,26 +44,26 @@ define("dojo/NodeList-data", ["dojo"], function(d) {
// | dojo.query(".foo").data("foo"); // returns [`bar`] // | dojo.query(".foo").data("foo"); // returns [`bar`]
// //
// returns: Object|Anything|Nothing // returns: Object|Anything|Nothing
// When used as a setter via `dojo.NodeList`, a NodeList instance is returned // When used as a setter via `dojo.NodeList`, a NodeList instance is returned
// for further chaning. When used as a getter via `dojo.NodeList` an ARRAY // for further chaning. When used as a getter via `dojo.NodeList` an ARRAY
// of items is returned. The items in the array correspond to the elements // of items is returned. The items in the array correspond to the elements
// in the original list. This is true even when the list length is 1, eg: // in the original list. This is true even when the list length is 1, eg:
// when looking up a node by ID (#foo) // when looking up a node by ID (#foo)
}; };
dojo.NodeList.prototype.removeData = function(key){ dojo.NodeList.prototype.removeData = function(key){
// summary: Remove the data associated with these nodes. // summary: Remove the data associated with these nodes.
// key: String? // key: String?
// If ommitted, clean all data for this node. // If ommitted, clean all data for this node.
// If passed, remove the data item found at `key` // If passed, remove the data item found at `key`
}; };
dojo._nodeDataCache = { dojo._nodeDataCache = {
// summary: An alias to the private dataCache for NodeList-data. NEVER USE THIS! // summary: An alias to the private dataCache for NodeList-data. NEVER USE THIS!
// This private is only exposed for the benefit of unit testing, and is // This private is only exposed for the benefit of unit testing, and is
// removed during the build process. // removed during the build process.
}; };
=====*/ =====*/


var dataCache = {}, x = 0, dataattr = "data-dojo-dataid", nl = d.NodeList, var dataCache = {}, x = 0, dataattr = "data-dojo-dataid", nl = d.NodeList,
Expand All @@ -76,17 +77,17 @@ define("dojo/NodeList-data", ["dojo"], function(d) {
return pid; return pid;
} }
; ;

//>>excludeStart("debugging", true); //>>excludeStart("debugging", true);
// exposed for unit tests: // exposed for unit tests:
d._nodeDataCache = dataCache; d._nodeDataCache = dataCache;
//>>excludeEnd("debugging"); //>>excludeEnd("debugging");

var dodata = d._nodeData = function(node, key, value){ var dodata = d._nodeData = function(node, key, value){


var pid = dopid(node), r; var pid = dopid(node), r;
if(!dataCache[pid]){ dataCache[pid] = {}; } if(!dataCache[pid]){ dataCache[pid] = {}; }

// API discrepency: calling with only a node returns the whole object. $.data throws // API discrepency: calling with only a node returns the whole object. $.data throws
if(arguments.length == 1){ r = dataCache[pid]; } if(arguments.length == 1){ r = dataCache[pid]; }
if(typeof key == "string"){ if(typeof key == "string"){
Expand All @@ -99,12 +100,12 @@ define("dojo/NodeList-data", ["dojo"], function(d) {
}else{ }else{
// must be a setter, mix `value` into data hash // must be a setter, mix `value` into data hash
// API discrepency: using object as setter works here // API discrepency: using object as setter works here
r = d._mixin(dataCache[pid], key); r = d._mixin(dataCache[pid], key);
} }

return r; // Object|Anything|Nothing return r; // Object|Anything|Nothing
}; };

var removeData = d._removeNodeData = function(node, key){ var removeData = d._removeNodeData = function(node, key){
// summary: Remove some data from this node // summary: Remove some data from this node
// node: String|DomNode // node: String|DomNode
Expand All @@ -114,22 +115,22 @@ define("dojo/NodeList-data", ["dojo"], function(d) {
// If passed, remove only the passed `key` in the associated dataset // If passed, remove only the passed `key` in the associated dataset
var pid = dopid(node); var pid = dopid(node);
if(dataCache[pid]){ if(dataCache[pid]){
if(key){ if(key){
delete dataCache[pid][key]; delete dataCache[pid][key];
}else{ }else{
delete dataCache[pid]; delete dataCache[pid];
} }
} }
}; };

d._gcNodeData = function(){ d._gcNodeData = function(){
// summary: super expensive: GC all data in the data for nodes that no longer exist in the dom. // summary: super expensive: GC all data in the data for nodes that no longer exist in the dom.
// description: // description:
// super expensive: GC all data in the data for nodes that no longer exist in the dom. // super expensive: GC all data in the data for nodes that no longer exist in the dom.
// MUCH safer to do this yourself, manually, on a per-node basis (via `NodeList.removeData()`) // MUCH safer to do this yourself, manually, on a per-node basis (via `NodeList.removeData()`)
// provided as a stop-gap for exceptionally large/complex applications with constantly changing // provided as a stop-gap for exceptionally large/complex applications with constantly changing
// content regions (eg: a dijit.layout.ContentPane with replacing data) // content regions (eg: a dijit.layout.ContentPane with replacing data)
// There is NO automatic GC going on. If you dojo.destroy() a node, you should _removeNodeData // There is NO automatic GC going on. If you dojo.destroy() a node, you should _removeNodeData
// prior to destruction. // prior to destruction.
var livePids = dojo.query("[" + dataattr + "]").map(dopid); var livePids = dojo.query("[" + dataattr + "]").map(dopid);
for(var i in dataCache){ for(var i in dataCache){
Expand Down Expand Up @@ -162,6 +163,8 @@ define("dojo/NodeList-data", ["dojo"], function(d) {
// } // }
// return r; // dojo.NodeList|Array|SingleItem // return r; // dojo.NodeList|Array|SingleItem
// }; // };


})(dojo);

return dojo.NodeList; return dojo.NodeList;
}); });
2 changes: 2 additions & 0 deletions hash.js
Expand Up @@ -11,6 +11,7 @@ define("dojo/hash", ["dojo"], function(dojo) {
// // do something based on the hash value. // // do something based on the hash value.
// } // }


(function(){
dojo.hash = function(/* String? */ hash, /* Boolean? */ replace){ dojo.hash = function(/* String? */ hash, /* Boolean? */ replace){
// summary: // summary:
// Gets or sets the hash string. // Gets or sets the hash string.
Expand Down Expand Up @@ -232,6 +233,7 @@ define("dojo/hash", ["dojo"], function(dojo) {
// else non-supported browser, do nothing. // else non-supported browser, do nothing.
} }
}); });
})();


return dojo.hash; return dojo.hash;
}); });
2 changes: 2 additions & 0 deletions html.js
Expand Up @@ -2,6 +2,7 @@ define("dojo/html", ["dojo", "dojo/parser"], function(dojo) {
dojo.getObject("html", true, dojo); dojo.getObject("html", true, dojo);


// the parser might be needed.. // the parser might be needed..
(function(){ // private scope, sort of a namespace


// idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes // idCounter is incremented with each instantiation to allow asignment of a unique id for tracking, logging purposes
var idCounter = 0, var idCounter = 0,
Expand Down Expand Up @@ -330,6 +331,7 @@ dojo.getObject("html", true, dojo);
return op.set(); return op.set();
} }
}; };
})();


return dojo.html; return dojo.html;
}); });

0 comments on commit 0da1395

Please sign in to comment.