diff --git a/bower.json b/bower.json index 1181b64c18..434ce7e1f2 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "polymer", - "version": "2.0.0-rc.2", + "version": "2.0.0-rc.3", "main": [ "polymer.html" ], diff --git a/lib/legacy/class.html b/lib/legacy/class.html index ea8dfd835e..108e3d1f4f 100644 --- a/lib/legacy/class.html +++ b/lib/legacy/class.html @@ -25,11 +25,7 @@ registered: true, attributeChanged: true, // meta objects - behaviors: true, - hostAttributes: true, - properties: true, - observers: true, - listeners: true + behaviors: true } /** @@ -135,8 +131,6 @@ function GenerateClassFromInfo(info, Base) { - let registered = false; - class PolymerGenerated extends Base { static get properties() { @@ -167,13 +161,9 @@ } _registered() { - if (!registered) { - super._registered(); - // call `registered` only if it was not called for *this* constructor - registered = true; - if (info.registered) { - info.registered.call(Object.getPrototypeOf(this)); - } + super._registered(); + if (info.registered) { + info.registered.call(Object.getPrototypeOf(this)); } } diff --git a/lib/legacy/legacy-element-mixin.html b/lib/legacy/legacy-element-mixin.html index 6de979f229..73f087ad04 100644 --- a/lib/legacy/legacy-element-mixin.html +++ b/lib/legacy/legacy-element-mixin.html @@ -106,12 +106,17 @@ /** * Overrides the default `Polymer.PropertyEffects` implementation to - * add support for one-time `registration` callback. + * add support for class initialization via the `_registered` callback. + * This is called only when the first instance of the element is created. * * @override */ _initializeProperties() { - this._registered(); + let proto = Object.getPrototypeOf(this); + if (!proto.hasOwnProperty('__hasRegisterFinished')) { + proto.__hasRegisterFinished = true; + this._registered(); + } super._initializeProperties(); } diff --git a/lib/utils/mixin.html b/lib/utils/mixin.html index 91dbdbfec7..85a04b0e3a 100644 --- a/lib/utils/mixin.html +++ b/lib/utils/mixin.html @@ -51,9 +51,7 @@ Polymer.dedupingMixin = function(mixin) { mixin = cachingMixin(mixin); // maintain a unique id for each mixin - if (!mixin.__id) { - mixin.__dedupeId = ++dedupeId; - } + mixin.__dedupeId = ++dedupeId; return function(base) { let baseSet = base.__mixinSet; if (baseSet && baseSet[mixin.__dedupeId]) { diff --git a/package.json b/package.json index 57eb6235f4..5abd923fb5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymer/polymer", - "version": "2.0.0-rc.2", + "version": "2.0.0-rc.3", "description": "The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to write", "main": "polymer.html", "directories": { diff --git a/test/unit/behaviors.html b/test/unit/behaviors.html index 27535891e3..997a6ded74 100644 --- a/test/unit/behaviors.html +++ b/test/unit/behaviors.html @@ -172,7 +172,12 @@ behaviors: [ Polymer.BehaviorA - ] + ], + + properties: {}, + observers: [], + hostAttributes: {}, + listeners: {} }); Polymer({ @@ -307,6 +312,14 @@ assert.equal(el.is, 'single-behavior'); }); + test('instance behaviors, properties, observers, hostAttributes, listeners', function() { + assert.isOk(el.behaviors); + assert.isOk(el.properties); + assert.isOk(el.observers); + assert.isOk(el.hostAttributes); + assert.isOk(el.listeners); + }); + test('ready from behavior', function() { assert.equal(el.__readyA, true); }); diff --git a/test/unit/mixin-behaviors.html b/test/unit/mixin-behaviors.html index e64ee2ae24..8bfd9dbfe1 100644 --- a/test/unit/mixin-behaviors.html +++ b/test/unit/mixin-behaviors.html @@ -329,12 +329,18 @@ BehaviorRegistered.prototype.registeredCount = 0; customElements.define(BehaviorRegistered.is, BehaviorRegistered); + + class BehaviorRegisteredExt extends BehaviorRegistered { + static get is() { return 'behavior-registered-ext'} + } + + BehaviorRegisteredExt.prototype.registeredCount = 0; + + customElements.define(BehaviorRegisteredExt.is, BehaviorRegisteredExt); }); - - + + + +