Opened 12 years ago
Closed 12 years ago
#9986 closed defect (fixed)
dijit._Container.getIndexOfChild() code reduction
Reported by: | Les | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Dijit | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
This is lightly tested.
These two methods should be functionally equivalent, but the last one is simpler and shorter.
getIndexOfChild: function(/*Widget*/ child){ // summary: // Gets the index of the child in this container or -1 if not found var children = this.getChildren(); for(var i=0, c; c=children[i]; i++){ if(c == child){ return i; // int } } return -1; // int }
getIndexOfChild: function(/*Widget*/ child){ // summary: // Gets the index of the child in this container or -1 if not found return dojo.indexOf(this.getChildren(), child); }
Change History (3)
comment:1 Changed 12 years ago by
Component: | General → Dijit |
---|---|
Owner: | anonymous deleted |
comment:2 Changed 12 years ago by
Milestone: | tbd → 1.4 |
---|---|
Owner: | set to bill |
Status: | new → assigned |
Anyway, I will make your suggested change, thanks!
comment:3 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [20280]) dijit._Contained and dijit._Container code reduction from Les (CLA on file) and me.
Seems like there is still a lot of redundancy though between _Container (_getSiblingOfChild, _nextElement) and _Contained (_getSibling, _getPrevSibling, _getNextSibling). The only difference I see is that _Container._getSiblingOfChild() skips over non-Widget siblings; not sure if/why that code is needed. Also might make sense to just use dojo.query() for these methods.
Also updating API doc for return codes.
That does seem shorter, although it strikes me as strange that both the old and new code is comparing _Widget objects rather than just comparing the widget id's.