Chrome mistakenly applies locale to values ​​inside CSSStyleSheet

Is it a bug in Chrome Version 65.0.3325.146on macOS High Sierra that CSSStyleSheet applies a locale to its values? The following html reproduces the error. It prints the wrong output for the Russian-language system, where "," is used as a decimal separator.

<script>
var el = document.createElement('style');
el.innerHTML = '.someclass {font-size: 3.5rem; line-height: 1.5rem;}';
document.head.appendChild(el);
console.log(el.sheet.cssRules[0].style.cssText);    
</script>

Conclusion:

font-size: 3,5rem; line-height: 1,5rem;

Expected Result:

font-size: 3.5rem; line-height: 1.5rem;

Screenshot of the problem (marked in the browser console):

Screenshot of the problem

+4
source share
1 answer

Really weird stuff here.

The problem disappeared after commenting out the following lines from ~/.profileand restarting Chrome:

export LC_NUMERIC=ru_RU.UTF-8
export LC_TIME=ru_RU.UTF-8
export LC_COLLATE="en_US.UTF-8" 
export LC_MONETARY=ru_RU.UTF-8
export LC_MESSAGES="en_US.UTF-8" 
export LC_PAPER=ru_RU.UTF-8
export LC_NAME=ru_RU.UTF-8
export LC_ADDRESS=ru_RU.UTF-8
export LC_TELEPHONE=ru_RU.UTF-8
export LC_MEASUREMENT=ru_RU.UTF-8
export LC_IDENTIFICATION=ru_RU.UTF-8
export LC_ALL=

But after I split the lines back - the problem no longer occurs. Tried Chrome and reboots the system.

Chrome , . , ( ):)

UPD. , , - Chrome Terminal ( ) (LC_NUMERIC,...).

0

Source: https://habr.com/ru/post/1694696/


All Articles