mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
chore: Use .includes and .startsWith, not .indexOf (#7936)
Easier to read than the diverse collection of `=== 0` and `!== -1` and `> -1` tests.
This commit is contained in:
@@ -216,7 +216,7 @@ export class FieldNumber extends FieldInput<number> {
|
||||
private setPrecisionInternal(precision: number | string | undefined | null) {
|
||||
this.precision_ = Number(precision) || 0;
|
||||
let precisionString = String(this.precision_);
|
||||
if (precisionString.indexOf('e') !== -1) {
|
||||
if (precisionString.includes('e')) {
|
||||
// String() is fast. But it turns .0000001 into '1e-7'.
|
||||
// Use the much slower toLocaleString to access all the digits.
|
||||
precisionString = this.precision_.toLocaleString('en-US', {
|
||||
|
||||
Reference in New Issue
Block a user