Skip to content

Commit 0ac236a

Browse files
committed
workaround to prevent variables redeclaration
1 parent 449be23 commit 0ac236a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

javascript/src/androidMain/kotlin/dev/icerock/moko/javascript/JavaScriptEngine.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ actual class JavaScriptEngine actual constructor() {
6666

6767
val scriptWithContext: String = buildString {
6868
scriptContext.forEach { (name, jsType) ->
69+
70+
try {
71+
quickJs.evaluate("$name;")
72+
return@forEach
73+
} catch (e: Throwable) { }
74+
6975
append("const ")
7076
append(name)
7177
append(" = ")

0 commit comments

Comments
 (0)