Skip to content

Commit

Permalink
fix optimizePropertyMaps to avoid duplicate entries in name lists, ad…
Browse files Browse the repository at this point in the history
…d one primitive test, fixes #298
  • Loading branch information
Scott J. Miles committed Sep 27, 2013
1 parent 7257c7b commit 3f3fd2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
16 changes: 11 additions & 5 deletions src/declaration/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
}
}
},
optimizePropertyMaps: function(prototype, base) {
optimizePropertyMaps: function(prototype) {
if (prototype.observe) {
// combine name list
prototype._observeNames = Object.keys(prototype.observe).concat(base._observeNames || []);
// construct name list
var a = prototype._observeNames = [];
for (var n in prototype.observe) {
a.push(n);
}
// build value list
prototype._observeValues = valuesForNames(prototype._observeNames, prototype.observe);
}
if (prototype.publish) {
// combine name list
prototype._publishNames = Object.keys(prototype.publish).concat(base._publishNames || []);
// construct name list
var a = prototype._publishNames = [];
for (var n in prototype.publish) {
a.push(n);
}
// build value list
prototype._publishValues = valuesForNames(prototype._publishNames, prototype.publish);
}
Expand Down
7 changes: 2 additions & 5 deletions src/declaration/prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@
// chain custom api to inherited
prototype = this.chainObject(prototype, base);
// build side-chained lists to optimize iterations
this.optimizePropertyMaps(prototype, base);
// inherit publishing meta-data
//this.inheritAttributesObjects(prototype);
//this.inheritDelegates(prototype);
// x-platform fixups
this.optimizePropertyMaps(prototype);
// x-platform fixup
ensurePrototypeTraversal(prototype);
return prototype;
},
Expand Down
10 changes: 8 additions & 2 deletions test/html/reflection.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
zot: 3,
bar: 2
},
Foo: '1'
Foo: '1',
skonkChanged: function() {
}
});
</script>
</polymer-element>
Expand All @@ -37,7 +39,10 @@

<polymer-element name="x-three" extends="x-two" attributes="quux">
<script>
Polymer('x-three', {});
Polymer('x-three', {
skonkChanged: function() {
}
});
</script>
</polymer-element>

Expand All @@ -47,6 +52,7 @@
chai.assert.equal(x1.Foo, 'squid');
var x3 = document.querySelector('x-three');
chai.assert.equal(x3.Foo, '3');
chai.assert.equal(x3._observeNames.length, 1, 'x3 should have exactly one observed name');
done();
});
</script>
Expand Down

0 comments on commit 3f3fd2d

Please sign in to comment.