Skip to content

Commit

Permalink
splice fix training fixes #112
Browse files Browse the repository at this point in the history
  • Loading branch information
Aosanders committed Jun 1, 2018
1 parent aaed7a8 commit ca389b5
Show file tree
Hide file tree
Showing 2 changed files with 19 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

0 comments on commit ca389b5

Please sign in to comment.