Skip to content

Commit

Permalink
add instance behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Mar 9, 2017
1 parent 4ae65ba commit 4bf7bdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
behaviors = superBehaviors.concat(behaviors);
}
klass.behaviors = behaviors;
klass.prototype.behaviors = behaviors;
return klass;
}

Expand Down
10 changes: 10 additions & 0 deletions test/unit/mixin-behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@
assert.equal(el.__label, 'foo');
});

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

test('listener from behavior', function() {
el.fire('change', {value: 'bar'});
assert.equal(el.__change, 'bar');
Expand Down Expand Up @@ -447,6 +452,11 @@
assert.equal(el.__readyB, true);
});

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

test('properties from behaviors', function() {
el.label = 'foo';
assert.equal(el.__label, 'foo');
Expand Down

0 comments on commit 4bf7bdd

Please sign in to comment.