Skip to content
Myr

createDraft can now handle drafts

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 9f75bf5 · Browse files · 2 files+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−2 removed

  • tests:+1 added−1 removed
  • other:+3 added−1 removed

2 files+4 added−2 removed

modified:__tests__/manual.js+1 added-1 removed
modified:src/core/immerClass.ts+3 added-1 removed
22 unmodified lines
23 leaveScope,24 usePatchesInScope,25 getCurrentScope,26 NOTHING,27 freeze27 freeze,28 current29} from "../internal"3031interface ProducersFns {32 produce: IProduce
106 unmodified lines
139 }140141 createDraft<T extends Objectish>(base: T): Draft<T> {142 if (!isDraftable(base)) die(8)143 if (isDraft(base)) base = current(base)144 const scope = enterScope(this)145 const proxy = createProxy(this, base, undefined)146 proxy[DRAFT_STATE].isManual_ = true147 leaveScope(scope)
81 unmodified lines