I attach drupalSettings
in a preprocess hook using code similar to the following one.
$settings = [
'bcd' => 'BCD',
'abc' => 'ABC'
];
$variables['#attached']['drupalSettings']['options'] = $settings;
When I print the content of drupalSettings
using console.log(drupalSettings.options);
I get a sorted object.
{ 'abc' : 'ABC','abc' : 'BCD'}
Is this the normal behavior? How can I prevent it?