Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#16629 closed defect (fixed)

StatefulArray incorrect implementation of concat

Reported by: ben hockey Owned by: Ed Chatelain
Priority: undecided Milestone: 1.8.4
Component: DojoX MVC Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

calling concat on a StatefulArray? with no args will add an undefined element to the array.

var arr = new StatefulArray(['alice', 'bob']),
   copy = arr.concat();

console.log(copy); // ['alice', 'bob', undefined]

it is also not possible to concat more than one array together or add multiple elements (see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat for API regarding how arrays concat multiple arguments)

a possible implementation to fix this might be

concat: function () {
    return new StatefulArray([].concat.apply(this, arguments));
}

see http://jsfiddle.net/neonstalwart/aqphE/ for a small test page

Change History (3)

comment:1 Changed 6 years ago by Ed Chatelain

In [30488]:

refs #16629 Support varargs in concat() in dojox/mvc/StatefulArray. Thanks neonstalwart and asudoh. !strict

comment:2 Changed 6 years ago by Ed Chatelain

Resolution: fixed
Status: newclosed

In [30489]:

fixes #16629 Support varargs in concat() in dojox/mvc/StatefulArray. Thanks neonstalwart and asudoh. !strict

comment:3 Changed 6 years ago by Ed Chatelain

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