[OpenLayers-Dev] 2.10 and 2.11-RC1 OpenLayers.Class behavior
changes
Eric Lemoine
eric.lemoine at camptocamp.com
Sat Aug 6 18:01:49 EDT 2011
On Sat, Aug 6, 2011 at 9:32 PM, RICHARD Didier <didier.richard at ign.fr> wrote:
>
>>
>>>>>> 2/ in test 4, if you remove the initialize function from B and
>>>>>> overload
>>>>>> A,
>>>>>> the B constructor is still the previous A's constructor.
>>>>>
>>>>> Yes. To address this one I see no other solution than patching
>>>>> OpenLayers.Class. See the patch attached to this email, and my
>>>>> test_overload_5 test function. The Class.html tests continue to pass
>>>>> with my patch.
>>>>>
>>>>
>>>> this works in OL 2.11, not in OL 2.10 for me !-(
>>>> I guess there is something similar to do in OL 2.10 ?
>>>
>>> Your initial mail was about OpenLayers trunk/2.11 introducing
>>> regressions. Now the failing test that remains is OL 2.10-only, so OL
>>> trunk/2.11 works better than OL 2.10 for you. Yippee! :-)
>>>
>>
>> My initial mail was really about regression between 2.10 and 2.11 !-)
>>
>>> (Not sure it is worth "fixing" OL 2.10 for that.)
>>>
>>
>> Well, one of my test is versus the current release (2.10) and I am sure
>> there are users that will migrate slower than us (I mean OL and IGNF) ...
>>
>> I do think it is worth fixing it ... at least to prove there is no
>> regression !-D
>>
>
> I've got somethinf working, hence ugly :-)
>
> OpenLayers.overload= function(P,F) {
> var pProtoInitialize= typeof(F.initialize)=="function"?
> P.prototype.initialize
> : null;
> OpenLayers.Util.extend(P.prototype, F);
> if (pProtoInitialize!==null) {
> // override sub-class having same constructor:
> for (var pn in P) {
> if (typeof(P[pn])=='function' &&
> P[pn].prototype.initialize===pProtoInitialize) {
> var f= {};
> eval('f= {"initialize":'+F.initialize.toString()+'}');
> P[pn]= OpenLayers.overload(P[pn],f);
> }
> }
> }
>
> return P;
> };
Hi Didier. Just to say that I personally wouldn't rely on an overload
function that assumes subclasses use their parent constructors as
their namespaces.
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Dev
mailing list