Ensure options object is cloned when used, instead of attached directly. #425

Merged
merged 1 commit into from Mar 7, 2014

Conversation

Projects
None yet
2 participants
@STRML
Collaborator

STRML commented Feb 28, 2014

This prevents modifications on the passed-in options object from changing options on the view.

Without it, the attached test case will fail, leading to some pretty bizarre and hard-to-find bugs.

@tbranyen

This comment has been minimized.

Show comment Hide comment
@tbranyen

tbranyen Feb 28, 2014

Owner

Build is failing because of #426

Owner

tbranyen commented Feb 28, 2014

Build is failing because of #426

backbone.layoutmanager.js
@@ -732,7 +732,7 @@ var LayoutManager = Backbone.View.extend({
// Configure a View to work with the LayoutManager plugin.
setupView: function(views, options) {
// Don't break the options object (passed into Backbone.View#initialize).
- options = options || {};
+ options = _.clone(options) || {};

This comment has been minimized.

Show comment Hide comment
@tbranyen

tbranyen Feb 28, 2014

Owner

Maybe: _.extend({}, options); as an added benefit this would ensure options is always an object.

@tbranyen

tbranyen Feb 28, 2014

Owner

Maybe: _.extend({}, options); as an added benefit this would ensure options is always an object.

Ensure options object is cloned when used, instead of attached directly.
This prevents modifications on the passed-in options object from changing
options on the view.
@tbranyen

This comment has been minimized.

Show comment Hide comment
@tbranyen

tbranyen Mar 7, 2014

Owner

Looks good to me. Thanks!

Owner

tbranyen commented Mar 7, 2014

Looks good to me. Thanks!

tbranyen added a commit that referenced this pull request Mar 7, 2014

Merge pull request #425 from STRML/fixOptions
Ensure options object is cloned when used, instead of attached directly.

@tbranyen tbranyen merged commit a5f865d into tbranyen:master Mar 7, 2014

1 check passed

default The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment