-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Object passed into component.set
is mutated by computed properties
#479
Comments
It looks like this is consciously being done in the const statement = `state.${key} = newState.${key} = ${generator.alias( 'template' )}.computed.${key}( ${deps.map( dep => `state.${dep}` ).join( ', ' )} );`; so that other computed properties that depend on this computed property will be recomputed. I wonder if there's another way we could handle this that wouldn't be too complicated. I suppose we could always |
Best place to do that is probably inside function set( newState ) {
- this._set( newState );
+ this._set( assign( {}, newState ) );
( this._root || this )._flush();
} Though that raises an awkward problem — |
REPL
This logs
{ a: 1, b: 2 }
.I have an app where I have an array of different objects that I pass to
component.set
as appropriate. The computed property is getting assigned into the object that's passed in. Callingcomponent.set
again with a previously used (and mutated) object is a problem when dev mode is enabled, because attempting to set the read-only computed property throws an error.The text was updated successfully, but these errors were encountered: