Our team is currently utilizing CrossRider to develop an extension specifically for Internet Explorer. We have a crucial object that is downloaded from , but we are facing an issue where arrays within this object are getting converted into objects with integer keys when sent to a callback function. This unexpected conversion raises the question of why arrays are being transformed into objects, and more importantly, if there's a way to prevent this during the process. While one solution would involve using JSON.stringify
and JSON.parse
within the calling function, we're curious if there's a direct method to send arrays without them being altered. Even a simple array like ['a','b','c']
ends up as an object ({"0":"a","1":"b","2":"c"}
) once it reaches the function.
This functionality is being developed for Internet Explorer 11, but ultimately should be compatible with all versions of the browser.
Edit (1): After conducting tests in both Internet Explorer 11 and Google Chrome, our findings showed discrepancies between the browsers. Specifically, a new extension with ID 67708 worked flawlessly in Chrome but faced issues in Explorer. A snippet of the code showcases these differences:
background.js:
/************************************************************************************
This section contains background-specific code.
Refer to our wiki site for detailed information:
http://docs.crossrider.com/#!/guide/scopes_background
*************************************************************************************/
function callme1() {
var r1 = ['a','b','c'];
alert('r1 = ' + JSON.stringify(r1));
return r1;
}
appAPI.ready(function($) {
// Your custom code goes here (ideal for managing browser buttons, global timers, etc.)
alert('callme1() = ' + JSON.stringify(callme1()));
});
extension.js:
/************************************************************************************
This section pertains to Page Code. The appAPI.ready() block will run on every page load.
Consult our docs at: http://docs.crossrider.com
*************************************************************************************/
function callme2() {
var r2 = ['a','b','c'];
alert('r2 = ' + JSON.stringify(r2));
return r2;
}
appAPI.ready(function($) {
// Place your code here (you can define additional functions above)
// The $ object refers to the extension's jQuery object
// For instance: alert("My new Crossrider extension works! Current page: " + document.location.href);
alert('callme2() = ' + JSON.stringify(callme2()));
});
While alerts in Chrome present valid arrays like ["a","b","c"]
, those in Explorer show objects like {"0":"a","1":"b","2":"c"}
, both before and after returning the object. Despite attempts to rectify this by employing JSON.stringify
followed by JSON.parse
, the issue persists within our extension (ID 43889). Interestingly, executing JSON.stringify(['a','b','c'])
in either browser yields the expected outcome - "["a","b","c"]"
.
An additional concern emerged regarding CrossRider inadvertently converting staging extensions to production status, necessitating manual reversion to staging mode multiple times with both extensions.
Edit (2): Seeking alternative solutions, we experimented with replacing JSON.stringify
with appAPI.JSON.stringify
. As a result, Explorer now displays the correct results within extension.js (["a","b","c"]
). However, an unforeseen setback arose where background.js failed to load altogether in debug mode, persisting with outdated content even upon selecting "reload background code." It remains unclear whether this anomaly stems from running two extensions simultaneously in debug mode or if it represents a peculiar bug unique to our scenario.