dart-archive / polymer-dart

Polymer support for Dart
https://pub.dartlang.org/packages/polymer
BSD 3-Clause "New" or "Revised" License
181 stars 33 forks source link

Div Attribute with bigint value is rounded #567

Closed neurofoo closed 9 years ago

neurofoo commented 9 years ago

Hello,

PolymerDart appears to round a div attribute bigint value when the value is inserted with data binding, but not when added as div.setAttribute from within a .dart file.

For an example polymer app made in WebStorm,

In main_app.html

<div id="div1" bigint1="{{myBigInt1}}"></div>

In main_app.dart

...

@observable int myBigInt1 = 121824329561278175;
int myBigint2 = 121824329561278175;

attached() {
    super.attached();
    $['div1'].setAttribute('bigint2', myBigInt2.toString());
    $['div1'].setAttribute('bigint3', myBigInt1.toString()); //check to see if an @observable issue
}

...

The result, as seen in the Dartium inspector

<div id="div1" bigint1="121824329561278180" bigint2="121824329561278175" bigint3="121824329561278175"> </div>

When one builds to javascript, the number is always rounded and, therefore, incorrect. Additionally, when one builds to javascript, the following is also rounded:

<div>myBigInt1 = {{myBigInt1}}</div>

produces:

myBigInt1 = 121824329561278180

I've made a full example of the issue here: https://github.com/neurofoo/dart_bigint_error

Many thanks.

jakemac53 commented 9 years ago

This is unfortunately working as expected. Everything is actually getting converted to a JS number before it is rendered on the page, and thus have all the limitations of numbers in JS http://www.w3schools.com/js/js_numbers.asp.

This is good in the sense that you get consistent behavior across dartium and dart2js though.

neurofoo commented 9 years ago

Thanks!