The issue is with $merge. This will create an infinite loop in MooTools:
$merge({ fx: new Fx() });
On Fri, Nov 19, 2010 at 11:11 AM, Vito Tafuni <[email protected]> wrote:
> may be i'm wrong
>
> if B hasn't its initialize method, it's like you do
> var instance = new A({child : A});
>
> If your code is recursive the problem is not with mootools but ONLY with
> your code.
> quoting a wise: "...It gives you enough rope to hang yourself."
>
> but if you cannot revise the structure of your code you can simply avoid
> the recurring with something like this
> if (options && typeOf(options.child) == 'class' && options.child!=A)
>
>
> -Vito-
>
>
>
>
> --
> -----------
> Tafuni Vito
> [email protected]
> ---------------------------------------------
> "Verba volant, scripta manent... data corrupted"
>
>
> 2010/11/19 Aaron Newton <[email protected]>
>
> You have two options for a solution here:
>>
>> 1) remove that child before you call setOptions:
>>
>> if (options.child) {
>> this.child = options.child;
>> delete options.child;
>> }
>>
>> 2) make the child option a function that returns one:
>>
>> if (this.options.child) this.child = this.options.child();
>>
>> //usage
>> new A({ child: Function.from(B) });
>>
>>
>>
>>
>> On Fri, Nov 19, 2010 at 9:44 AM, אריה גלזר <[email protected]>wrote:
>>
>>> if i understand correctly, the real issue is if child requires other
>>> parameters.
>>> and anyway, a class creating other classes (other than perhaps mootools
>>> utilities) is a bad habit.
>>> imo, if the class is supplied via options, the supplier should already
>>> instantiate the class
>>>
>>>
>>> On Fri, Nov 19, 2010 at 7:21 PM, Alex K <[email protected]> wrote:
>>>
>>>> I apologize for bringing up a topic that might have been discussed
>>>> in the past, but I wonder if anyone has a definite and clear solution
>>>> to this problem:
>>>>
>>>>
>>>> var A = new Class({
>>>> Implements : Options,
>>>>
>>>> initialize : function(options) {
>>>> this.setOptions(options);
>>>> if (options && typeOf(options.child) == 'class')
>>>> this.child = new options.child(options);
>>>> }
>>>> });
>>>>
>>>> var B = new Class({
>>>> Implements : A,
>>>> });
>>>>
>>>> // "Maximum call stack size exceeded"
>>>> var instance = new A({child : B});
>>>>
>>>>
>>>> Also, due to some design considerations, implementing "initialize" in
>>>> every subclass is not an option.
>>>>
>>>> Thanks in advance.
>>>> -a
>>>>
>>>
>>>
>>>
>>> --
>>> Arieh Glazer
>>> אריה גלזר
>>> 052-5348-561
>>> 5561
>>>
>>>
>>
>