Skip to content

Commit b46bb79

Browse files
committed
Fixes Polymer#120.
1 parent fbd9c6c commit b46bb79

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/declaration/properties.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,27 @@
1111

1212
// element api
1313

14+
var observationBlacklist = ['attribute'];
15+
1416
var properties = {
1517
inferObservers: function(prototype) {
1618
// called before prototype.observe is chained to inherited object
1719
var observe = prototype.observe, property;
1820
for (var n in prototype) {
1921
if (n.slice(-7) === 'Changed') {
20-
if (!observe) {
21-
observe = (prototype.observe = {});
22+
property = n.slice(0, -7);
23+
if (this.canObserveProperty(property)) {
24+
if (!observe) {
25+
observe = (prototype.observe = {});
26+
}
27+
observe[property] = observe[property] || n;
2228
}
23-
property = n.slice(0, -7)
24-
observe[property] = observe[property] || n;
2529
}
2630
}
2731
},
32+
canObserveProperty: function(property) {
33+
return (observationBlacklist.indexOf(property) < 0);
34+
},
2835
explodeObservers: function(prototype) {
2936
// called before prototype.observe is chained to inherited object
3037
var o = prototype.observe;

test/html/property-changes.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<script>
2525
(function() {
2626
var changes = 0;
27-
var doneChanges = 2;
27+
var doneChanges = 3;
2828
function checkDone() {
2929
if (doneChanges == ++changes) {
3030
done();
@@ -33,7 +33,12 @@
3333

3434
Polymer('x-test', {
3535
bar: '',
36+
attributeChangedCount: 0,
3637
ready: function() {
38+
this.attribute = 'foo';
39+
this.deliverChanges();
40+
chai.assert.equal(this.attributeChangedCount, 0, 'attributeChanged does not observe property attribute');
41+
this.setAttribute('nog', 'nog');
3742
this.bar = 'bar';
3843
setTimeout(function() {
3944
this.zonk = 'zonk';
@@ -46,6 +51,11 @@
4651
zonkChanged: function() {
4752
chai.assert.equal(this.zonk, 'zonk', 'change calls *Changed without prototype value')
4853
checkDone();
54+
},
55+
attributeChanged: function() {
56+
this.attributeChangedCount++;
57+
chai.assert.equal(this.getAttribute('nog'), 'nog', 'attributeChanged called in response to an attribute value changing')
58+
checkDone();
4959
}
5060
});
5161
})();

0 commit comments

Comments
 (0)