[OpenLayers-Dev] Constructor trouble when testing new control
Ian Mayo
ian at planetmayo.com
Thu Oct 11 15:06:37 EDT 2007
I'm afraid I can't get my head around an error that's being thrown by
my test at:
http://trac.openlayers.org/browser/sandbox/ianmayo/openlayers/tests/Control/test_ScaleLine.html
when I execute the following line in test_01_Control_ScaleLine_constructor:
control = new OpenLayers.Control.ScaleLine();
I get this error reported:
test_01_Control_ScaleLine_constructor planned 2 assertions but got 0;
fail 0 ok 0
exception: : object: [Exception... "Illegal operation on WrappedNative
prototype object" nsresult: "0x8057000c
(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame ::
file:///home/ian/dev/openlayers/openlayers/lib/OpenLayers/Util.js ::
anonymous :: line 60" data: no]
The guilty line is calling my constructor in
http://trac.openlayers.org/browser/sandbox/ianmayo/openlayers/lib/OpenLayers/Control/ScaleLine.js:
initialize: function(element, options) {
OpenLayers.Control.prototype.initialize.apply(this, arguments);
this.element = OpenLayers.Util.getElement(element);
},
I have to admit, I don't fully understand how the
constructor/initialiser model is working.
The other tests in the module all work - and demonstrate parameters
being used in the constructor.
I'd really appreciate a pointer in either the correct way to handle
parameters in the constructor, or the correct way to use the
parameters in the constructor.
cheers,
Ian.
More information about the Dev
mailing list