|
@@ -46,10 +46,6 @@ directive('model', (el, { modifiers, expression }, { effect, cleanup }) => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (modifiers.includes('fill') && el.hasAttribute('value') && (getValue() === null || getValue() === '')) {
|
|
|
|
- setValue(el.value)
|
|
|
|
- }
|
|
|
|
|
|
|
|
if (typeof expression === 'string' && el.type === 'radio') {
|
|
if (typeof expression === 'string' && el.type === 'radio') {
|
|
// Radio buttons only work properly when they share a name attribute.
|
|
// Radio buttons only work properly when they share a name attribute.
|
|
@@ -73,7 +69,10 @@ directive('model', (el, { modifiers, expression }, { effect, cleanup }) => {
|
|
let removeListener = isCloning ? () => {} : on(el, event, modifiers, (e) => {
|
|
let removeListener = isCloning ? () => {} : on(el, event, modifiers, (e) => {
|
|
setValue(getInputValue(el, modifiers, e, getValue()))
|
|
setValue(getInputValue(el, modifiers, e, getValue()))
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ if (modifiers.includes('fill') && [null, ''].includes(getValue())) {
|
|
|
|
+ el.dispatchEvent(new Event(event, {}));
|
|
|
|
+ }
|
|
// Register the listener removal callback on the element, so that
|
|
// Register the listener removal callback on the element, so that
|
|
// in addition to the cleanup function, x-modelable may call it.
|
|
// in addition to the cleanup function, x-modelable may call it.
|
|
// Also, make this a keyed object if we decide to reintroduce
|
|
// Also, make this a keyed object if we decide to reintroduce
|
|
@@ -134,9 +133,9 @@ function getInputValue(el, modifiers, event, currentValue) {
|
|
// Check for event.detail due to an issue where IE11 handles other events as a CustomEvent.
|
|
// 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
|
|
// Safari autofill triggers event as CustomEvent and assigns value to target
|
|
// so we return event.target.value instead of event.detail
|
|
// 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 the data we are binding to is an array, toggle its value inside the array.
|
|
if (Array.isArray(currentValue)) {
|
|
if (Array.isArray(currentValue)) {
|
|
let newValue = modifiers.includes('number') ? safeParseNumber(event.target.value) : event.target.value
|
|
let newValue = modifiers.includes('number') ? safeParseNumber(event.target.value) : event.target.value
|