Update MooTools Core from 1.2.5 to 1.3 breaks inheritance structures


Update 2010-12-20: I created a bug report which was set to “wontfix”. As Christopher Pojer explained here there is no guarantee that this.parent is defined in classes that are used as interfaces.

Some weeks ago, I wrote about two API breaks I found in MooTools Core 1.3 when I tried to upgrade from 1.2.5. After creating a bug report, the API breaks turn out to result from a code cleanup which removes the support for some undocumented features in MooTools 1.2.5.

Today I found another problem: Upgrading to MooTools Core 1.3 (from 1.2.5) breaks my inheritance structures. The following simplified example demonstrates the problem:

var MyBaseClass = new Class({
	sayHello: function() {
		alert("BaseClass: Hello!");
	}
});
var MyInterface = new Class({
	sayHello: function() {
		alert("Interface: Hello!");
		this.parent();
	}
});
var MyClass = new Class({
	Extends: MyBaseClass
	,Implements: MyInterface
});
var myClass = new MyClass();
myClass.sayHello();

With MooTools Core 1.2.5 the output was as expected: Two alert boxes show up “Interface: Hello!” and “BaseClass: Hello!”. With MooTools 1.3, I get the following error after the first alert box:

The method “sayHello” has no parent.
[Break on this error] if (!previous) throw new Error(‘The method “‘ + name + ‘” has no parent.’);


Leave a Reply

Your email address will not be published. Required fields are marked *