Webassembly passing reference to HTML Elements

How do I pass a reference to a HTML element to a method?

The following raises an exception:

  var a: dynamic := Browser.GetElementById('helloWorld');
  DoSomthingWithElement(a);

method DoSomthingWithElement(el: dynamic);
begin
  writeLn('Child Count: ' + el.children.length);
end;

http://127.0.0.1:14428/wasm/RemObjectsElements.js:298 Fatal exception in WebAssembly!
http://127.0.0.1:14428/wasm/RemObjectsElements.js:298 Exception: RemObjects.Elements.System.DynamicInvokeException: No overload with these parameters
!> Exception of type RuntimeError on thread 0001
!> Message: RuntimeError: unreachable
!> at ElementsRaiseException (wasm-function[2378]:0xa21d0)
!> at ms_t11__1sDynamicHelpers6_Invokenoni32na_o (wasm-function[2677]:0xae5ef)
!> at ms_t11__1sDynamicHelpers6_Invokenonsni32na_o (wasm-function[2676]:0xae2ae)
!> at mi_t25_Dynamic__Parameter__Passing_d_Programa_HelloWorld (wasm-function[2689]:0xb1776)
!> at imp.env.__island_invoke (http://127.0.0.1:14428/wasm/RemObjectsElements.js:480:42)
!> at ms_te__1sWebAssemblyc_InvokeMethodnp_vna_o (wasm-function[1077]:0x6e57e)
!> at mi_td__1sMethodInfo6_Invokenona_o (wasm-function[1095]:0x6f378)
!> at mi_tnte__1sWebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt13__1sEcmaScriptObject (wasm-function[861]:0x666f1)
!> at mi_t16__1sWebAssemblyDelegate6_Invokent13__1sEcmaScriptObject (wasm-function[618]:0x5d439)
!> at __island_call_delegate (wasm-function[2379]:0xa21fb)

Hm, that should work. can you give me a complete testcase for this?

Just using default index.html from new WebAssembly project and the following:

type
[Export]
Program = public class
private

method DoSomthingWithElement(el: dynamic);
begin
  writeLn('Child Count: ' + el.children.length);
end;

public

method HelloWorld;
begin
  writeLn('HelloWorld');
  var el := Browser.GetElementById('helloWorld');
  if el = nil then begin
    writeLn('Element by ID test is null!');
    exit;
  end;
  var t2 := Browser.CreateTextNode('Hello from Elements WebAssembly!');
  el.appendChild(t2);

  var a: dynamic := Browser.GetElementById('helloWorld');
  DoSomthingWithElement(a);
end;

end;

Thanks, logged as bugs://84100

bugs://84100 got closed with status fixed.