Skip to content

Commit

Permalink
fix: made NOTHING and IMMERABLE shared symbols. Fixes #632
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Jul 24, 2020
1 parent 0fe9132 commit b1c6a8e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/env.ts
Expand Up @@ -20,7 +20,7 @@ export const isMinified = mini.name !== "mini"
* The sentinel value returned by producers to replace the draft with undefined.
*/
export const NOTHING: Nothing = hasSymbol
? Symbol("immer-nothing")
? Symbol.for("immer-nothing")

This comment has been minimized.

Copy link
@yiminghe

yiminghe Aug 24, 2020

safari 12 hasSymbol but Symbol.for is undefined

: ({["immer-nothing"]: true} as any)

/**
Expand All @@ -32,11 +32,11 @@ export const NOTHING: Nothing = hasSymbol
* safe to mutate in a produce callback.
*/
export const DRAFTABLE: unique symbol = hasSymbol
? Symbol("immer-draftable")
? Symbol.for("immer-draftable")
: ("__$immer_draftable" as any)

export const DRAFT_STATE: unique symbol = hasSymbol
? Symbol("immer-state")
? Symbol.for("immer-state")
: ("__$immer_state" as any)

// Even a polyfilled Symbol might provide Symbol.iterator
Expand Down

0 comments on commit b1c6a8e

Please sign in to comment.