Skip to content

Commit

Permalink
Merge pull request #114 from Aosanders/master
Browse files Browse the repository at this point in the history
splice fix training
  • Loading branch information
justinbmeyer committed Jun 2, 2018
2 parents c648990 + 9ebeadf commit 221c5f4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions reflections/get-set/get-set-test.js
Expand Up @@ -90,3 +90,18 @@ QUnit.test("setValue", function(){

QUnit.deepEqual(obj, {value: 2}, "can.setValue");
});

QUnit.test("splice", function(){
var arr = ["a","b"];

getSetReflections.splice(arr, 0, 1);

QUnit.deepEqual(arr, ["b"], "removes item with no additions");

arr = ["a","b"];

getSetReflections.splice(arr, 0, 1, ["c", "d"]);

QUnit.deepEqual(arr, ["c","d","b"], "removes item with no additions");

});
4 changes: 4 additions & 0 deletions reflections/get-set/get-set.js
Expand Up @@ -191,6 +191,10 @@ var reflections = {
howMany = removing;
}

if(arguments.length <= 3){
adding = [];
}

var splice = obj[canSymbol.for("can.splice")];
if(splice) {
return splice.call(obj, index, howMany, adding);
Expand Down
2 changes: 2 additions & 0 deletions reflections/type/type-test.js
Expand Up @@ -82,6 +82,8 @@ QUnit.test("isMapLike", function(){
QUnit.test("isMoreListLikeThanMapLike", function(){
QUnit.equal(typeReflections.isMoreListLikeThanMapLike({}), false, "Object");
QUnit.equal(typeReflections.isMoreListLikeThanMapLike([]), true, "Array");
QUnit.equal(typeReflections.isMoreListLikeThanMapLike(undefined), "undefined", "undefined");
QUnit.equal(typeReflections.isMoreListLikeThanMapLike(null), "undefined", "null");
});

QUnit.test("isObservableLike", function(){
Expand Down
3 changes: 3 additions & 0 deletions reflections/type/type.js
Expand Up @@ -453,6 +453,9 @@ module.exports = {
if(obj instanceof Array) {
return true;
}
if(obj === undefined || obj === null) {
return "undefined";
}
var value = obj[canSymbol.for("can.isMoreListLikeThanMapLike")];
if(value !== undefined) {
return value;
Expand Down

0 comments on commit 221c5f4

Please sign in to comment.