FOR-1340 Fixed bug with JS aggregation (applied https://www.drupal.org/node/1898168#comment-9090791 patch).