Skip to content

Commit 3f3fd2d

Browse files
author
Scott J. Miles
committed
fix optimizePropertyMaps to avoid duplicate entries in name lists, add one primitive test, fixes #298
1 parent 7257c7b commit 3f3fd2d

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

src/declaration/properties.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@
1919
}
2020
}
2121
},
22-
optimizePropertyMaps: function(prototype, base) {
22+
optimizePropertyMaps: function(prototype) {
2323
if (prototype.observe) {
24-
// combine name list
25-
prototype._observeNames = Object.keys(prototype.observe).concat(base._observeNames || []);
24+
// construct name list
25+
var a = prototype._observeNames = [];
26+
for (var n in prototype.observe) {
27+
a.push(n);
28+
}
2629
// build value list
2730
prototype._observeValues = valuesForNames(prototype._observeNames, prototype.observe);
2831
}
2932
if (prototype.publish) {
30-
// combine name list
31-
prototype._publishNames = Object.keys(prototype.publish).concat(base._publishNames || []);
33+
// construct name list
34+
var a = prototype._publishNames = [];
35+
for (var n in prototype.publish) {
36+
a.push(n);
37+
}
3238
// build value list
3339
prototype._publishValues = valuesForNames(prototype._publishNames, prototype.publish);
3440
}

src/declaration/prototype.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@
5353
// chain custom api to inherited
5454
prototype = this.chainObject(prototype, base);
5555
// build side-chained lists to optimize iterations
56-
this.optimizePropertyMaps(prototype, base);
57-
// inherit publishing meta-data
58-
//this.inheritAttributesObjects(prototype);
59-
//this.inheritDelegates(prototype);
60-
// x-platform fixups
56+
this.optimizePropertyMaps(prototype);
57+
// x-platform fixup
6158
ensurePrototypeTraversal(prototype);
6259
return prototype;
6360
},

test/html/reflection.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
zot: 3,
2929
bar: 2
3030
},
31-
Foo: '1'
31+
Foo: '1',
32+
skonkChanged: function() {
33+
}
3234
});
3335
</script>
3436
</polymer-element>
@@ -37,7 +39,10 @@
3739

3840
<polymer-element name="x-three" extends="x-two" attributes="quux">
3941
<script>
40-
Polymer('x-three', {});
42+
Polymer('x-three', {
43+
skonkChanged: function() {
44+
}
45+
});
4146
</script>
4247
</polymer-element>
4348

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

0 commit comments

Comments
 (0)