Skip to content

Commit

Permalink
🐛 Fixes Safari AutoFill (#3483)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekwoka committed May 10, 2023
1 parent 8d23398 commit 6d23457
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/alpinejs/src/directives/x-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d23457

Please sign in to comment.