Protected members in mootools classes
Some times ago I wrote about the private static and instance members in mootools classes. Now it's time to speak about the protected members in mootools classes.
So the goal here is to obtain some members which are inherited from the parent class and accessible to a child class but not outside.
The trick is to use the Object.merge function to merge together the private properties of the parent exposed to the children through a protected method and the private properties of the child. Look at the following code:
-
var ids = 1;
-
-
var myParentClass = (function(){
-
-
var _protected_prop = {};
-
-
return new Class({
-
-
initialize: function(id, par1, par2) {
-
this.id = id;
-
...