Permalink
Browse files

Fixes #250 - Binds mutator overwrites previous binds

https://mootools.lighthouseapp.com/projects/24057/tickets/250

* Added fix for allowing Binds that persist through the prototype chain when Classes are extended (Daniel Buchner)
* Added specs for this (Aaron Newton)
  • Loading branch information...
csuwildcat authored and anutron committed Feb 1, 2011
1 parent 57b4afd commit 559f824203eee729b6e8ce3fd13da49fd9cce4b4
Showing with 23 additions and 1 deletion.
  1. +1 −1 Source/Class/Class.Binds.js
  2. +22 −0 Specs/1.3/Class/Class.Binds.js
@@ -23,7 +23,7 @@ provides: [Class.Binds]
Class.Mutators.Binds = function(binds){
if (!this.prototype.initialize) this.implement('initialize', function(){});
- return binds;
+ return Array.from(binds).concat(this.prototype.Binds || []);
};
Class.Mutators.initialize = function(initialize){
@@ -67,4 +67,26 @@ describe('Class.Binds', function(){
});
+ it('should retain binders from ancestors', function(){
+
+ var Parent = new Class({
+ Binds: ['foo'],
+ fooValue: 'foo',
+ foo: function(){
+ return this.fooValue;
+ }
+ });
+
+ var Child = new Class({
+ Extends: Parent,
+ Binds: ['bar'],
+ barValue: 'bar',
+ bar: function(){
+ return this.barValue;
+ }
+ });
+ expect(new Child().foo.apply(false)).toEqual('foo');
+ expect(new Child().bar.apply(false)).toEqual('bar');
+ });
+
});

0 comments on commit 559f824

Please sign in to comment.