I have this very simple MooTools script:
var MyElement = new Class({
Extends: Element
});
which gives the error: Uncaught TypeError: Cannot call method 'set' of null
I'm using MooTools 1.4.5, full without compatability.
If I change the class it extends to any other class, it works fine.
What's going on here? Is this a bug?
EDIT:
Same thing happens with Implements: Element!
As pointed out on this page:
element is not extendable as its not a real class.
This is because it is mostly an interface wrapper ('proxy') around your browser's native internal classes wrapping 'real' elements. There is a 'workaround' for this though with the toElement
function. If you implement it on an object or class, passing the class to the $ function will automatically invoke it, as such making your class behave completely like an Element, and allowing you to use aggregation instead of (faulty!) inheritance to wrap browser elements.