Skip to content
Myr

fix: Object.isFrozen dies on non objects in Internet Explorer. Fixes #600

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 a9a3af0 · Browse files · 2 files+10 added−3 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+10 added−3 removed

  • other:+10 added−3 removed

2 files+10 added−3 removed

modified:src/core/finalize.ts+3 added-2 removed
modified:src/utils/common.ts+7 added-1 removed
174 unmodified lines
175 return clone176}177178export function freeze(obj: any, deep: boolean): void {179 if (isDraft(obj) || Object.isFrozen(obj) || !isDraftable(obj)) return179 if (isDraft(obj) || isFrozen(obj) || !isDraftable(obj)) return180 if (getArchtype(obj) > 1 /* Map or Set */) {181 obj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections as any182 }183 Object.freeze(obj)
2 unmodified lines
186187function dontMutateFrozenCollections() {188 die(2)189}190191export function isFrozen(obj: any): boolean {192 if (obj == null || typeof obj !== "object") return true193 // See #600, IE dies on non-objects in Object.isFrozen194 return Object.isFrozen(obj)195}