JS hotfix for the Internet Explorer up to version 11
This commit is contained in:
parent
856dc4c5c1
commit
08637bc272
1 changed files with 14 additions and 1 deletions
|
|
@ -332,7 +332,7 @@ proc cmpStrings(a, b: string): int {.asmNoStackFrame, compilerProc.} =
|
||||||
return `a`.length - `b`.length;
|
return `a`.length - `b`.length;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc cmp(x, y: string): int =
|
proc cmp(x, y: string): int =
|
||||||
return cmpStrings(x, y)
|
return cmpStrings(x, y)
|
||||||
|
|
||||||
proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} =
|
proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} =
|
||||||
|
|
@ -750,3 +750,16 @@ when defined(nodejs):
|
||||||
else:
|
else:
|
||||||
# Deprecated. Use `alert` defined in dom.nim
|
# Deprecated. Use `alert` defined in dom.nim
|
||||||
proc alert*(s: cstring) {.importc, nodecl, deprecated.}
|
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);
|
||||||
|
};
|
||||||
|
}""".}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue