From ba08ec4201aa0622a191ca8aa9faba3a135dcb72 Mon Sep 17 00:00:00 2001 From: mgschoen Date: Mon, 11 Sep 2023 14:47:25 +0200 Subject: [PATCH] Fixed webpack 4 builds breaking due to nullish coalescing operator (#3679) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed webpack 4 builds breaking due to nullish coalescing operator * Replaced another usage of nullish coalescing with explicit typechecks in order to fix webpack 4 builds --------- Co-authored-by: Martin Schön --- packages/alpinejs/src/directives/x-model.js | 2 +- packages/mask/src/index.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/alpinejs/src/directives/x-model.js b/packages/alpinejs/src/directives/x-model.js index f17e55e9b..7d725043f 100644 --- a/packages/alpinejs/src/directives/x-model.js +++ b/packages/alpinejs/src/directives/x-model.js @@ -134,7 +134,7 @@ function getInputValue(el, modifiers, event, currentValue) { // Safari autofill triggers event as CustomEvent and assigns value to target // so we return event.target.value instead of event.detail if (event instanceof CustomEvent && event.detail !== undefined) - return event.detail ?? event.target.value + return event.detail !== null && event.detail !== undefined ? event.detail : event.target.value else if (el.type === 'checkbox') { // If the data we are binding to is an array, toggle its value inside the array. if (Array.isArray(currentValue)) { diff --git a/packages/mask/src/index.js b/packages/mask/src/index.js index 7a3fa0a2e..818b1c59e 100644 --- a/packages/mask/src/index.js +++ b/packages/mask/src/index.js @@ -174,7 +174,9 @@ export function formatMoney(input, delimiter = '.', thousands, precision = 2) { if (input === '-') return '-' if (/^\D+$/.test(input)) return '9' - thousands = thousands ?? (delimiter === "," ? "." : ",") + if (thousands === null || thousands === undefined) { + thousands = delimiter === "," ? "." : "," + } let addThousands = (input, thousands) => { let output = ''