From 90fdf4db795a6fc8bb6339174a5fb4586d873054 Mon Sep 17 00:00:00 2001 From: mrholek Date: Tue, 14 Jul 2026 02:20:15 +0200 Subject: [PATCH] fix: avoid Array.prototype.at() to support the declared browser range Array.prototype.at() requires Chrome 92 / Safari 15.4 / iOS 15.4, but .browserslistrc declares Chrome >= 60 and Safari >= 12, and the build does not polyfill (no useBuiltIns). Replace .at(-1) with index access so ChipInput, ChipSet and the calendar util run on the supported browsers. --- js/src/chip-input.js | 8 ++++---- js/src/chip-set.js | 2 +- js/src/util/calendar.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/src/chip-input.js b/js/src/chip-input.js index 585638da9..19ac7719f 100644 --- a/js/src/chip-input.js +++ b/js/src/chip-input.js @@ -166,7 +166,7 @@ class ChipInput extends ChipSet { // direction is mirrored in RTL. if (event.key === (isRTL() ? 'ArrowLeft' : 'ArrowRight')) { const chips = this._getFocusableChips() - if (chips.length > 0 && chips.at(-1).contains(event.target)) { + if (chips.length > 0 && chips[chips.length - 1].contains(event.target)) { event.preventDefault() this._input.focus() return @@ -271,7 +271,7 @@ class ChipInput extends ChipSet { const chips = this._getChipElements() if (chips.length > 0) { - chips.at(-1).focus() + chips[chips.length - 1].focus() } } @@ -292,7 +292,7 @@ class ChipInput extends ChipSet { const chips = this._getChipElements() if (chips.length > 0) { - chips.at(-1).focus() + chips[chips.length - 1].focus() } } @@ -323,7 +323,7 @@ class ChipInput extends ChipSet { this.add(part.trim()) } - this._input.value = parts.at(-1) + this._input.value = parts[parts.length - 1] } this._setInputSize() diff --git a/js/src/chip-set.js b/js/src/chip-set.js index a6b072e42..808c58d78 100644 --- a/js/src/chip-set.js +++ b/js/src/chip-set.js @@ -428,7 +428,7 @@ class ChipSet extends BaseComponent { _navigateToEdge(targetIndex) { const chips = this._getFocusableChips() - chips.at(targetIndex)?.focus() + chips[targetIndex < 0 ? chips.length + targetIndex : targetIndex]?.focus() } _handleSelectionChange(event) { diff --git a/js/src/util/calendar.js b/js/src/util/calendar.js index f4a1049da..7bb077f9f 100644 --- a/js/src/util/calendar.js +++ b/js/src/util/calendar.js @@ -859,13 +859,13 @@ export const getMonthDetails = (year, month, firstDayOfWeek) => { if ((index + 1) % 7 === 0) { const { weekNumber, year } = getISOWeekNumberAndYear(day.date) - const lastWeek = weeks.at(-1) + const lastWeek = weeks[weeks.length - 1] if (lastWeek) { lastWeek.week = { number: weekNumber, year } } } - const lastWeek = weeks.at(-1) + const lastWeek = weeks[weeks.length - 1] if (lastWeek) { lastWeek.days.push(day) }