diff --git a/vendors/knockout/src/binding/bindingAttributeSyntax.js b/vendors/knockout/src/binding/bindingAttributeSyntax.js index 86bc34b0c..62a916c5b 100644 --- a/vendors/knockout/src/binding/bindingAttributeSyntax.js +++ b/vendors/knockout/src/binding/bindingAttributeSyntax.js @@ -13,7 +13,7 @@ ko.bindingHandlers = {}; // The ko.bindingContext constructor is only called directly to create the root context. For child // contexts, use bindingContext.createChildContext or bindingContext.extend. ko.bindingContext = class { - constructor(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, options) + constructor(dataItemOrAccessor, parentContext, extendCallback, options) { var self = this, shouldInheritData = dataItemOrAccessor === inheritParentVm, @@ -60,9 +60,6 @@ ko.bindingContext = class { self['$data'] = dataItem; } - if (dataItemAlias) - self[dataItemAlias] = dataItem; - // The extendCallback function is provided when creating a child context or extending a context. // It handles the specific actions needed to finish setting up the binding context. Actions in this // function could also add dependencies to this binding context. @@ -107,21 +104,14 @@ 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, dataItemAlias, extendCallback, options) { - if (!options && dataItemAlias && typeof dataItemAlias == "object") { - options = dataItemAlias; - dataItemAlias = options['as']; - extendCallback = options['extend']; - } - - return new ko.bindingContext(dataItemOrAccessor, this, dataItemAlias, (self, parentContext) => { + 'createChildContext'(dataItemOrAccessor, options) { + return new ko.bindingContext(dataItemOrAccessor, this, (self, parentContext) => { // Extend the context hierarchy by setting the appropriate pointers self['$parentContext'] = parentContext; self['$parent'] = parentContext['$data']; self['$parents'] = (parentContext['$parents'] || []).slice(0); self['$parents'].unshift(self['$parent']); - if (extendCallback) - extendCallback(self); + options['extend']?.(self); }, options); } @@ -129,7 +119,7 @@ ko.bindingContext = class { // Similarly to "child" contexts, provide a function here to make sure that the correct values are set // when an observable view model is updated. 'extend'(properties, options) { - return new ko.bindingContext(inheritParentVm, this, null, self => + return new ko.bindingContext(inheritParentVm, this, self => ko.utils.extend(self, typeof(properties) == "function" ? properties(self) : properties) , options); } @@ -432,7 +422,7 @@ ko.storedBindingContextForNode = node => { function getBindingContext(viewModelOrBindingContext, extendContextCallback) { return viewModelOrBindingContext && (viewModelOrBindingContext instanceof ko.bindingContext) ? viewModelOrBindingContext - : new ko.bindingContext(viewModelOrBindingContext, undefined, undefined, extendContextCallback); + : new ko.bindingContext(viewModelOrBindingContext, null, extendContextCallback); } ko['applyBindingAccessorsToNode'] = (node, bindings, viewModelOrBindingContext) => diff --git a/vendors/knockout/src/binding/defaultBindings/foreach.js b/vendors/knockout/src/binding/defaultBindings/foreach.js index 961132fc9..a1c5f25a8 100644 --- a/vendors/knockout/src/binding/defaultBindings/foreach.js +++ b/vendors/knockout/src/binding/defaultBindings/foreach.js @@ -16,8 +16,7 @@ ko.bindingHandlers['foreach'] = { // If unwrappedValue.data is the array, preserve all relevant options and unwrap again value so we get updates ko.utils.unwrapObservable(modelValue); return { - 'foreach': unwrappedValue['data'], - 'as': unwrappedValue['as'] + 'foreach': unwrappedValue['data'] }; }, 'init': (element, valueAccessor) => diff --git a/vendors/knockout/src/binding/defaultBindings/ifIfnotWith.js b/vendors/knockout/src/binding/defaultBindings/ifIfnotWith.js index 9a3636fed..b5e01407f 100644 --- a/vendors/knockout/src/binding/defaultBindings/ifIfnotWith.js +++ b/vendors/knockout/src/binding/defaultBindings/ifIfnotWith.js @@ -7,7 +7,7 @@ function makeWithIfBinding(bindingKey, isWith, isNot) { var savedNodes, contextOptions = {}, needAsyncContext; if (isWith) { - contextOptions = { 'as': allBindings.get('as'), 'exportDependencies': true }; + contextOptions = { 'exportDependencies': true }; } needAsyncContext = allBindings['has'](ko.bindingEvent.descendantsComplete); diff --git a/vendors/knockout/src/templating/templating.js b/vendors/knockout/src/templating/templating.js index ba4637be4..699ce092c 100644 --- a/vendors/knockout/src/templating/templating.js +++ b/vendors/knockout/src/templating/templating.js @@ -115,7 +115,7 @@ // Ensure we've got a proper binding context to work with var bindingContext = (dataOrBindingContext instanceof ko.bindingContext) ? dataOrBindingContext - : new ko.bindingContext(dataOrBindingContext, null, null, null, { "exportDependencies": true }); + : new ko.bindingContext(dataOrBindingContext, null, null, { "exportDependencies": true }); var templateName = resolveTemplateName(template, bindingContext['$data'], bindingContext); executeTemplate(targetNodeOrNodeArray, renderMode, templateName, bindingContext, options); @@ -130,19 +130,13 @@ ko.renderTemplateForEach = (template, arrayOrObservableArray, options, targetNode, parentBindingContext) => { // Since setDomNodeChildrenFromArrayMapping always calls executeTemplateForArrayItem and then // activateBindingsCallback for added items, we can store the binding context in the former to use in the latter. - var arrayItemContext, asName = options['as']; + var arrayItemContext; // This will be called by setDomNodeChildrenFromArrayMapping to get the nodes to add to targetNode var executeTemplateForArrayItem = (arrayValue, index) => { // Support selecting template as a function of the data being rendered arrayItemContext = parentBindingContext['createChildContext'](arrayValue, { - 'as': asName, - 'extend': context => { - context['$index'] = index; - if (asName) { - context[asName + "Index"] = index; - } - } + 'extend': context => context['$index'] = index }); var templateName = resolveTemplateName(template, arrayValue, arrayItemContext); @@ -267,7 +261,6 @@ var innerBindingContext = bindingContext; if ('data' in options) { innerBindingContext = bindingContext['createChildContext'](options['data'], { - 'as': options['as'], 'exportDependencies': true }); }