diff --git a/lib/legacy/class.html b/lib/legacy/class.html
index 7411d4bb15..ea8dfd835e 100644
--- a/lib/legacy/class.html
+++ b/lib/legacy/class.html
@@ -54,7 +54,7 @@
if (!Array.isArray(behaviors)) {
behaviors = [behaviors];
}
- let superBehaviors = klass.behaviors;
+ let superBehaviors = klass.prototype.behaviors;
// get flattened, deduped list of behaviors *not* already on super class
behaviors = flattenBehaviors(behaviors, null, superBehaviors);
// mixin new behaviors
@@ -62,7 +62,8 @@
if (superBehaviors) {
behaviors = superBehaviors.concat(behaviors);
}
- klass.behaviors = behaviors;
+ // Set behaviors on prototype for BC...
+ klass.prototype.behaviors = behaviors;
return klass;
}
@@ -320,8 +321,6 @@
LegacyElementMixin(HTMLElement));
// decorate klass with registration info
klass.is = info.is;
- // behaviors on prototype for BC...
- klass.prototype.behaviors = klass.behaviors;
// NOTE: while we could call `beforeRegister` here to maintain
// some BC, the state of the element at this point is not as it was in 1.0
// In 1.0, the method was called *after* mixing prototypes together
diff --git a/test/unit/mixin-behaviors.html b/test/unit/mixin-behaviors.html
index 3a598b6318..e64ee2ae24 100644
--- a/test/unit/mixin-behaviors.html
+++ b/test/unit/mixin-behaviors.html
@@ -284,7 +284,7 @@
this._createMethodObserver('propChanged2(prop)');
this.registeredCount++;
this.registeredProps = [this.prop1, this.prop2, this.prop3];
- this.registeredBehaviors = this.constructor.behaviors;
+ this.registeredBehaviors = this.behaviors;
},
prop1: true,
ready: function() {
@@ -382,6 +382,10 @@
assert.equal(el.__label, 'foo');
});
+ test('instance behaviors', function() {
+ assert.equal(el.behaviors.length, 1);
+ });
+
test('listener from behavior', function() {
el.fire('change', {value: 'bar'});
assert.equal(el.__change, 'bar');
@@ -413,7 +417,7 @@
var el = fixture('registered');
assert.equal(el.registeredCount, 4);
assert.equal(el.registeredBehaviors.length, 3);
- assert.equal(el.registeredBehaviors, el.constructor.behaviors);
+ assert.equal(el.registeredBehaviors, el.behaviors);
assert.deepEqual(el.registeredProps, [true, true, true]);
});
@@ -447,6 +451,10 @@
assert.equal(el.__readyB, true);
});
+ test('instance behaviors', function() {
+ assert.equal(el.behaviors.length, 2);
+ });
+
test('properties from behaviors', function() {
el.label = 'foo';
assert.equal(el.__label, 'foo');
@@ -510,13 +518,13 @@
test('behavior array is unique', function() {
customElements.define('behavior-unique', Polymer.mixinBehaviors(
[Polymer.BehaviorA, Polymer.BehaviorA], Polymer.Element));
- assert.equal(document.createElement('behavior-unique').constructor.behaviors.length, 1);
+ assert.equal(document.createElement('behavior-unique').behaviors.length, 1);
});
test('duplicate behaviors keep first behavior', function() {
customElements.define('behavior-unique-last-behavior', Polymer.mixinBehaviors(
[Polymer.BehaviorA, Polymer.BehaviorB, Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB], Polymer.Element));
- var behaviors = document.createElement('behavior-unique-last-behavior').constructor.behaviors;
+ var behaviors = document.createElement('behavior-unique-last-behavior').behaviors;
assert.deepEqual(behaviors, [Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB]);
});
@@ -530,7 +538,7 @@
});
test('nested-behavior dedups', function() {
- assert.equal(el.constructor.behaviors.length, 4);
+ assert.equal(el.behaviors.length, 4);
});
test('nested-behavior overrides ordering', function() {