This project is archived and is in readonly mode.

Class Mutators should run before all else
Reported by Arieh | August 11th, 2010 @ 01:19 PM | in 2.0 (closed)
This is something i ran into when trying to dynamically create parameters for the Class constructor - the Object passed to the Class constructor is iterated by it's order. This means that if Extends isn't the first in it's Hash, it will overwrite whatever comes before him. A simple test case -
After some debugging I've found the problem in the Class.implement (core:1214). It simply iterates the Object. IMO - it should first look for mutators, and only then iterate over the rest.
a possible solution could be doing an extra iteration if key is an object (the first check in Class.implement); something like:
if ($type(key) == 'object'){
for (var p in key) if (p in Class.Mutators){
Class.Mutators[p].call(this, key[p]);
delete key[p];
}
for (var p in key) this.implement(p, key[p]);
return this;
}
Comments and changes to this ticket
-
Michael Ficarra August 11th, 2010 @ 04:58 PM
duplicate of ticket 940
https://mootools.lighthouseapp.com/projects/2706/tickets/940-loop-o...
which was a wontfix
-
Michael Ficarra August 13th, 2010 @ 04:04 PM
And even though this issue has been discussed and decided upon before, I still believe it's a horrible design decision. In fact, I know it is. Object enumeration is not order-dependent. It's one of the few features of Javascript that are nondeterministic (see the full list). Because of this, relying on order of enumeration is just ignorant and wrong. The v8 engine (the JS engine in chrome) developers specifically deny requests for changes to support a deterministic enumeration order.
-
Christoph Pojer September 10th, 2010 @ 12:40 AM
- Milestone set to 2.0
- State changed from new to open
- Assigned user set to Valerio
- Milestone order changed from 789 to 0
teh mighty leader is going to respond to you.
-
ibolmo January 19th, 2012 @ 08:02 AM
- State changed from open to invalid
Moved to Github Issues: https://github.com/mootools/mootools-core/issues/2216
Please use Github Issues, since Lighthouse has been deprecated.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »