Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Write hooks can change the return value of the writer by returning a …

…value themselves
  • Loading branch information...
commit 1437aa5dfebc97ef7cc2e1df7a7ff440fb11fcf2 1 parent 4c7c5e9
@nathansobo authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/monarch/foundation.js
View
8 lib/monarch/foundation.js
@@ -149,9 +149,11 @@ function buildPropertyAccessor(name, reader, writer, afterWriteHook, afterChange
} else {
var oldValue = this[fieldName];
var newValue = writer.apply(this, arguments) || this[fieldName];
- if (afterWriteHook) afterWriteHook.call(this, newValue, oldValue);
- if (afterChangeHook && newValue !== oldValue) afterChangeHook.call(this, newValue, oldValue);
- return newValue;
+
+ var writeHookReturnVal, changeHookReturnVal;
+ if (afterWriteHook) writeHookReturnVal = afterWriteHook.call(this, newValue, oldValue);
+ if (afterChangeHook && newValue !== oldValue) changeHookReturnVal = afterChangeHook.call(this, newValue, oldValue);
+ return changeHookReturnVal || writeHookReturnVal || newValue;
}
};
accessor._accessor_ = true;
Please sign in to comment.
Something went wrong with that request. Please try again.