Skip to content

Commit cd7db73

Browse files
committed
made requested changes
1 parent 447afbc commit cd7db73

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/document.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ Document.prototype.$session = function $session(session) {
988988
this.$__.session = session;
989989

990990

991-
if (!this.isSubDocument) {
991+
if (!this.$__.isSubDocument) {
992992
const subdocs = this.$getAllSubdocs();
993993
for (const child of subdocs) {
994994
child.$session(session);
@@ -1458,9 +1458,9 @@ Document.prototype.$set = function $set(path, val, type, options) {
14581458
}
14591459

14601460
if (shouldSet) {
1461-
const doc = this.isSubDocument ? this.ownerDocument() : this;
1461+
const doc = this.$__.isSubDocument ? this.ownerDocument() : this;
14621462
const savedState = doc.$__.savedState;
1463-
const savedStatePath = this.isSubDocument ? this.$__.fullPath + '.' + path : path;
1463+
const savedStatePath = this.$__.isSubDocument ? this.$__.fullPath + '.' + path : path;
14641464
if (savedState != null) {
14651465
const firstDot = savedStatePath.indexOf('.');
14661466
const topLevelPath = firstDot === -1 ? savedStatePath : savedStatePath.slice(0, firstDot);
@@ -1834,7 +1834,7 @@ Document.prototype.$__path = function(path) {
18341834

18351835
Document.prototype.markModified = function(path, scope) {
18361836
this.$__.activePaths.modify(path);
1837-
if (scope != null && !this.isSubDocument) {
1837+
if (scope != null && !this.$__.isSubDocument) {
18381838
this.$__.pathsToScopes = this.$__pathsToScopes || {};
18391839
this.$__.pathsToScopes[path] = scope;
18401840
}
@@ -2362,7 +2362,7 @@ Document.prototype.validate = function(pathsToValidate, options, callback) {
23622362
let parallelValidate;
23632363
this.$op = 'validate';
23642364

2365-
if (this.isSubDocument != null) {
2365+
if (this.$__.isSubDocument != null) {
23662366
// Skip parallel validate check for subdocuments
23672367
} else if (this.$__.validating) {
23682368
parallelValidate = new ParallelValidateError(this, {
@@ -3941,7 +3941,9 @@ Document.prototype.toJSON = function(options) {
39413941
};
39423942

39433943

3944-
Document.prototype.ownerDocument = function() {};
3944+
Document.prototype.ownerDocument = function() {
3945+
return this;
3946+
};
39453947

39463948

39473949
/**

lib/types/subdocument.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = Subdocument;
1717
*/
1818

1919
function Subdocument(value, fields, parent, skipId, options) {
20+
this.$__.isSubDocument = true;
2021
if (parent != null) {
2122
// If setting a nested path, should copy isNew from parent re: gh-7048
2223
const parentOptions = { isNew: parent.isNew, defaults: 'defaults' in parent.$__ ? parent.$__.defaults : true };
@@ -229,7 +230,6 @@ Subdocument.prototype.$ignore = function(path) {
229230
*/
230231

231232
Subdocument.prototype.ownerDocument = function() {
232-
this.isSubDocument = true;
233233
if (this.$__.ownerDocument) {
234234
return this.$__.ownerDocument;
235235
}

0 commit comments

Comments
 (0)