Ticket #6604 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

getDescendants() broken for various layout widgets

Reported by: bill Owned by: bill
Priority: normal Milestone: 1.2
Component: Dijit Version: 1.1.0
Severity: normal Keywords:
Cc:

Description (last modified by bill) (diff)

This is fallout from #5865.

In Dojo 1.1, _Widget.getDescendats() searches widgets off "containerNode", which did under "domNode" in 1.0.

 getDescendants: function(){
  // summary:
  // Returns all the widgets that contained by this, i.e., all
widgets underneath this.containerNode.
  if(this.containerNode){
   var list= dojo.query('[widgetId]', this.containerNode);
   return list.map(dijit.byNode);  // Array
  }else{
   return [];
  }
 },

This change causes destroyDescendants() not working for some layout widgets, as they do not set "containerNode"...

While, _Container.getChildren() still does access domNode:

 getChildren: function(){
  // summary:
  //  Returns array of children widgets
  return dojo.query("> [widgetId]", this.containerNode || this.domNode).map(dijit.byNode); // Array
 },

Maybe can add this to _Container.postCreate():

if(!this.containerNode){
   this.containerNode = this.domNode;
}

and then modify getChildren() and friends to use this.containerNode exclusively.

Note that getDescendants()/destroyDescendants() on a plain widget with widgets in it's template but no true descendants should do nothing; need to make sure that the widgets in the template aren't destroyed in that case either.

Change History

Changed 7 months ago by bill

  • description modified (diff)

Changed 7 months ago by bill

  • status changed from new to closed
  • resolution set to fixed

(In [13521]) Fix leak where destroyDescendants() wasn't working on layout widgets.

Problem was that getDescendants() wasn't finding the children (and grandchildren, etc) of widgets which didn't set containerNode, particularly layout widgets with no templates.

Fixes #6604. !strict

Changed 7 months ago by bill

(In [13537]) Fix bug where closing a tree node would hide the node itself rather than just it's children; regression from [13521].

TreeNode? is unusual in that it defines containerNode lazily, so the code in _Container to set containerNode automatically was actually messing things up.

Fixes #6673, refs #6604. !strict

Changed 7 months ago by bill

(In [13568]) Avoid null reference. Refs #6673, #6604. !strict

Note: See TracTickets for help on using tickets.