diff --git a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js index 9571d489f..9b7a826b8 100644 --- a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js +++ b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js @@ -21,7 +21,7 @@ $rt_compare = function(a, b) { return a > b ? 1 : a < b ? -1 : 0; } $rt_isInstance = function(obj, cls) { - return obj != null && obj.constructor.$meta && $rt_isAssignable(obj.constructor, cls); + return obj !== null && !!obj.constructor.$meta && $rt_isAssignable(obj.constructor, cls); } $rt_isAssignable = function(from, to) { if (from === to) { diff --git a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java index 1ef4defb6..e68d243ed 100644 --- a/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java +++ b/teavm-html4j/src/main/java/org/teavm/html4j/JavaScriptConvGenerator.java @@ -116,8 +116,12 @@ public class JavaScriptConvGenerator implements Generator { writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Double") .append(") {").indent().softNewLine(); writer.append("return ").appendMethodBody(valueOfDoubleMethod).append("(" + obj + ");").softNewLine(); - writer.outdent().append("} else if (" + type + " === $rt_intcls()) {").indent().softNewLine(); + writer.outdent().append("} else if (" + type + " === $rt_intcls() || " + type + " === $rt_bytecls() || " + + type + " === $rt_shortcls()) {").indent().softNewLine(); writer.append("return " + obj + "|0;").softNewLine(); + writer.outdent().append("} else if (" + type + " === $rt_doublecls() || " + type + " == $rt_floatcls()) {") + .indent().softNewLine(); + writer.append("return " + obj + ";").softNewLine(); writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Boolean") .append(") {").indent().softNewLine(); writer.append("return ").appendMethodBody(valueOfBooleanMethod).append("(" + obj + "?1:0);").softNewLine();