I use my latest solution, i.e. only include the bundle once when loading the background page. I did some debugging. Here is the “as” cast that fails:
window.document.createElement("p") as HTMLParagraphElement
It fails in:
Kotlin.isType = function(object, klass)
at this instanceof:
var klassMetadata = klass.$metadata$;
if (klassMetadata == null) {
return object instanceof klass;
}
This shouldn’t fail…
I guess the reason why it fails is that there are actually two window objects.
- The background window (where I load my js bundle)
- The popup window (where I create the new HTML element and do the “as” cast)