I was trying to use newObj "Image" to get an HTML Image object, but the object that was created wasn't a proper Image. It was an object but it was mostly empty.
I think the problem is in primMkObj - it's doing
return new primGetCtor(nm);
I think what's happening is the new here is treating primGetCtor itself as the constructor function, and the actual constructor that primGetCtor returns is just being ignored.
I can fix it by adding parentheses:
return new (primGetCtor(nm))
I think what you are trying to do is:
foreign import js "new Image()"
newImage :: IO a
This is equivalent to: "new Image()".
I have modified the def of primMkObj, added the parenthesis.
@davidfletcher: can you confirm that it works now as you intended?
Yes, looks like it works now - thanks.