Changeset 13683
- Timestamp:
- 05/10/08 20:25:50 (5 days ago)
- Location:
- dijit/trunk
- Files:
-
- 1 added
- 1 modified
-
tests/test_WidgetPreserve.html (added)
-
_Widget.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/_Widget.js
r13521 r13683 202 202 //////////// DESTROY FUNCTIONS //////////////////////////////// 203 203 204 destroyRecursive: function(/*Boolean*/ finalize){204 destroyRecursive: function(/*Boolean*/ preserveDom){ 205 205 // summary: 206 206 // Destroy this widget and it's descendants. This is the generic … … 208 208 // cleanly discard with a widget. Once a widget is destroyed, it's 209 209 // removed from the manager object. 210 // finalize: Boolean 211 // is this function being called part of global environment 212 // tear-down? 213 214 this.destroyDescendants(); 215 this.destroy(); 216 }, 217 218 destroy: function(/*Boolean*/ finalize){ 210 // preserveDom: Boolean 211 // If true, this method will leave the original Dom structure alone 212 // of descendant Widgets. Note: This will NOT work with _Templated 213 // widgets. 214 // 215 this.destroyDescendants(preserveDom); 216 this.destroy(preserveDom); 217 }, 218 219 destroy: function(/*Boolean*/ preserveDom){ 219 220 // summary: 220 221 // Destroy this widget, but not its descendants 221 // finalize: Boolean222 // is this function being called part of global environment223 // tear-down?222 // preserveDom: Boolean 223 // If true, this method will leave the original Dom structure alone. 224 // Note: This will not yet work with _Templated widgets 224 225 225 226 this.uninitialize(); … … 231 232 dojo.forEach(this._supportingWidgets || [], function(w){ w.destroy(); }); 232 233 233 this.destroyRendering( finalize);234 this.destroyRendering(preserveDom); 234 235 dijit.registry.remove(this.id); 235 236 }, 236 237 237 destroyRendering: function(/*Boolean*/ finalize){238 destroyRendering: function(/*Boolean*/ preserveDom){ 238 239 // summary: 239 240 // Destroys the DOM nodes associated with this widget 240 // finalize: Boolean 241 // is this function being called part of global environment 242 // tear-down? 243 241 // preserveDom: Boolean 242 // If true, this method will leave the original Dom structure alone 243 // during tear-down. Note: this will not work with _Templated 244 // widgets yet. 245 244 246 if(this.bgIframe){ 245 this.bgIframe.destroy( );247 this.bgIframe.destroy(preserveDom); 246 248 delete this.bgIframe; 247 249 } 248 250 249 251 if(this.domNode){ 250 dojo._destroyElement(this.domNode); 252 if(!preserveDom){ 253 dojo._destroyElement(this.domNode); 254 } 251 255 delete this.domNode; 252 256 } 253 257 254 258 if(this.srcNodeRef){ 255 dojo._destroyElement(this.srcNodeRef); 259 if(!preserveDom){ 260 dojo._destroyElement(this.srcNodeRef); 261 } 256 262 delete this.srcNodeRef; 257 263 } 258 264 }, 259 265 260 destroyDescendants: function( ){266 destroyDescendants: function(/* Boolean */ preserveDom){ 261 267 // summary: 262 268 // Recursively destroy the children of this widget and their 263 269 // descendants. 264 270 // preserveDom: Boolean 271 // If true, the preserveDom attribute is passed to all descendant 272 // widget's .destroy() method. Not for use with _Templated widgets. 273 265 274 // TODO: should I destroy in the reverse order, to go bottom up? 266 dojo.forEach(this.getDescendants(), function(widget){ widget.destroy( ); });275 dojo.forEach(this.getDescendants(), function(widget){ widget.destroy(preserveDom); }); 267 276 }, 268 277