diff --git a/packages/alpinejs/src/directives/x-model.js b/packages/alpinejs/src/directives/x-model.js index c18950af2..ba03f522c 100644 --- a/packages/alpinejs/src/directives/x-model.js +++ b/packages/alpinejs/src/directives/x-model.js @@ -134,9 +134,9 @@ function getInputValue(el, modifiers, event, currentValue) { // Check for event.detail due to an issue where IE11 handles other events as a CustomEvent. // 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 typeof event.detail != 'undefined' ? event.detail : event.target.value - } else if (el.type === 'checkbox') { + if (event instanceof CustomEvent && event.detail !== undefined) + return 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)) { let newValue = modifiers.includes('number') ? safeParseNumber(event.target.value) : event.target.value