[OpenLayers-Dev] 2.10 and 2.11-RC1 OpenLayers.Class behavior changes

RICHARD Didier didier.richard at ign.fr
Sat Aug 6 15:32:29 EDT 2011


>
>>>>> 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;
    };


I had to use the eval() function to make it working, but don't know why ?

Regards,

didier

>> --
>> 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
>>
>
>
> --
> RICHARD Didier - Chef du pôle technique du Géoportail
> 2/4, avenue Pasteur - 94165 Saint Mandé Cedex
> Tél : +33 (0) 1 43 98 83 23
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>


-- 
RICHARD Didier - Chef du pôle technique du Géoportail
2/4, avenue Pasteur - 94165 Saint Mandé Cedex
Tél : +33 (0) 1 43 98 83 23


More information about the Dev mailing list