@@ -988,7 +988,7 @@ Document.prototype.$session = function $session(session) {
988
988
this . $__ . session = session ;
989
989
990
990
991
- if ( ! this . isSubDocument ) {
991
+ if ( ! this . $__ . isSubDocument ) {
992
992
const subdocs = this . $getAllSubdocs ( ) ;
993
993
for ( const child of subdocs ) {
994
994
child . $session ( session ) ;
@@ -1458,9 +1458,9 @@ Document.prototype.$set = function $set(path, val, type, options) {
1458
1458
}
1459
1459
1460
1460
if ( shouldSet ) {
1461
- const doc = this . isSubDocument ? this . ownerDocument ( ) : this ;
1461
+ const doc = this . $__ . isSubDocument ? this . ownerDocument ( ) : this ;
1462
1462
const savedState = doc . $__ . savedState ;
1463
- const savedStatePath = this . isSubDocument ? this . $__ . fullPath + '.' + path : path ;
1463
+ const savedStatePath = this . $__ . isSubDocument ? this . $__ . fullPath + '.' + path : path ;
1464
1464
if ( savedState != null ) {
1465
1465
const firstDot = savedStatePath . indexOf ( '.' ) ;
1466
1466
const topLevelPath = firstDot === - 1 ? savedStatePath : savedStatePath . slice ( 0 , firstDot ) ;
@@ -1834,7 +1834,7 @@ Document.prototype.$__path = function(path) {
1834
1834
1835
1835
Document . prototype . markModified = function ( path , scope ) {
1836
1836
this . $__ . activePaths . modify ( path ) ;
1837
- if ( scope != null && ! this . isSubDocument ) {
1837
+ if ( scope != null && ! this . $__ . isSubDocument ) {
1838
1838
this . $__ . pathsToScopes = this . $__pathsToScopes || { } ;
1839
1839
this . $__ . pathsToScopes [ path ] = scope ;
1840
1840
}
@@ -2362,7 +2362,7 @@ Document.prototype.validate = function(pathsToValidate, options, callback) {
2362
2362
let parallelValidate ;
2363
2363
this . $op = 'validate' ;
2364
2364
2365
- if ( this . isSubDocument != null ) {
2365
+ if ( this . $__ . isSubDocument != null ) {
2366
2366
// Skip parallel validate check for subdocuments
2367
2367
} else if ( this . $__ . validating ) {
2368
2368
parallelValidate = new ParallelValidateError ( this , {
@@ -3941,7 +3941,9 @@ Document.prototype.toJSON = function(options) {
3941
3941
} ;
3942
3942
3943
3943
3944
- Document . prototype . ownerDocument = function ( ) { } ;
3944
+ Document . prototype . ownerDocument = function ( ) {
3945
+ return this ;
3946
+ } ;
3945
3947
3946
3948
3947
3949
/**
0 commit comments