不要怂,就是干,撸起袖子干!

Commit e37f3340 by Mick Hansen Committed by Mick Hansen

update should pass options to set

Currently the options are not passed along, which breaks ssaclAttributeRoles and might break other plugins.
Generally all options should just be propagated (unless they need to removed cause they will break the method).
1 parent e368ce68
Showing with 6 additions and 3 deletions
...@@ -770,12 +770,15 @@ Instance.prototype.hookValidate = function(options) { ...@@ -770,12 +770,15 @@ Instance.prototype.hookValidate = function(options) {
Instance.prototype.update = function(values, options) { Instance.prototype.update = function(values, options) {
var changedBefore = this.changed() || [] var changedBefore = this.changed() || []
, sideEffects , sideEffects
, fields; , fields
, setOptions;
options = options || {}; options = options || {};
if (Array.isArray(options)) options = {fields: options}; if (Array.isArray(options)) options = {fields: options};
this.set(values, {attributes: options.fields}); setOptions = this.$Model.$optClone(options);
setOptions.attributes = options.fields;
this.set(values, setOptions);
// Now we need to figure out which fields were actually affected by the setter. // Now we need to figure out which fields were actually affected by the setter.
sideEffects = _.without.apply(this, [this.changed() || []].concat(changedBefore)); sideEffects = _.without.apply(this, [this.changed() || []].concat(changedBefore));
......
...@@ -285,7 +285,7 @@ var conformOptions = function(options, self) { ...@@ -285,7 +285,7 @@ var conformOptions = function(options, self) {
}); });
}; };
var optClone = Model.prototype.__optClone = function(options) { var optClone = Model.prototype.__optClone = Model.prototype.$optClone = function(options) {
options = options || {}; options = options || {};
return Utils.cloneDeep(options, function(elem) { return Utils.cloneDeep(options, function(elem) {
// The InstanceFactories used for include are pass by ref, so don't clone them. // The InstanceFactories used for include are pass by ref, so don't clone them.
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!