diff --git a/src/array/method/Pop.js b/src/array/method/Pop.js index a074ff9..1e383c2 100644 --- a/src/array/method/Pop.js +++ b/src/array/method/Pop.js @@ -6,7 +6,7 @@ define([], function() { model.pop = function() { - originalPop.apply(this, arguments); + var popped = originalPop.apply(this, arguments); var property = properties.pop(); @@ -21,6 +21,8 @@ define([], function() { } model.subscribableLength = model.length; + + return popped; }; } diff --git a/src/array/method/Shift.js b/src/array/method/Shift.js index 86df3cc..9658404 100644 --- a/src/array/method/Shift.js +++ b/src/array/method/Shift.js @@ -6,7 +6,7 @@ define([], function() { model.shift = function() { - originalShift.apply(this, arguments); + var shifted = originalShift.apply(this, arguments); var property = properties.shift(); @@ -21,6 +21,8 @@ define([], function() { } model.subscribableLength = model.length; + + return shifted; }; } diff --git a/src/array/method/Splice.js b/src/array/method/Splice.js index 7b28234..70e8330 100644 --- a/src/array/method/Splice.js +++ b/src/array/method/Splice.js @@ -12,8 +12,10 @@ define(["property/TransientProperty"], function(TransientProperty) { removeObjects(start, deleteCount); insertObjects(start, newObjects); - originalSplice.apply(this, arguments); + var spliced = originalSplice.apply(this, arguments); model.subscribableLength = model.length; + + return spliced; }; function normaliseStart(start) { diff --git a/test/array/method/pop.html b/test/array/method/pop.html index 42dbcd5..359e1dd 100644 --- a/test/array/method/pop.html +++ b/test/array/method/pop.html @@ -68,7 +68,8 @@ DOMElement, TransientProperty) { - var model = [{}]; + var object = {}; + var model = [object]; var element = new DOMElement(document.querySelector("#pop")); var elements = [element.toArrayElement(1)]; var propertyType = new FakePropertyType(); @@ -76,9 +77,10 @@ new Pop(model, elements, properties); - model.pop(); + var popped = model.pop(); assert.strictEqual(model.length, 0); + assert.strictEqual(popped, object); assert.strictEqual(properties.length, 0); assert.strictEqual(element.get().children.length, 0); assert.ok(propertyType.removeBindingWasCalled); diff --git a/test/array/method/shift.html b/test/array/method/shift.html index cca8f84..6ed7850 100644 --- a/test/array/method/shift.html +++ b/test/array/method/shift.html @@ -68,7 +68,8 @@ DOMElement, TransientProperty) { - var model = [{}]; + var object = {}; + var model = [object]; var element = new DOMElement(document.querySelector("#shift")); var elements = [element.toArrayElement(1)]; var propertyType = new FakePropertyType(); @@ -76,9 +77,10 @@ new Shift(model, elements, properties); - model.shift(); + var shifted = model.shift(); assert.strictEqual(model.length, 0); + assert.strictEqual(shifted, object); assert.strictEqual(properties.length, 0); assert.strictEqual(element.get().children.length, 0); assert.ok(propertyType.removeBindingWasCalled); diff --git a/test/array/method/splice.html b/test/array/method/splice.html index 26326b5..3e42a87 100644 --- a/test/array/method/splice.html +++ b/test/array/method/splice.html @@ -368,16 +368,19 @@ Splice, DOMElement) { - var model = [{}]; + var object = {}; + var model = [object]; var element = new DOMElement(document.querySelector("#remove")); var elements = [element.toArrayElement(1)]; var properties = [{}]; new Splice(model, elements, properties, new FakePropertyType()); - model.splice(0, 1); + var spliced = model.splice(0, 1); assert.strictEqual(model.length, 0); + assert.strictEqual(spliced.length, 1); + assert.strictEqual(spliced[0], object); assert.strictEqual(element.get().children.length, 0); assert.strictEqual(properties.length, 0);