Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimals numbers in styles are formatted incorrectly #8825

Closed
ghost opened this issue Mar 3, 2017 · 14 comments
Closed

Decimals numbers in styles are formatted incorrectly #8825

ghost opened this issue Mar 3, 2017 · 14 comments

Comments

@ghost
Copy link

ghost commented Mar 3, 2017

  • Electron version: 1.6.1
  • Operating system: macOS Sierra 10.12.3

Expected behavior

Numbers returned by element.style or window.getComputedStyle are not formatted according to language preferences. I should always see "7.6px".

Actual behavior

Numbers returned by element.style or window.getComputedStyle are formatted according to language preferences. I see "7,6px" instead of "7.6px".

How to reproduce

  1. Have different localization, Czech in my case. The localization has to use comma as decimal number separator.
  2. run electron
  3. open Develop Tools (Alt+Cmd+I)
  4. run in console: document.body.style.lineHeight = '7.6px'
  5. you can see that there is Warning icon in element.style in Styles pane
  6. run in console: document.body.style.lineHeight
  7. see what's the output: "7,6px"

I can't see this behavior in Chrome 56.0.2924.87 on the same machine

@tex0l
Copy link

tex0l commented Mar 3, 2017

I think I have the same issue with electron 1.4.15 on OSX Sierra 10.12.3 with transition durations, still investigating though: my computed style properties have "," and not "." when decimal values are used, and transitions are not applied then.

@tonyganch
Copy link
Contributor

I personally could not reproduce that on macOS 10.12.3 and Czech locale.
However, I've found exactly the same issue in Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=623347
It's closed as not reproducible.

@kevinsawicki
Copy link
Contributor

@jiri-prokop @tex0l are either of you able to reproduce this directly in Chrome 56?

@ghost
Copy link
Author

ghost commented Mar 8, 2017

@kevinsawicki No, for me it doesn't happen in Chrome 56.0.2924.87.

@tex0l
Copy link

tex0l commented Mar 8, 2017

After investigating a bit more on my side:

  • it seems that when my application runs directly with electron binary it fails on my non-retina macbook pro under macOS 10.12.3 with French locale (but not on another retina macbook pro with the same config), but once packaged with electron-builder it works fine on both sides.
  • I tried making a very simple test case without any dependency, and it seems to work fine on both Google Chrome and electron 1.6.1 -_- on my computer.

I have no idea why it doesn't work in my application on my computer, it's not reproductible as hell.

FTR, the only differences between my test case and my application are:

  • I use vue.js in my application,
  • my css is transpiled and minified respectively with gulp-sass and postCSS+cssNano (but when I read the output, it's fine).

@tex0l
Copy link

tex0l commented Mar 28, 2017

Ok I investigated a bit more and I have found what makes it reproductible on macOS 10.12.3 and electron 1.6.2:
When started in command line, if you set the environment variable LANG=fr_FR.UTF-8 in your .profile, or .zshrc, or if you export it manually the separator used by chromium for rendering is , instead of ., and it makes all animations with decimal animation-duration fail...

@tex0l
Copy link

tex0l commented Mar 28, 2017

OK, I tried to reproduce this bug on Google Chrome Version 57.0.2987.98 (64-bit) on macOS 10.12.3 (starting it in command line with LANG=fr_FR.UTF-8 set), and it happens to make Google Chrome totally unusable on most websites. Here is an screenshot on MDN:
capture d ecran 2017-03-28 a 11 37 44

I didn't investigate further.

@TwR-Slice
Copy link

I can reproduce the error with Electron 1.6.2 and Mac OS X 10.11.6 German System

Electron: window.getComputedStyle(elem).width => "102,70px"
Chrome (57.0.2987.133): window.getComputedStyle(elem).width => "102.70px"

I suspect my region setting is producing this issue as i have a German system. And in Germany the decimal sign is a comma.

@kevinsawicki
Copy link
Contributor

Was able to reproduce this in Chrome 58 stable and 60 canary, reported upstream as https://bugs.chromium.org/p/chromium/issues/detail?id=717216

@codebytere
Copy link
Member

Is this issue still occurring on later versions of electron?

@feronetick
Copy link

feronetick commented Apr 10, 2018

Reproduced on mac 10.13.2, electron 1.8.2, node 9.8.0, russian locale

const div = document.createElement('div');
div.style.width = 1.2 + 'px';
div.setAttribute('data-width', 1.2 + 'px');
document.body.appendChild(div);

data attribute has correct value but width style has comma instead dot

@arxanter
Copy link

Reproduced on mac 10.13.2, electron 1.8.2, node 9.9.1, russian locale
use Electron-vue

SimulatedGREG/electron-vue#584

@marvin-enthus
Copy link

Hi.
Just stumbled over this issue on mac 10.14.1 and electron v3.0.9, german locale.
It seems related to a chromium bug tracked in https://bugs.chromium.org/p/chromium/issues/detail?id=720222 - it might be fixed on 68.0.3409.0, electron 3.0.9 is on 66.0.3359.181.
Just tested my testcase against electron v4.0-beta.7 - it works here as expected, reporting 69.0.3497.106....

@codebytere
Copy link
Member

Closed as fixed in the 4-0-x line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants