Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#17325 closed defect (fixed)

StatefulArray.set("length", ...) does not reduce array length

Reported by: clancymalcolm Owned by: Ed Chatelain
Priority: undecided Milestone: 1.9.2
Component: DojoX MVC Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

When you reduce a StatefulArray?'s length using .set("length", ...) it doesn't remove the elements correctly. See the code fix shown below:

            set: function(/*Number|String*/ name, /*Anything*/ value){
                // summary:
                //      Sets a new value to an array.
                // name: Number|String
                //      The property name.
                // value: Anything
                //      The new value.

                if(name == "length"){
                    var old = this.get("length");
                    if(old < value){
                        this.splice.apply(this, [old, 0].concat(new Array(value - old)));
                    // }else if(value > old){  // <-- Original Dojo code
                    }else if(old > value){     // <-- Fixed by Clancy
                        this.splice.apply(this, [value, old - value]);
                    }

Change History (5)

comment:1 Changed 6 years ago by bill

Component: GeneralDojoX MVC
Owner: set to Ed Chatelain

comment:3 Changed 6 years ago by Ed Chatelain <ed.chatelain@…>

Resolution: fixed
Status: newclosed

In c7f962a8b4aee6bd7832a5eda01776fdf6b7c7ea/dojox:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:4 Changed 6 years ago by Ed Chatelain <ed.chatelain@…>

In 24aa06f5570aa4ab21c189d8ada2a16133374fb8/dojox:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:5 Changed 6 years ago by Ed Chatelain

Milestone: tbd1.9.2
Note: See TracTickets for help on using tickets.