Improved Knockout property binding error

This commit is contained in:
the-djmaze 2024-09-23 17:02:51 +02:00
parent 4022d39f76
commit 92a6027aa0
7 changed files with 37 additions and 35 deletions

View file

@ -69,7 +69,7 @@ ko.bindingHandlers['checked'] = {
elemValue = undefined;
}
}
ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'checked', elemValue, true);
ko.expressionRewriting.writeValueToProperty(element, modelValue, allBindings, 'checked', elemValue, true);
}
}

View file

@ -11,7 +11,7 @@ ko.bindingHandlers['hasfocus'] = {
// Discussion at https://github.com/SteveSanderson/knockout/pull/352
element[hasfocusUpdatingProperty] = true;
isFocused = (element.ownerDocument.activeElement === element);
ko.expressionRewriting.writeValueToProperty(valueAccessor(), allBindings, 'hasfocus', isFocused, true);
ko.expressionRewriting.writeValueToProperty(element, valueAccessor(), allBindings, 'hasfocus', isFocused, true);
//cache the latest value, so we can avoid unnecessarily calling focus/blur in the update function
element[hasfocusLastValue] = isFocused;

View file

@ -13,7 +13,7 @@ ko.bindingHandlers['textInput'] = {
if (element.checkValidity() && previousElementValue !== elementValue) {
// Provide a way for tests to know exactly which event was processed
previousElementValue = elementValue;
ko.expressionRewriting.writeValueToProperty(valueAccessor(), allBindings, 'textInput', elementValue);
ko.expressionRewriting.writeValueToProperty(element, valueAccessor(), allBindings, 'textInput', elementValue);
}
};

View file

@ -20,7 +20,7 @@ ko.bindingHandlers['value'] = {
elementValueBeforeEvent = null;
var modelValue = valueAccessor();
var elementValue = ko.selectExtensions.readValue(element);
ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'value', elementValue);
ko.expressionRewriting.writeValueToProperty(element, modelValue, allBindings, 'value', elementValue);
};
if (requestedEventsToCatch) {