@@ -780,7 +780,7 @@ function init(self, obj, doc, opts, prefix) {
780780 }
781781 } else {
782782 // Retain order when overwriting defaults
783- if ( doc . hasOwnProperty ( i ) && value !== void 0 && ! opts . hydratedPopulatedDocs ) {
783+ if ( Object . hasOwn ( doc , i ) && value !== void 0 && ! opts . hydratedPopulatedDocs ) {
784784 delete doc [ i ] ;
785785 }
786786 if ( value === null ) {
@@ -1156,7 +1156,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
11561156 const orderedKeys = Object . keys ( this . $__schema . tree ) ;
11571157 for ( let i = 0 , len = orderedKeys . length ; i < len ; ++ i ) {
11581158 ( key = orderedKeys [ i ] ) &&
1159- ( this . _doc . hasOwnProperty ( key ) ) &&
1159+ ( Object . hasOwn ( this . _doc , key ) ) &&
11601160 ( orderedDoc [ key ] = undefined ) ;
11611161 }
11621162 this . _doc = Object . assign ( orderedDoc , this . _doc ) ;
@@ -1206,8 +1206,8 @@ Document.prototype.$set = function $set(path, val, type, options) {
12061206 return this ;
12071207 }
12081208 const wasModified = this . $isModified ( path ) ;
1209- const hasInitialVal = this . $__ . savedState != null && this . $__ . savedState . hasOwnProperty ( path ) ;
1210- if ( this . $__ . savedState != null && ! this . $isNew && ! this . $__ . savedState . hasOwnProperty ( path ) ) {
1209+ const hasInitialVal = this . $__ . savedState != null && Object . hasOwn ( this . $__ . savedState , path ) ;
1210+ if ( this . $__ . savedState != null && ! this . $isNew && ! Object . hasOwn ( this . $__ . savedState , path ) ) {
12111211 const initialVal = this . $__getValue ( path ) ;
12121212 this . $__ . savedState [ path ] = initialVal ;
12131213
@@ -1512,7 +1512,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
15121512 this . $__ . session [ sessionNewDocuments ] . get ( this ) . modifiedPaths &&
15131513 ! this . $__ . session [ sessionNewDocuments ] . get ( this ) . modifiedPaths . has ( savedStatePath ) ;
15141514 if ( savedState != null &&
1515- savedState . hasOwnProperty ( savedStatePath ) &&
1515+ Object . hasOwn ( savedState , savedStatePath ) &&
15161516 ( ! isInTransaction || isModifiedWithinTransaction ) &&
15171517 utils . deepEqual ( val , savedState [ savedStatePath ] ) ) {
15181518 this . unmarkModified ( path ) ;
@@ -1994,7 +1994,7 @@ Document.prototype.$get = Document.prototype.get;
19941994
19951995Document . prototype . $__path = function ( path ) {
19961996 const adhocs = this . $__ . adhocPaths ;
1997- const adhocType = adhocs && adhocs . hasOwnProperty ( path ) ? adhocs [ path ] : null ;
1997+ const adhocType = adhocs && Object . hasOwn ( adhocs , path ) ? adhocs [ path ] : null ;
19981998
19991999 if ( adhocType ) {
20002000 return adhocType ;
@@ -2038,7 +2038,7 @@ Document.prototype.$__saveInitialState = function $__saveInitialState(path) {
20382038 if ( savedState != null ) {
20392039 const firstDot = savedStatePath . indexOf ( '.' ) ;
20402040 const topLevelPath = firstDot === - 1 ? savedStatePath : savedStatePath . slice ( 0 , firstDot ) ;
2041- if ( ! savedState . hasOwnProperty ( topLevelPath ) ) {
2041+ if ( ! Object . hasOwn ( savedState , topLevelPath ) ) {
20422042 savedState [ topLevelPath ] = clone ( this . $__getValue ( topLevelPath ) ) ;
20432043 }
20442044 }
@@ -2349,15 +2349,15 @@ Document.prototype.$isDefault = function(path) {
23492349 }
23502350
23512351 if ( typeof path === 'string' && path . indexOf ( ' ' ) === - 1 ) {
2352- return this . $__ . activePaths . getStatePaths ( 'default' ) . hasOwnProperty ( path ) ;
2352+ return Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'default' ) , path ) ;
23532353 }
23542354
23552355 let paths = path ;
23562356 if ( ! Array . isArray ( paths ) ) {
23572357 paths = paths . split ( ' ' ) ;
23582358 }
23592359
2360- return paths . some ( path => this . $__ . activePaths . getStatePaths ( 'default' ) . hasOwnProperty ( path ) ) ;
2360+ return paths . some ( path => Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'default' ) , path ) ) ;
23612361} ;
23622362
23632363/**
@@ -2411,7 +2411,7 @@ Document.prototype.isDirectModified = function(path) {
24112411 }
24122412
24132413 if ( typeof path === 'string' && path . indexOf ( ' ' ) === - 1 ) {
2414- const res = this . $__ . activePaths . getStatePaths ( 'modify' ) . hasOwnProperty ( path ) ;
2414+ const res = Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'modify' ) , path ) ;
24152415 if ( res || path . indexOf ( '.' ) === - 1 ) {
24162416 return res ;
24172417 }
@@ -2450,15 +2450,15 @@ Document.prototype.isInit = function(path) {
24502450 }
24512451
24522452 if ( typeof path === 'string' && path . indexOf ( ' ' ) === - 1 ) {
2453- return this . $__ . activePaths . getStatePaths ( 'init' ) . hasOwnProperty ( path ) ;
2453+ return Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'init' ) , path ) ;
24542454 }
24552455
24562456 let paths = path ;
24572457 if ( ! Array . isArray ( paths ) ) {
24582458 paths = paths . split ( ' ' ) ;
24592459 }
24602460
2461- return paths . some ( path => this . $__ . activePaths . getStatePaths ( 'init' ) . hasOwnProperty ( path ) ) ;
2461+ return paths . some ( path => Object . hasOwn ( this . $__ . activePaths . getStatePaths ( 'init' ) , path ) ) ;
24622462} ;
24632463
24642464/**
@@ -2596,7 +2596,7 @@ Document.prototype.isDirectSelected = function isDirectSelected(path) {
25962596 return true ;
25972597 }
25982598
2599- if ( this . $__ . selected . hasOwnProperty ( path ) ) {
2599+ if ( Object . hasOwn ( this . $__ . selected , path ) ) {
26002600 return inclusive ;
26012601 }
26022602
@@ -2772,7 +2772,7 @@ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip, isNestedValidate
27722772 if ( doc . $isModified ( fullPathToSubdoc , null , modifiedPaths ) &&
27732773 // Avoid using isDirectModified() here because that does additional checks on whether the parent path
27742774 // is direct modified, which can cause performance issues re: gh-14897
2775- ! subdocParent . $__ . activePaths . getStatePaths ( 'modify' ) . hasOwnProperty ( fullPathToSubdoc ) &&
2775+ ! Object . hasOwn ( subdocParent . $__ . activePaths . getStatePaths ( 'modify' ) , fullPathToSubdoc ) &&
27762776 ! subdocParent . $isDefault ( fullPathToSubdoc ) ) {
27772777 paths . add ( fullPathToSubdoc ) ;
27782778
@@ -2843,7 +2843,12 @@ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip, isNestedValidate
28432843 // Single nested paths (paths embedded under single nested subdocs) will
28442844 // be validated on their own when we call `validate()` on the subdoc itself.
28452845 // Re: gh-8468
2846- Object . keys ( flat ) . filter ( path => ! doc . $__schema . singleNestedPaths . hasOwnProperty ( path ) ) . forEach ( addToPaths ) ;
2846+ const singleNestedPaths = doc . $__schema . singleNestedPaths ;
2847+ for ( const path of Object . keys ( flat ) ) {
2848+ if ( ! Object . hasOwn ( singleNestedPaths , path ) ) {
2849+ addToPaths ( path ) ;
2850+ }
2851+ }
28472852 }
28482853 }
28492854
@@ -4184,7 +4189,7 @@ function applyVirtuals(self, json, options, toObjectOptions) {
41844189 }
41854190
41864191 // Allow skipping aliases with `toObject({ virtuals: true, aliases: false })`
4187- if ( ! aliases && schema . aliases . hasOwnProperty ( path ) ) {
4192+ if ( ! aliases && Object . hasOwn ( schema . aliases , path ) ) {
41884193 continue ;
41894194 }
41904195
@@ -5097,7 +5102,7 @@ function checkDivergentArray(doc, path, array) {
50975102 // would be similarly destructive as we never received all
50985103 // elements of the array and potentially would overwrite data.
50995104 const check = pop . options . match ||
5100- pop . options . options && utils . object . hasOwnProperty ( pop . options . options , 'limit' ) || // 0 is not permitted
5105+ pop . options . options && Object . hasOwn ( pop . options . options , 'limit' ) || // 0 is not permitted
51015106 pop . options . options && pop . options . options . skip || // 0 is permitted
51025107 pop . options . select && // deselected _id?
51035108 ( pop . options . select . _id === 0 ||
0 commit comments