Explorar o código

fixed safari autofill bug (#1969)

* fixed safari autofill bug

* removed test html mockup
Dede Muzaffer %!s(int64=3) %!d(string=hai) anos
pai
achega
b41b35832a
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      packages/alpinejs/src/directives/x-model.js

+ 3 - 1
packages/alpinejs/src/directives/x-model.js

@@ -60,8 +60,10 @@ function generateAssignmentFunction(el, modifiers, expression) {
     return (event, currentValue) => {
         return mutateDom(() => {
             // 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 event.detail
+                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)) {