summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorhlaaftana <10591326+hlaaftana@users.noreply.github.com>2021-11-24 10:20:15 +0300
committerGitHub <noreply@github.com>2021-11-24 08:20:15 +0100
commitff39f6e26062651a56d6ac4c24fe5a799c177c50 (patch)
treeb3337627cfac7d2a39543f1a33de18ad4c51552f /lib/system
parent2859069dbe1c943494cb6be299b200afa748cf52 (diff)
downloadNim-ff39f6e26062651a56d6ac4c24fe5a799c177c50.tar.gz
make JS trunc polyfill opt-in, closes #16144 (#19183)
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/jssys.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index cd4f378be..250bd069d 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -763,7 +763,8 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, start: int): int
 
 # Workaround for IE, IE up to version 11 lacks 'Math.trunc'. We produce
 # 'Math.trunc' for Nim's ``div`` and ``mod`` operators:
-const jsMathTrunc = """
+when defined(nimJsMathTruncPolyfill):
+  {.emit: """
 if (!Math.trunc) {
   Math.trunc = function(v) {
     v = +v;
@@ -771,5 +772,4 @@ if (!Math.trunc) {
     return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
   };
 }
-"""
-when not defined(nodejs): {.emit: jsMathTrunc .}
+""".}