Pārlūkot izejas kodu

:bug: Fixes Safari AutoFill (#3483)

Eric Kwoka 2 gadi atpakaļ
vecāks
revīzija
6d23457881
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 3 3
      packages/alpinejs/src/directives/x-model.js

+ 3 - 3
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