@@ -784,7 +784,7 @@ function init(self, obj, doc, opts, prefix) {
784784 }
785785 } else {
786786 // Retain order when overwriting defaults
787- if ( doc . hasOwnProperty ( i ) && value !== void 0 && ! opts . hydratedPopulatedDocs ) {
787+ if ( Object . hasOwn ( doc , i ) && value !== void 0 && ! opts . hydratedPopulatedDocs ) {
788788 delete doc [ i ] ;
789789 }
790790 if ( value === null ) {
@@ -1167,7 +1167,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
11671167 const orderedKeys = Object . keys ( this . $__schema . tree ) ;
11681168 for ( let i = 0 , len = orderedKeys . length ; i < len ; ++ i ) {
11691169 ( key = orderedKeys [ i ] ) &&
1170- ( this . _doc . hasOwnProperty ( key ) ) &&
1170+ ( Object . hasOwn ( this . _doc , key ) ) &&
11711171 ( orderedDoc [ key ] = undefined ) ;
11721172 }
11731173 this . _doc = Object . assign ( orderedDoc , this . _doc ) ;
@@ -1217,8 +1217,8 @@ Document.prototype.$set = function $set(path, val, type, options) {
12171217 return this ;
12181218 }
12191219 const wasModified = this . $isModified ( path ) ;
1220- const hasInitialVal = this . $__ . savedState != null && this . $__ . savedState . hasOwnProperty ( path ) ;
1221- if ( this . $__ . savedState != null && ! this . $isNew && ! this . $__ . savedState . hasOwnProperty ( path ) ) {
1220+ const hasInitialVal = this . $__ . savedState != null && Object . hasOwn ( this . $__ . savedState , path ) ;
1221+ if ( this . $__ . savedState != null && ! this . $isNew && ! Object . hasOwn ( this . $__ . savedState , path ) ) {
12221222 const initialVal = this . $__getValue ( path ) ;
12231223 this . $__ . savedState [ path ] = initialVal ;
12241224
@@ -1523,7 +1523,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
15231523 this . $__ . session [ sessionNewDocuments ] . get ( this ) . modifiedPaths &&
15241524 ! this . $__ . session [ sessionNewDocuments ] . get ( this ) . modifiedPaths . has ( savedStatePath ) ;
15251525 if ( savedState != null &&
1526- savedState . hasOwnProperty ( savedStatePath ) &&
1526+ Object . hasOwn ( savedState , savedStatePath ) &&
15271527 ( ! isInTransaction || isModifiedWithinTransaction ) &&
15281528 utils . deepEqual ( val , savedState [ savedStatePath ] ) ) {
15291529 this . unmarkModified ( path ) ;
@@ -2005,7 +2005,7 @@ Document.prototype.$get = Document.prototype.get;
20052005
20062006Document . prototype . $__path = function ( path ) {
20072007 const adhocs = this . $__ . adhocPaths ;
2008- const adhocType = adhocs && adhocs . hasOwnProperty ( path ) ? adhocs [ path ] : null ;
2008+ const adhocType = adhocs && Object . hasOwn ( adhocs , path ) ? adhocs [ path ] : null ;
20092009
20102010 if ( adhocType ) {
20112011 return adhocType ;
@@ -2049,7 +2049,7 @@ Document.prototype.$__saveInitialState = function $__saveInitialState(path) {
20492049 if ( savedState != null ) {
20502050 const firstDot = savedStatePath . indexOf ( '.' ) ;
20512051 const topLevelPath = firstDot === - 1 ? savedStatePath : savedStatePath . slice ( 0 , firstDot ) ;
2052- if ( ! savedState . hasOwnProperty ( topLevelPath ) ) {
2052+ if ( ! Object . hasOwn ( savedState , topLevelPath ) ) {
20532053 savedState [ topLevelPath ] = clone ( this . $__getValue ( topLevelPath ) ) ;
20542054 }
20552055 }
@@ -2360,15 +2360,15 @@ Document.prototype.$isDefault = function(path) {
23602360 }
23612361
23622362 if ( typeof path === 'string' && path . indexOf ( ' ' ) === - 1 ) {
2363- return this . $__ . activePaths . getStatePaths ( 'default' ) . hasOwnProperty ( path ) ;
2363+ return Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'default' ) , path ) ;
23642364 }
23652365
23662366 let paths = path ;
23672367 if ( ! Array . isArray ( paths ) ) {
23682368 paths = paths . split ( ' ' ) ;
23692369 }
23702370
2371- return paths . some ( path => this . $__ . activePaths . getStatePaths ( 'default' ) . hasOwnProperty ( path ) ) ;
2371+ return paths . some ( path => Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'default' ) , path ) ) ;
23722372} ;
23732373
23742374/**
@@ -2422,7 +2422,7 @@ Document.prototype.isDirectModified = function(path) {
24222422 }
24232423
24242424 if ( typeof path === 'string' && path . indexOf ( ' ' ) === - 1 ) {
2425- const res = this . $__ . activePaths . getStatePaths ( 'modify' ) . hasOwnProperty ( path ) ;
2425+ const res = Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'modify' ) , path ) ;
24262426 if ( res || path . indexOf ( '.' ) === - 1 ) {
24272427 return res ;
24282428 }
@@ -2461,15 +2461,15 @@ Document.prototype.isInit = function(path) {
24612461 }
24622462
24632463 if ( typeof path === 'string' && path . indexOf ( ' ' ) === - 1 ) {
2464- return this . $__ . activePaths . getStatePaths ( 'init' ) . hasOwnProperty ( path ) ;
2464+ return Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'init' ) , path ) ;
24652465 }
24662466
24672467 let paths = path ;
24682468 if ( ! Array . isArray ( paths ) ) {
24692469 paths = paths . split ( ' ' ) ;
24702470 }
24712471
2472- return paths . some ( path => this . $__ . activePaths . getStatePaths ( 'init' ) . hasOwnProperty ( path ) ) ;
2472+ return paths . some ( path => Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'init' ) , path ) ) ;
24732473} ;
24742474
24752475/**
@@ -2607,7 +2607,7 @@ Document.prototype.isDirectSelected = function isDirectSelected(path) {
26072607 return true ;
26082608 }
26092609
2610- if ( this . $__ . selected . hasOwnProperty ( path ) ) {
2610+ if ( Object . hasOwn ( this . $__ . selected , path ) ) {
26112611 return inclusive ;
26122612 }
26132613
@@ -2779,7 +2779,7 @@ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip, isNestedValidate
27792779 if ( doc . $isModified ( fullPathToSubdoc , null , modifiedPaths ) &&
27802780 // Avoid using isDirectModified() here because that does additional checks on whether the parent path
27812781 // is direct modified, which can cause performance issues re: gh-14897
2782- ! subdocParent . $__ . activePaths . getStatePaths ( 'modify' ) . hasOwnProperty ( fullPathToSubdoc ) &&
2782+ ! Object . hasOwn ( subdocParent . $__ . activePaths . getStatePaths ( 'modify' ) , fullPathToSubdoc ) &&
27832783 ! subdocParent . $isDefault ( fullPathToSubdoc ) ) {
27842784 paths . add ( fullPathToSubdoc ) ;
27852785
@@ -2850,7 +2850,12 @@ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip, isNestedValidate
28502850 // Single nested paths (paths embedded under single nested subdocs) will
28512851 // be validated on their own when we call `validate()` on the subdoc itself.
28522852 // Re: gh-8468
2853- Object . keys ( flat ) . filter ( path => ! doc . $__schema . singleNestedPaths . hasOwnProperty ( path ) ) . forEach ( addToPaths ) ;
2853+ const singleNestedPaths = doc . $__schema . singleNestedPaths ;
2854+ for ( const path of Object . keys ( flat ) ) {
2855+ if ( ! Object . hasOwn ( singleNestedPaths , path ) ) {
2856+ addToPaths ( path ) ;
2857+ }
2858+ }
28542859 }
28552860 }
28562861
@@ -4188,7 +4193,7 @@ function applyVirtuals(self, json, options, toObjectOptions) {
41884193 }
41894194
41904195 // Allow skipping aliases with `toObject({ virtuals: true, aliases: false })`
4191- if ( ! aliases && schema . aliases . hasOwnProperty ( path ) ) {
4196+ if ( ! aliases && Object . hasOwn ( schema . aliases , path ) ) {
41924197 continue ;
41934198 }
41944199
@@ -5101,7 +5106,7 @@ function checkDivergentArray(doc, path, array) {
51015106 // would be similarly destructive as we never received all
51025107 // elements of the array and potentially would overwrite data.
51035108 const check = pop . options . match ||
5104- pop . options . options && utils . object . hasOwnProperty ( pop . options . options , 'limit' ) || // 0 is not permitted
5109+ pop . options . options && Object . hasOwn ( pop . options . options , 'limit' ) || // 0 is not permitted
51055110 pop . options . options && pop . options . options . skip || // 0 is permitted
51065111 pop . options . select && // deselected _id?
51075112 ( pop . options . select . _id === 0 ||
0 commit comments