[Dart] MouseEvent ClientX and ClientY Deprecated


Recently I am porting JavaScript code to Dart. When I write the following code:

int dx = e.clientX - initialMouseX;

It works on Dartium. Then I compiled the code to JavaScript by dart2js. The compiled JavaScript code failed to run on Chromium. After some Googling, I found Dart MouseEvent clientX and clientY deprecated ([1], [2], [4]). And I also found someone got the same problem as me ([3]). The correct way to get clientX and clientY in Dart should be:

int dx = e.client.x - initialMouseX;

Then the compiled JavaScript code runs on Chromium without trouble.

PS: Tested on Dart 1.8


References:

[1]MouseEvent ClientX and ClientY deprecated
[2]Breaking Change: dart:html Point & Rect
[3]JS MouseEvent unexpectedly converted to Dart MouseEvent in interop
[4]dart/tools/dom/templates/html/dart2js/impl_MouseEvent.darttemplate - external/dart - Git at Google