From cc9146fddf1d68d41f89addb12709a0e0db8ac39 Mon Sep 17 00:00:00 2001 From: Bill Keese Date: Fri, 25 Jan 2013 23:44:40 +0900 Subject: [PATCH] _WidgetBase: remove deprecated code, refs #4 Removing attributeMap, connect()/disconnect(), subscribe()/publish(). Also this._connects & this._supportingWidgets --- _WidgetBase.js | 164 +++---------------------------------------------- 1 file changed, 8 insertions(+), 156 deletions(-) diff --git a/_WidgetBase.js b/_WidgetBase.js index 3ab4cad11..cfff200b1 100644 --- a/_WidgetBase.js +++ b/_WidgetBase.js @@ -3,7 +3,6 @@ define([ "dojo/_base/array", // array.forEach array.map "dojo/aspect", "dojo/_base/config", // config.blankGif - "dojo/_base/connect", // connect.connect "dojo/_base/declare", // declare "dojo/dom", // dom.byId "dojo/dom-attr", // domAttr.set domAttr.remove @@ -16,14 +15,13 @@ define([ "dojo/_base/lang", // mixin(), isArray(), etc. "dojo/on", "dojo/Stateful", // Stateful - "dojo/topic", "dojo/_base/window", // win.body() "./Destroyable", "dojo/has!dojo-bidi?./_BidiMixin", "./registry" // registry.getUniqueId(), registry.findWidgets() -], function(require, array, aspect, config, connect, declare, +], function(require, array, aspect, config, declare, dom, domAttr, domClass, domConstruct, domGeometry, domStyle, has, kernel, - lang, on, Stateful, topic, win, Destroyable, _BidiMixin, registry){ + lang, on, Stateful, win, Destroyable, _BidiMixin, registry){ // module: // dijit/_WidgetBase @@ -204,50 +202,6 @@ define([ _started: false, =====*/ - // attributeMap: [protected] Object - // Deprecated. Instead of attributeMap, widget should have a _setXXXAttr attribute - // for each XXX attribute to be mapped to the DOM. - // - // attributeMap sets up a "binding" between attributes (aka properties) - // of the widget and the widget's DOM. - // Changes to widget attributes listed in attributeMap will be - // reflected into the DOM. - // - // For example, calling set('title', 'hello') - // on a TitlePane will automatically cause the TitlePane's DOM to update - // with the new title. - // - // attributeMap is a hash where the key is an attribute of the widget, - // and the value reflects a binding to a: - // - // - DOM node attribute - // | focus: {node: "focusNode", type: "attribute"} - // Maps this.focus to this.focusNode.focus - // - // - DOM node innerHTML - // | title: { node: "titleNode", type: "innerHTML" } - // Maps this.title to this.titleNode.innerHTML - // - // - DOM node innerText - // | title: { node: "titleNode", type: "innerText" } - // Maps this.title to this.titleNode.innerText - // - // - DOM node CSS class - // | myClass: { node: "domNode", type: "class" } - // Maps this.myClass to this.domNode.className - // - // If the value is an array, then each element in the array matches one of the - // formats of the above list. - // - // There are also some shorthands for backwards compatibility: - // - // - string --> { node: string, type: "attribute" }, for example: - // - // | "focusNode" ---> { node: "focusNode", type: "attribute" } - // - // - "" --> { node: "domNode", type: "attribute" } - attributeMap: {}, - // _blankGif: [protected] String // Path to a blank 1x1 image. // Used by `` nodes in templates that really get their image via CSS background-image. @@ -285,11 +239,6 @@ define([ attrs = ctor._setterAttrs = [], // attributes with custom setters onMap = (ctor._onMap = {}); - // Items in this.attributeMap are like custom setters. For back-compat, remove for 2.0. - for(var name in proto.attributeMap){ - attrs.push(name); - } - // Loop over widget properties, collecting properties with custom setters and filling in ctor._onMap. for(name in proto){ if(/^on/.test(name)){ @@ -298,9 +247,7 @@ define([ if(/^_set[A-Z](.*)Attr$/.test(name)){ name = name.charAt(4).toLowerCase() + name.substr(5, name.length - 9); - if(!proto.attributeMap || !(name in proto.attributeMap)){ - attrs.push(name); - } + attrs.push(name); } } @@ -350,10 +297,6 @@ define([ // store pointer to original DOM tree this.srcNodeRef = dom.byId(srcNodeRef); - // No longer used, remove for 2.0. - this._connects = []; - this._supportingWidgets = []; - // this is here for back-compat, remove in 2.0 (but check NodeList-instantiate.html test) if(this.srcNodeRef && (typeof this.srcNodeRef.id == "string")){ this.id = this.srcNodeRef.id; @@ -387,8 +330,7 @@ define([ var deleteSrcNodeRef; if(this.domNode){ - // Copy attributes listed in attributeMap into the [newly created] DOM for the widget. - // Also calls custom setters for all attributes with custom setters. + // Call custom setters for all attributes with custom setters. this._applyAttributes(); // If srcNodeRef was specified, then swap out original srcNode for this widget's DOM tree. @@ -419,15 +361,12 @@ define([ _applyAttributes: function(){ // summary: // Step during widget creation to copy widget attributes to the - // DOM according to attributeMap and _setXXXAttr objects, and also to call + // DOM according to _setXXXAttr objects, and also to call // custom _setXXXAttr() methods. // // Skips over blank/false attribute values, unless they were explicitly specified // as parameters to the widget, since those are the default anyway, // and setting tabIndex="" is different than not setting tabIndex at all. - // - // For backwards-compatibility reasons attributeMap overrides _setXXXAttr when - // _setXXXAttr is a hash/string/array, but _setXXXAttr as a functions override attributeMap. // tags: // private @@ -573,10 +512,6 @@ define([ } } - // Back-compat, remove for 2.0 - array.forEach(this._connects, lang.hitch(this, "disconnect")); - array.forEach(this._supportingWidgets, destroy); - // Destroy supporting widgets, but not child widgets under this.containerNode (for 2.0, destroy child widgets // here too). if() statement is to guard against exception if destroy() called multiple times (see #15815). if(this.domNode){ @@ -653,9 +588,6 @@ define([ // Sets the style attribute of the widget according to value, // which is either a hash like {height: "5px", width: "3px"} // or a plain string - // description: - // Determines which node to set the style on based on style setting - // in attributeMap. // tags: // protected @@ -681,7 +613,6 @@ define([ // summary: // Reflect a widget attribute (title, tabIndex, duration etc.) to // the widget DOM, as specified by commands parameter. - // If commands isn't specified then it's looked up from attributeMap. // Note some attributes like "type" // cannot be processed this way as they are not mutable. // attr: @@ -690,8 +621,6 @@ define([ // tags: // private - commands = arguments.length >= 3 ? commands : this.attributeMap[attr]; - array.forEach(lang.isArray(commands) ? commands : [commands], function(command){ // Get target node and what we are doing to that node @@ -793,17 +722,15 @@ define([ }else{ // Mapping from widget attribute to DOMNode/subwidget attribute/value/etc. // Map according to: - // 1. attributeMap setting, if one exists (TODO: attributeMap deprecated, remove in 2.0) - // 2. _setFooAttr: {...} type attribute in the widget (if one exists) - // 3. apply to focusNode or domNode if standard attribute name, excluding funcs like onClick. + // 1. _setFooAttr: {...} type attribute in the widget (if one exists) + // 2. apply to focusNode or domNode if standard attribute name, excluding funcs like onClick. // Checks if an attribute is a "standard attribute" by whether the DOMNode JS object has a similar // attribute name (ex: accept-charset attribute matches jsObject.acceptCharset). // Note also that Tree.focusNode() is a function not a DOMNode, so test for that. var defaultNode = this.focusNode && !lang.isFunction(this.focusNode) ? "focusNode" : "domNode", tag = this[defaultNode] && this[defaultNode].tagName, attrsForTag = tag && (tagAttrs[tag] || (tagAttrs[tag] = getAttrs(this[defaultNode]))), - map = name in this.attributeMap ? this.attributeMap[name] : - names.s in this ? this[names.s] : + map = names.s in this ? this[names.s] : ((attrsForTag && names.l in attrsForTag && typeof value != "function") || /^aria-|^data-|^role$/.test(name)) ? defaultNode : null; if(map != null){ @@ -977,81 +904,6 @@ define([ return registry.getEnclosingWidget(this.domNode.parentNode); }, - connect: function(/*Object|null*/ obj, /*String|Function*/ event, /*String|Function*/ method){ - // summary: - // Deprecated, will be removed in 2.0, use this.own(on(...)) or this.own(aspect.after(...)) instead. - // - // Connects specified obj/event to specified method of this object - // and registers for disconnect() on widget destroy. - // - // Provide widget-specific analog to dojo.connect, except with the - // implicit use of this widget as the target object. - // Events connected with `this.connect` are disconnected upon - // destruction. - // returns: - // A handle that can be passed to `disconnect` in order to disconnect before - // the widget is destroyed. - // example: - // | var btn = new Button(); - // | // when foo.bar() is called, call the listener we're going to - // | // provide in the scope of btn - // | btn.connect(foo, "bar", function(){ - // | console.debug(this.toString()); - // | }); - // tags: - // protected - - return this.own(connect.connect(obj, event, this, method))[0]; // handle - }, - - disconnect: function(handle){ - // summary: - // Deprecated, will be removed in 2.0, use handle.remove() instead. - // - // Disconnects handle created by `connect`. - // tags: - // protected - - handle.remove(); - }, - - subscribe: function(t, method){ - // summary: - // Deprecated, will be removed in 2.0, use this.own(topic.subscribe()) instead. - // - // Subscribes to the specified topic and calls the specified method - // of this object and registers for unsubscribe() on widget destroy. - // - // Provide widget-specific analog to dojo.subscribe, except with the - // implicit use of this widget as the target object. - // t: String - // The topic - // method: Function - // The callback - // example: - // | var btn = new Button(); - // | // when /my/topic is published, this button changes its label to - // | // be the parameter of the topic. - // | btn.subscribe("/my/topic", function(v){ - // | this.set("label", v); - // | }); - // tags: - // protected - return this.own(topic.subscribe(t, lang.hitch(this, method)))[0]; // handle - }, - - unsubscribe: function(/*Object*/ handle){ - // summary: - // Deprecated, will be removed in 2.0, use handle.remove() instead. - // - // Unsubscribes handle created by this.subscribe. - // Also removes handle from this widget's list of subscriptions - // tags: - // protected - - handle.remove(); - }, - isLeftToRight: function(){ // summary: // Return this widget's explicit or implicit orientation (true for LTR, false for RTL)