Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a property designated as a mergedProperties will mutate the prototype if set during create #11714

Closed
krisselden opened this issue Jul 11, 2015 · 1 comment · Fixed by #13031
Closed
Labels

Comments

@krisselden
Copy link
Contributor

value = merge(originalValue, value);

this should be value = merge({}, originalValue, value);

@Panman82
Copy link
Contributor

Panman82 commented Mar 1, 2016

I'm running into this, trying to used an options:{} property as an attribute, with it defined as a mergedProperties:['options']. That way the Component could be extended to define "default" options but then allow usage in templates to override some options with the (hash) helper. Ex: {{foo-bar options=(hash baz="overridden" zoo="new")}} Any progress on this or a workaround?

As a side note, this could probably use the new Ember.assign() polyfil for Object.assign(). I'm sure you're fully aware, but just for reference: http://emberjs.com/blog/2016/02/29/ember-2-4-released.html#toc_code-ember-assign-code

Edit: Looks like master is already using embers assign. If you think passing in an empty hash/object first is all it'll take, I could whip up a PR with that and a test.

rwjblue pushed a commit that referenced this issue Mar 3, 2016
When `mergedProperties` are passed into an object at `.create()` time,
the objects prototype is inadvertently modified, which is then
reflected on all instances of the object. Simply passing in a new
object during `assign()` resolves this problem (per krisselden). Also
added a test for this use case, where `objA` results in 3 when the
proto is modified. Fixes #11714

(cherry picked from commit fa87517)
rwjblue pushed a commit that referenced this issue Mar 3, 2016
When `mergedProperties` are passed into an object at `.create()` time,
the objects prototype is inadvertently modified, which is then
reflected on all instances of the object. Simply passing in a new
object during `assign()` resolves this problem (per krisselden). Also
added a test for this use case, where `objA` results in 3 when the
proto is modified. Fixes #11714

(cherry picked from commit fa87517)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants