Skip to content

Commit 668d0a5

Browse files
committed
Fix(DecimalCode): add Arabic Letter Mark to rtl
1 parent d30a2a8 commit 668d0a5

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/models/validation/decimal-code.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,25 @@ export class DecimalCode extends NumberCode {
2727
const value: number = -0.9; // Reference value.
2828
const localeValue: string = new Intl.NumberFormat(defaultLocale).format(value);
2929

30-
// Checks Unicode character 'RIGHT-TO-LEFT MARK' (U+200F).
31-
if (this.Unicode(localeValue.charAt(0)) == "\\u200F") {
30+
const unicodeChars: string[] = [];
31+
unicodeChars.push(this.Unicode(localeValue.charAt(0)));
32+
unicodeChars.push(this.Unicode(localeValue.charAt(1)));
33+
unicodeChars.push(this.Unicode(localeValue.charAt(2)));
34+
unicodeChars.push(this.Unicode(localeValue.charAt(3)));
35+
36+
// Checks Unicode characters 'RIGHT-TO-LEFT MARK' (U+200F) & 'Arabic Letter Mark (U+061C)'.
37+
if (unicodeChars[0] == "\\u200F" || unicodeChars[0] == "\\u061C") {
3238
// Right to left.
33-
this.minusSignCode = this.Unicode(localeValue.charAt(1));
34-
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(3));
35-
} else if (this.Unicode(localeValue.charAt(0)) == this.Unicode(
36-
new Intl.NumberFormat(defaultLocale).format(0)
37-
)) {
38-
// IE & Edge reverse the order.
39-
this.minusSignCode = this.Unicode(localeValue.charAt(3));
40-
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(1));
39+
this.minusSignCode = unicodeChars[1];
40+
this.decimalSeparatorCode = unicodeChars[3];
41+
} else if (unicodeChars[0] == this.Unicode(new Intl.NumberFormat(defaultLocale).format(0))) {
42+
// Some IE & Edge versions reverse the order.
43+
this.minusSignCode = unicodeChars[3];
44+
this.decimalSeparatorCode = unicodeChars[1];
4145
} else {
4246
// Left to right.
43-
this.minusSignCode = this.Unicode(localeValue.charAt(0));
44-
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(2));
47+
this.minusSignCode = unicodeChars[0];
48+
this.decimalSeparatorCode = unicodeChars[2];
4549
}
4650
}
4751
}

0 commit comments

Comments
 (0)