From 3f3fd2ddbd1042d349459e57561c5df9335d59e8 Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Fri, 27 Sep 2013 15:54:00 -0700 Subject: [PATCH] fix optimizePropertyMaps to avoid duplicate entries in name lists, add one primitive test, fixes #298 --- src/declaration/properties.js | 16 +++++++++++----- src/declaration/prototype.js | 7 ++----- test/html/reflection.html | 10 ++++++++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/declaration/properties.js b/src/declaration/properties.js index 8312204209..d72144f876 100644 --- a/src/declaration/properties.js +++ b/src/declaration/properties.js @@ -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); } diff --git a/src/declaration/prototype.js b/src/declaration/prototype.js index 14d52afb5e..1965f4eda2 100644 --- a/src/declaration/prototype.js +++ b/src/declaration/prototype.js @@ -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; }, diff --git a/test/html/reflection.html b/test/html/reflection.html index 53685f1147..5de68d4e29 100644 --- a/test/html/reflection.html +++ b/test/html/reflection.html @@ -28,7 +28,9 @@ zot: 3, bar: 2 }, - Foo: '1' + Foo: '1', + skonkChanged: function() { + } }); @@ -37,7 +39,10 @@ @@ -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(); });