Remove some unused KnockoutJS features

This commit is contained in:
djmaze 2021-09-13 16:20:29 +02:00
parent f09820d0b9
commit 5839bcf62d
7 changed files with 100 additions and 184 deletions

View file

@ -18,12 +18,7 @@ ko.bindingHandlers['foreach'] = {
return {
'foreach': unwrappedValue['data'],
'as': unwrappedValue['as'],
'noChildContext': unwrappedValue['noChildContext'],
'includeDestroyed': unwrappedValue['includeDestroyed'],
'afterAdd': unwrappedValue['afterAdd'],
'beforeRemove': unwrappedValue['beforeRemove'],
'afterRender': unwrappedValue['afterRender'],
'beforeMove': unwrappedValue['beforeMove'],
'afterMove': unwrappedValue['afterMove']
};
};

View file

@ -4,12 +4,11 @@
function makeWithIfBinding(bindingKey, isWith, isNot) {
ko.bindingHandlers[bindingKey] = {
'init': (element, valueAccessor, allBindings, viewModel, bindingContext) => {
var didDisplayOnLastUpdate, savedNodes, contextOptions = {}, needAsyncContext, renderOnEveryChange;
var didDisplayOnLastUpdate, savedNodes, contextOptions = {}, needAsyncContext;
if (isWith) {
var as = allBindings.get('as'), noChildContext = allBindings.get('noChildContext');
renderOnEveryChange = !(as && noChildContext);
contextOptions = { 'as': as, 'noChildContext': noChildContext, 'exportDependencies': renderOnEveryChange };
var as = allBindings.get('as'), noChildContext = false;
contextOptions = { 'as': as, 'exportDependencies': true };
}
needAsyncContext = allBindings['has'](ko.bindingEvent.descendantsComplete);
@ -20,18 +19,12 @@ function makeWithIfBinding(bindingKey, isWith, isNot) {
isInitial = !savedNodes,
childContext;
if (!renderOnEveryChange && shouldDisplay === didDisplayOnLastUpdate) {
return;
}
if (needAsyncContext) {
bindingContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);
}
if (shouldDisplay) {
if (!isWith || renderOnEveryChange) {
contextOptions['dataDependency'] = ko.dependencyDetection.computed();
}
contextOptions['dataDependency'] = ko.dependencyDetection.computed();
if (isWith) {
childContext = bindingContext['createChildContext'](typeof value == "function" ? value : valueAccessor, contextOptions);