From 99d77616afc3784b7342816d287c11a1811016b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Thu, 17 Aug 2023 15:42:07 +0300 Subject: [PATCH] Fixed #4285 - Locale performance updates with large datasets --- components/lib/calendar/Calendar.vue | 2 +- components/lib/carousel/Carousel.vue | 2 +- components/lib/dataview/DataView.vue | 2 +- components/lib/galleria/GalleriaThumbnails.vue | 2 +- components/lib/treetable/TreeTable.vue | 5 +++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/components/lib/calendar/Calendar.vue b/components/lib/calendar/Calendar.vue index 4d2fabc997..65b014abdb 100755 --- a/components/lib/calendar/Calendar.vue +++ b/components/lib/calendar/Calendar.vue @@ -2589,7 +2589,7 @@ export default { let innerHTML = ''; if (this.responsiveOptions) { - let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * o1.breakpoint.localeCompare(o2.breakpoint, undefined, { numeric: true })); + let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * new Intl.Collator(undefined, { numeric: true }).compare(o1.breakpoint, o2.breakpoint)); for (let i = 0; i < responsiveOptions.length; i++) { let { breakpoint, numMonths } = responsiveOptions[i]; diff --git a/components/lib/carousel/Carousel.vue b/components/lib/carousel/Carousel.vue index b326d5d6ba..7393856cd6 100755 --- a/components/lib/carousel/Carousel.vue +++ b/components/lib/carousel/Carousel.vue @@ -537,7 +537,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true }); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return -1 * result; diff --git a/components/lib/dataview/DataView.vue b/components/lib/dataview/DataView.vue index 5061cf48a8..b6988883b9 100755 --- a/components/lib/dataview/DataView.vue +++ b/components/lib/dataview/DataView.vue @@ -119,7 +119,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true }); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return this.sortOrder * result; diff --git a/components/lib/galleria/GalleriaThumbnails.vue b/components/lib/galleria/GalleriaThumbnails.vue index 9b30c537f1..e580095017 100755 --- a/components/lib/galleria/GalleriaThumbnails.vue +++ b/components/lib/galleria/GalleriaThumbnails.vue @@ -446,7 +446,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true }); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return -1 * result; diff --git a/components/lib/treetable/TreeTable.vue b/components/lib/treetable/TreeTable.vue index 81d1995787..e6c79001cb 100755 --- a/components/lib/treetable/TreeTable.vue +++ b/components/lib/treetable/TreeTable.vue @@ -426,7 +426,7 @@ export default { if (value1 == null && value2 != null) result = -1; else if (value1 != null && value2 == null) result = 1; else if (value1 == null && value2 == null) result = 0; - else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true }); + else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; return this.d_sortOrder * result; @@ -458,7 +458,8 @@ export default { if (value1 === value2) { return this.d_multiSortMeta.length - 1 > index ? this.multisortField(node1, node2, index + 1) : 0; } else { - if ((typeof value1 === 'string' || value1 instanceof String) && (typeof value2 === 'string' || value2 instanceof String)) return this.d_multiSortMeta[index].order * value1.localeCompare(value2, undefined, { numeric: true }); + if ((typeof value1 === 'string' || value1 instanceof String) && (typeof value2 === 'string' || value2 instanceof String)) + return this.d_multiSortMeta[index].order * new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else result = value1 < value2 ? -1 : 1; } }