Skip to content

Commit 69f364c

Browse files
committed
fix an issue that array observer not working if it is set on the
prototype.
1 parent cea51a6 commit 69f364c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/instance/properties.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) {
2727
o.addPath(this, n);
2828
// observer array properties
29-
var pd = Object.getOwnPropertyDescriptor(this.__proto__, name);
29+
var pd = Object.getOwnPropertyDescriptor(this.__proto__, n);
3030
if (pd && pd.value) {
31-
this.observeArrayValue(name, pd.value, null);
31+
this.observeArrayValue(n, pd.value, null);
3232
}
3333
}
3434
for (var i=0, l=pn$.length, n; (i<l) && (n=pn$[i]); i++) {

test/html/property-array-changes.html

+8
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616
(function() {
1717
var a = [], a1 = [];
1818
Polymer('x-test', {
19+
b: [],
1920
ready: function() {
2021
this.a = a;
2122
},
2223
aChanged: function() {
2324
this.nextTest();
2425
},
26+
bChanged: function() {
27+
this.nextTest();
28+
},
2529
currentTest: 0,
2630
getCurrentTest: function() {
2731
return this['test' + this.currentTest];
@@ -68,6 +72,10 @@
6872
},
6973
test6: function() {
7074
chai.assert.equal(this.a.length, 1, 'old array properly unobserved');
75+
this.b.push(1);
76+
},
77+
test7: function() {
78+
chai.assert.equal(this.b.length, 1, 'noticed array addition');
7179
}
7280
});
7381
})();

0 commit comments

Comments
 (0)