diff --git a/src/instance/properties.js b/src/instance/properties.js index 428a569..293913d 100644 --- a/src/instance/properties.js +++ b/src/instance/properties.js @@ -118,8 +118,8 @@ if (Array.isArray(value)) { log.observe && console.log('[%s] observeArrayValue: register observer [%s]', this.localName, name, value); var observer = new ArrayObserver(value); - observer.open(function(value, old) { - this.invokeMethod(callbackName, [old]); + observer.open(function(splices) { + this.invokeMethod(callbackName, [splices]); }, this); this.registerNamedObserver(name + '__array', observer); } diff --git a/test/html/property-array-changes.html b/test/html/property-array-changes.html index e3950b1..44f0093 100644 --- a/test/html/property-array-changes.html +++ b/test/html/property-array-changes.html @@ -29,20 +29,20 @@ this.a = a; }, aChanged: function() { - this.nextTest(); + this.nextTest(arguments); }, bChanged: function() { - this.nextTest(); + this.nextTest(arguments); }, currentTest: 0, getCurrentTest: function() { return this['test' + this.currentTest]; }, - nextTest: function() { + nextTest: function(args) { var m = this.getCurrentTest(); //console.log(this.currentTest); if (m) { - m.call(this); + m.apply(this, args); } this.currentTest++; if (!this.getCurrentTest()) { @@ -67,13 +67,16 @@ this.a.push(1); this.a.push(2); }, - test4: function() { + test4: function(splices) { chai.assert.equal(this.a, a1, 'array property is correct value'); chai.assert.equal(this.a.length, 2, 'noticed array addition'); + chai.assert.equal(arguments.length, 1, 'only 1 argument when array mutates'); + chai.assert.equal(splices[0].addedCount, 2, 'addedCount splice correctly sent in splices'); this.a.shift(); }, - test5: function() { + test5: function(splices) { chai.assert.equal(this.a.length, 1, 'noticed array removal'); + chai.assert.equal(splices[0].removed.length, 1, 'removed splices correctly sent'); a.push(55); setTimeout(this.nextTest.bind(this), 0); },