Skip to content

v1.1.1

Latest

Choose a tag to compare

@evanstern evanstern released this 13 Mar 15:59
· 17 commits to master since this release

Minor Patch

  • Fixed an issue when adding the same options object to two different instances during initialization, if a defaults option was defined for the instance prototype that returned an object, then the two resulting instances would both end up sharing the same resulting default object.

Here is an example of the bug:

// Define a Layout that applies defaults containing an object.
var MyLayout = BackboneLayout.extend({
  defaults: function() {
    return {shared: new SomeObject()}
  }
})

// Now, define shared options
var options = {
  'foo': 'bar'
}

// Finally, instantiate two instances of 'MyLayout', both sharing the same options object.
var layout1 = new MyLayout(options);
var layout2 = new MyLayout(options);

// They will both share the same 'shared' object
layout1.options.shared === layout2.options.shared;
>> true

This will no longer happen. The two instances will now have separate instances of the shared object.