Skip to content

Commit 6c4d836

Browse files
committed
fix(document): handle #9396 case by only applying #13973 logic if in transaction
1 parent c795ce4 commit 6c4d836

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/document.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,13 +1475,15 @@ Document.prototype.$set = function $set(path, val, type, options) {
14751475

14761476
this.$__set(pathToMark, path, options, constructing, parts, schema, val, priorVal);
14771477

1478+
const isInTransaction = !!this.$__.session?.transaction;
1479+
const isModifiedWithinTransaction = this.$__.session &&
1480+
this.$__.session[sessionNewDocuments] &&
1481+
this.$__.session[sessionNewDocuments].has(this) &&
1482+
this.$__.session[sessionNewDocuments].get(this).modifiedPaths &&
1483+
!this.$__.session[sessionNewDocuments].get(this).modifiedPaths.has(savedStatePath);
14781484
if (savedState != null &&
14791485
savedState.hasOwnProperty(savedStatePath) &&
1480-
this.$__.session &&
1481-
this.$__.session[sessionNewDocuments] &&
1482-
this.$__.session[sessionNewDocuments].has(this) &&
1483-
this.$__.session[sessionNewDocuments].get(this).modifiedPaths &&
1484-
!this.$__.session[sessionNewDocuments].get(this).modifiedPaths.has(savedStatePath) &&
1486+
(!isInTransaction || isModifiedWithinTransaction) &&
14851487
utils.deepEqual(val, savedState[savedStatePath])) {
14861488
this.unmarkModified(path);
14871489
}

0 commit comments

Comments
 (0)