fix ie11
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Andrey Boldyrev · committed by Andrey Boldyrev · parent ff25a83 · Browse files · 6 files·+35 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+35 added−8 removed
- other:+35 added−8 removed
Provenance
- Commit
ffd8769- Tree
f2baf64- Author
Andrey Boldyrev <runnez@yandex.ru>- Committer
Andrey Boldyrev <runnez@yandex.ru>- Parent
ff25a83
6 files changed+35 added−8 removed
modified:src/common.js+4 added-2 removed
140 unmodified lines141 return x !== x && y !== y142 }143 }144 145-const hasMap = typeof Map !== "undefined"145+export const hasSymbol = typeof Symbol !== "undefined"146 147+export const hasMap = typeof Map !== "undefined"148+149 export function isMap(target) {150 return hasMap && target instanceof Map151 }152 151-const hasSet = typeof Set !== "undefined"153+export const hasSet = typeof Set !== "undefined"154 155 export function isSet(target) {156 return hasSet && target instanceof Set157 }81 unmodified linesmodified:src/es5.js+3 added-2 removed
6 unmodified lines7 isDraftable,8 isEnumerable,9 isMap,10 isSet,11+ hasSymbol,12 shallowCopy,13 DRAFT_STATE,14 iterateMapValues,15 makeIterable,144 unmodified lines160 161 function proxyMap(target) {162 Object.defineProperties(target, mapTraps)163 163- if (typeof Symbol !== undefined) {164+ if (hasSymbol) {165 Object.defineProperty(166 target,167 Symbol.iterator,168 proxyMethod(iterateMapValues)58 unmodified lines227 228 function proxySet(target) {229 Object.defineProperties(target, setTraps)230 230- if (typeof Symbol !== undefined) {231+ if (hasSymbol) {232 Object.defineProperty(233 target,234 Symbol.iterator,235 proxyMethod(iterateSetValues)233 unmodified linesmodified:src/immer.js+1 added-1 removed
76 unmodified lines77 // finally instead of catch + rethrow better preserves original stack78 if (hasError) scope.revoke()79 else scope.leave()80 }81- if (result instanceof Promise) {81+ if (typeof Promise !== "undefined" && result instanceof Promise) {82 return result.then(83 result => {84 scope.usePatches(patchListener)85 return this.processResult(result, scope)264 unmodified linesmodified:src/proxy.js+3 added-2 removed
6 unmodified lines7 isDraftable,8 isDraft,9 isMap,10 isSet,11+ hasSymbol,12 shallowCopy,13 makeIterable,14 DRAFT_STATE,15 assignMap,242 unmodified lines258 },259 keys: state => () => latest(state).keys(),260 values: iterateMapValues,261 entries: iterateMapValues,261- [Symbol.iterator]: iterateMapValues262+ [hasSymbol && Symbol.iterator]: iterateMapValues263 })264 265 const iterateSetValues = makeIterateSetValues(createProxy)266 /**29 unmodified lines296 },297 keys: iterateSetValues,298 values: iterateSetValues,299 entries: iterateSetValues,299- [Symbol.iterator]: iterateSetValues300+ [hasSymbol && Symbol.iterator]: iterateSetValues301 })302 303 /**304 * Helpers63 unmodified linesmodified:.gitignore+1 added-1 removed
57 unmodified lines58 .env59 60 .idea61 dist/62-website/build62+website/buildadded:index.html+23 added
1234567891011121314151617181920212223<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Test in Browser</title> <script src="https://cdn.jsdelivr.net/npm/object-assign-polyfill@0.1.0/index.min.js"></script> <script src="./dist/immer.umd.js"></script> </head> <body> <script> try { const result = immer.produce(new Map([[1, 2]]), function(draft) { draft.set(1, 3) })
console.log(result) } catch (err) { alert(err) } </script> </body></html>