Skip to content

Commit

Permalink
fix: ensure Symbol.for exists before calling it (#366)
Browse files Browse the repository at this point in the history
For IE11 compatibility

Closes #365
  • Loading branch information
faberyx authored and aleclarson committed May 14, 2019
1 parent 4443cac commit c8ecbad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ export const NOTHING =
: {["immer-nothing"]: true}

export const DRAFTABLE =
typeof Symbol !== "undefined"
typeof Symbol !== "undefined" && Symbol.for
? Symbol.for("immer-draftable")
: "__$immer_draftable"

export const DRAFT_STATE =
typeof Symbol !== "undefined" ? Symbol.for("immer-state") : "__$immer_state"
typeof Symbol !== "undefined" && Symbol.for
? Symbol.for("immer-state")
: "__$immer_state"

export function isDraft(value) {
return !!value && !!value[DRAFT_STATE]
Expand Down

0 comments on commit c8ecbad

Please sign in to comment.