Skip to content

Commit cf62d77

Browse files
committed
Revert "bugfix: run preprocessor of types.snapshotProcessor before running applySnapshot (#1823)"
This reverts commit 13d9fee.
1 parent d53d86a commit cf62d77

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

packages/mobx-state-tree/__tests__/core/snapshotProcessor.test.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
detach,
77
clone,
88
SnapshotIn,
9-
getNodeId,
10-
applySnapshot
9+
getNodeId
1110
} from "../../src"
1211

1312
describe("snapshotProcessor", () => {
@@ -559,21 +558,6 @@ describe("snapshotProcessor", () => {
559558
})
560559
})
561560

562-
test("applySnapshot runs preprocessors before applying", () => {
563-
const M = types.snapshotProcessor(types.model({ x: types.number }), {
564-
preProcessor(snapshot: { x: string }) {
565-
return { x: Number(snapshot.x) }
566-
},
567-
postProcessor(snapshot) {
568-
return { x: String(snapshot.x) }
569-
}
570-
})
571-
572-
const m = M.create({ x: "1" })
573-
574-
expect(() => applySnapshot(m, { x: "2" })).not.toThrow()
575-
})
576-
577561
test("cached initial snapshots are ok", () => {
578562
const M2 = types.snapshotProcessor(types.model({ x: types.number }), {
579563
preProcessor(sn: { x: number }) {

packages/mobx-state-tree/src/types/utility-types/snapshotProcessor.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ class SnapshotProcessor<IT extends IAnyType, CustomC, CustomS> extends BaseType<
9595
return this
9696
}
9797
}
98-
99-
const oldApplySnapshot = node.applySnapshot
100-
node.applySnapshot = (snapshot) => {
101-
return oldApplySnapshot.call(node, this.preProcessSnapshot(snapshot)) as any
102-
}
10398
}
10499

105100
instantiate(

0 commit comments

Comments
 (0)