From 127abf878291a08d501e619581ddaedd2a5e76f9 Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 20 Mar 2012 17:07:52 -0600 Subject: [PATCH] Correcting the callback for the script protocol. In f08119b01e81cd03296d687ce916c05ee13d4e34, 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). --- lib/OpenLayers/Protocol/Script.js | 4 ++-- tests/Protocol/Script.html | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Protocol/Script.js b/lib/OpenLayers/Protocol/Script.js index 5cba843e9b..4ef847494e 100644 --- a/lib/OpenLayers/Protocol/Script.js +++ b/lib/OpenLayers/Protocol/Script.js @@ -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 diff --git a/tests/Protocol/Script.html b/tests/Protocol/Script.html index ee8ac89018..3a0b9b610f 100644 --- a/tests/Protocol/Script.html +++ b/tests/Protocol/Script.html @@ -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');