Opened 12 years ago
Closed 11 years ago
#10100 closed task (wontfix)
Tree code minor simplification
Reported by: | Les | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.6 |
Component: | Dijit | Version: | 1.4.0b |
Keywords: | Tree | Cc: | bill |
Blocked By: | Blocking: |
Description
I found some Tree code that can be simplified :)
// Current code this.getChildren().forEach(function(child){ dijit._Container.prototype.removeChild.call(this, child); }, this); // New code this.getChildren().forEach(dijit._Container.prototype.removeChild); // Current code dojo.forEach(this.getChildren(), function(child, idx){ child._updateLayout(); }); // New code (removed unused local var idx) dojo.forEach(this.getChildren(), function(child){ child._updateLayout(); });
Change History (5)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
As discussed in #9985 we can't in general depend on getChildren() returning a NodeList rather than a simple array. I guess it's a safe for Tree though, although I am surprised that Tree uses that syntax already.
About:
this.getChildren().forEach(dijit._Container.prototype.removeChild);
Are you sure that "this" will be the correct value (a pointer to the widget) inside of _Container.removeChild()?
Of course removing the unused variable makes sense.
comment:3 Changed 12 years ago by
Milestone: | tbd → 1.5 |
---|---|
Type: | enhancement → task |
comment:4 Changed 11 years ago by
Milestone: | 1.5 → 1.6 |
---|
comment:5 Changed 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Can't depend on getChildren() returning a NodeList, as a matter of fact in 1.5 it doesn't. Maybe that will change for 2.0 in which case we'll update all usages of getChildren(), but for now I'm going to close this ticket.
I see code in a few place that could be tiny bit shorter. It doesn't amount to much, but the code will be smaller.