Remove knockout evaluatorFunctionTarget

Drop deprecated knockout throttle extender
Added knockout debounce extender
This commit is contained in:
djmaze 2021-02-10 11:33:36 +01:00
parent b9b0a550d6
commit 75b7176ada
15 changed files with 158 additions and 226 deletions

View file

@ -11,12 +11,9 @@ ko.bindingHandlers['html'] = {
let html = ko.utils.unwrapObservable(valueAccessor());
if (html != null) {
if (typeof html != 'string')
html = html.toString();
const template = document.createElement('template');
template.innerHTML = html;
element.appendChild(template.content);
const template = document.createElement('template');
template.innerHTML = typeof html != 'string' ? html.toString() : html;
element.appendChild(template.content);
}
}
}
};

View file

@ -31,12 +31,12 @@ function makeWithIfBinding(bindingKey, isWith, isNot) {
if (shouldDisplay) {
if (!isWith || renderOnEveryChange) {
contextOptions['dataDependency'] = ko.computedContext.computed();
contextOptions['dataDependency'] = ko.dependencyDetection.computed();
}
if (isWith) {
childContext = bindingContext['createChildContext'](typeof value == "function" ? value : valueAccessor, contextOptions);
} else if (ko.computedContext.getDependenciesCount()) {
} else if (ko.dependencyDetection.getDependenciesCount()) {
childContext = bindingContext['extend'](null, contextOptions);
} else {
childContext = bindingContext;
@ -44,7 +44,7 @@ function makeWithIfBinding(bindingKey, isWith, isNot) {
}
// Save a copy of the inner nodes on the initial update, but only if we have dependencies.
if (isInitial && ko.computedContext.getDependenciesCount()) {
if (isInitial && ko.dependencyDetection.getDependenciesCount()) {
savedNodes = ko.utils.cloneNodes(ko.virtualElements.childNodes(element), true /* shouldCleanNodes */);
}
@ -64,7 +64,7 @@ function makeWithIfBinding(bindingKey, isWith, isNot) {
didDisplayOnLastUpdate = shouldDisplay;
}, null, { disposeWhenNodeIsRemoved: element });
}, { disposeWhenNodeIsRemoved: element });
return { 'controlsDescendantBindings': true };
}

View file

@ -144,7 +144,7 @@ ko.bindingHandlers['options'] = {
}
}
if (valueAllowUnset || ko.computedContext.isInitial()) {
if (valueAllowUnset || ko.dependencyDetection.isInitial()) {
ko.bindingEvent.notify(element, ko.bindingEvent.childrenComplete);
}

View file

@ -72,7 +72,7 @@ ko.bindingHandlers['textInput'] = {
// To deal with browsers that don't notify any kind of event for some changes (IE, Safari, etc.)
onEvent('blur', updateModel);
ko.computed(updateView, null, { disposeWhenNodeIsRemoved: element });
ko.computed(updateView, { disposeWhenNodeIsRemoved: element });
}
};
ko.expressionRewriting.twoWayBindings['textInput'] = true;

View file

@ -99,7 +99,7 @@ ko.bindingHandlers['value'] = {
ko.bindingEvent.subscribe(element, ko.bindingEvent.childrenComplete, () => {
if (!updateFromModelComputed) {
ko.utils.registerEventHandler(element, "change", valueUpdateHandler);
updateFromModelComputed = ko.computed(updateFromModel, null, { disposeWhenNodeIsRemoved: element });
updateFromModelComputed = ko.computed(updateFromModel, { disposeWhenNodeIsRemoved: element });
} else if (allBindings.get('valueAllowUnset')) {
updateFromModel();
} else {
@ -108,7 +108,7 @@ ko.bindingHandlers['value'] = {
}, null, { 'notifyImmediately': true });
} else {
ko.utils.registerEventHandler(element, "change", valueUpdateHandler);
ko.computed(updateFromModel, null, { disposeWhenNodeIsRemoved: element });
ko.computed(updateFromModel, { disposeWhenNodeIsRemoved: element });
}
},
'update': () => {} // Keep for backwards compatibility with code that may have wrapped value binding