KnockoutJS scramble createChildContext

This commit is contained in:
the-djmaze 2024-03-03 17:24:55 +01:00
parent 47cd902369
commit 4ee00d30ae
4 changed files with 5 additions and 5 deletions

View file

@ -104,7 +104,7 @@ ko.bindingContext = class {
// But this does not mean that the $data value of the child context will also get updated. If the child
// view model also depends on the parent view model, you must provide a function that returns the correct
// view model on each update.
'createChildContext'(dataItemOrAccessor, options) {
createChildContext(dataItemOrAccessor, options) {
return new ko.bindingContext(dataItemOrAccessor, this, (self, parentContext) => {
// Extend the context hierarchy by setting the appropriate pointers
self['$parentContext'] = parentContext;

View file

@ -26,7 +26,7 @@ function makeWithIfBinding(bindingKey, isWith, isNot) {
contextOptions['dataDependency'] = ko.dependencyDetection.computed();
childContext = isWith
? bindingContext['createChildContext'](typeof value == "function" ? value : valueAccessor, contextOptions)
? bindingContext.createChildContext(typeof value == "function" ? value : valueAccessor, contextOptions)
: (ko.dependencyDetection.getDependenciesCount()
? bindingContext['extend'](null, contextOptions)
: bindingContext