Invalid cast error in Wasm when reading HTML element property

Hi
In the latest stable release, there is a problem with access to HTML element properties. Here is a test case that worked in the previous stable :

    method TestCanvas;
    begin
      var hdiv := Browser.GetElementById('helloWorld');
      var canvas := Browser.CreateElement('canvas') as dynamic  ;
      canvas.id := "CursorLayer";
      var w := hdiv.clientWidth ; // ! RemObjects.Elements.System.InvalidCastException: Invalid cast, 512 int works
      canvas.width := w;
      canvas.height := 512;
      hdiv.appendChild(canvas);

      var ctx := canvas.getContext("2d", nil) as Dynamic;
      ctx.fillStyle :=  "rgba(255, 0, 0, 0.5)";
      ctx.fillRect( 100, 100, 200, 200 );
      ctx.fillStyle :=  "rgba(0, 255, 0, 0.5)";
      ctx.fillRect( 150, 150, 200, 200);
      ctx.fillStyle :=  "rgba(0, 0, 255, 0.5)";
      ctx.fillRect( 200, 50, 200, 200);
    end;

Module3.zip (5.0 KB)
What has changed and how to fix this error?
Artur

Logged as bugs://E25363.

What has changed and how to fix this error?

definitely sounds like a bug/regression. Not sure about a workaround until we had a closer look at what the problem is, sorry :frowning:

As a work around,

var w := (hdiv as Dynamic).clientWidth

should work.

1 Like

bugs://E25363 was closed as fixed.

1 Like