mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-18 23:11:36 +00:00
JS hotfix for the Internet Explorer up to version 11
This commit is contained in:
@@ -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);
|
||||
};
|
||||
}""".}
|
||||
|
||||
Reference in New Issue
Block a user