diff options
author | Araq <rumpf_a@web.de> | 2018-05-25 23:19:54 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-05-25 23:19:54 +0200 |
commit | 08637bc2724c3b21e966c0d00f7ced84c74f1ce3 (patch) | |
tree | 52cb10d1e4e2edc79405e7fb90cdf2a2a1dd9f9d /lib/system/jssys.nim | |
parent | 856dc4c5c13fb52741de8a2fb124e0d05a553ddb (diff) | |
download | Nim-08637bc2724c3b21e966c0d00f7ced84c74f1ce3.tar.gz |
JS hotfix for the Internet Explorer up to version 11
Diffstat (limited to 'lib/system/jssys.nim')
-rw-r--r-- | lib/system/jssys.nim | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 56a9f6575..e12bab184 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -332,7 +332,7 @@ proc cmpStrings(a, b: string): int {.asmNoStackFrame, compilerProc.} = return `a`.length - `b`.length; """ -proc cmp(x, y: string): int = +proc cmp(x, y: string): int = return cmpStrings(x, y) proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} = @@ -750,3 +750,16 @@ when defined(nodejs): else: # Deprecated. Use `alert` defined in dom.nim proc alert*(s: cstring) {.importc, nodecl, deprecated.} + +# Workaround for IE, IE up to version 11 lacks 'Math.trunc'. We produce +# 'Math.trunc' for Nim's ``div`` and ``mod`` operators: +when not defined(nodejs): + {.emit: """ + if (!Math.trunc) { + Math.trunc = function(v) { + v = +v; + if (!isFinite(v)) return v; + + return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0); + }; + }""".} |