Skip to content

Commit

Permalink
behaviors ONLY on the prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Mar 9, 2017
1 parent 4bf7bdd commit 444c043
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
if (superBehaviors) {
behaviors = superBehaviors.concat(behaviors);
}
klass.behaviors = behaviors;
klass.prototype.behaviors = behaviors;
return klass;
}
Expand Down
16 changes: 7 additions & 9 deletions test/unit/mixin-behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -383,8 +383,7 @@
});

test('instance and class behaviors', function() {
assert.equal(el.constructor.behaviors.length, 1);
assert.deepEqual(el.behaviors, el.constructor.behaviors);
assert.equal(el.behaviors.length, 1);
});

test('listener from behavior', function() {
Expand Down Expand Up @@ -418,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]);
});

Expand Down Expand Up @@ -453,8 +452,7 @@
});

test('instance and class behaviors', function() {
assert.equal(el.constructor.behaviors.length, 2);
assert.deepEqual(el.behaviors, el.constructor.behaviors);
assert.equal(el.behaviors.length, 2);
});

test('properties from behaviors', function() {
Expand Down Expand Up @@ -520,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]);
});

Expand All @@ -540,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() {
Expand Down

0 comments on commit 444c043

Please sign in to comment.