Correcting the callback for the script protocol.
In f08119b01e, the default syntax for the script protocol's callback made it so the callbacks looked like `OpenLayers.Protocol.Script.registry[c1]`. This essentially breaks the script protocol everywhere except where `c1` is defined and equals "c1" (the string).
Tests with this change demonstrate that default callbacks will now look like `OpenLayers.Protocol.Script.registry['c1']` (properly accessing the `c1` property of the registry object).
This commit is contained in:
@@ -57,9 +57,9 @@ OpenLayers.Protocol.Script = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
* APIProperty: callbackTemplate
|
||||
* {String} Template for creating a unique callback function name
|
||||
* for the registry. Should include ${id}.
|
||||
* Default is "OpenLayers.Protocol.Script.registry[${id}]".
|
||||
* Default is "OpenLayers.Protocol.Script.registry['${id}']".
|
||||
*/
|
||||
callbackTemplate: "OpenLayers.Protocol.Script.registry[${id}]",
|
||||
callbackTemplate: "OpenLayers.Protocol.Script.registry['${id}']",
|
||||
|
||||
/**
|
||||
* APIProperty: callbackKey
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
}
|
||||
|
||||
function test_createRequest(t) {
|
||||
t.plan(4);
|
||||
t.plan(5);
|
||||
var protocol = new OpenLayers.Protocol.Script({
|
||||
callbackKey: 'cb_key',
|
||||
callbackPrefix: 'cb_prefix:'
|
||||
@@ -150,8 +150,11 @@
|
||||
|
||||
t.eq(script.type, 'text/javascript',
|
||||
'created script has a correct type');
|
||||
t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.registry%5Bbar%5D',
|
||||
'created script has a correct url');
|
||||
|
||||
var params = OpenLayers.Util.getParameters(script.src);
|
||||
t.eq(params.k, "bar_param", "custom query string param");
|
||||
t.eq(params.cb_key, "cb_prefix:OpenLayers.Protocol.Script.registry['bar']", "callback with prefix");
|
||||
|
||||
t.eq(script.id, 'OpenLayers_Protocol_Script_bar',
|
||||
'created script has a correct id');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user