diff --git a/src/module.js b/src/module.js index 5234a1a..3120207 100644 --- a/src/module.js +++ b/src/module.js @@ -114,6 +114,11 @@ _.extend(Module.prototype, Backbone.Events, { if (!definition) { return; } // build the correct list of arguments for the module definition + + // make flattening consistent + // in lodash (v3) it's flatten(collection, deep) + // and in underscore it's flatten(collection, shallow) + var deepFlag = !_.flattenDeep; var args = _.flatten([ this, this.app, @@ -121,7 +126,7 @@ _.extend(Module.prototype, Backbone.Events, { Marionette, Backbone.$, _, customArgs - ]); + ], deepFlag); definition.apply(this, args); }, diff --git a/test/module.spec.js b/test/module.spec.js index 3afbb68..05c4c78 100644 --- a/test/module.spec.js +++ b/test/module.spec.js @@ -47,8 +47,13 @@ describe('application modules', function() { describe('and the define function is provided', function() { beforeEach(function() { - this.additionalParam = {}; - this.module = this.app.module('Mod', this.defineSpy, this.additionalParam); + this.additionalParam1 = [[1], 2]; + this.additionalParam2 = {}; + this.module = this.app.module('Mod', + this.defineSpy, + this.additionalParam1, + this.additionalParam2 + ); }); it('it should add module to the app', function() { @@ -71,7 +76,8 @@ describe('application modules', function() { Marionette, Backbone.$, _, - this.additionalParam + this.additionalParam1, + this.additionalParam2 ); }); });