Document.prototype.$__shouldModify = function (
pathToMark, path, constructing, parts, schema, val, priorVal) {
if (this.isNew) return true;
if (this.isDirectModified(pathToMark)) return false;
if (undefined === val && !this.isSelected(path)) {
// when a path is not selected in a query, its initial
// value will be undefined.
return true;
}
if (undefined === val && path in this.$__.activePaths.states.default) {
// we're just unsetting the default value which was never saved <---------------------- This assumption is wrong
return false;
}
if (!deepEqual(val, priorVal || this.get(path))) {
return true;
}
if (!constructing &&
null != val &&
path in this.$__.activePaths.states.default &&
deepEqual(val, schema.getDefault(this, constructing))) {
// a path with a default was $unset on the server
// and the user is setting it to the same value again