KnockoutJS don't scramble exportDependencies. controlsDescendantBindings, createChildContext

This commit is contained in:
the-djmaze 2024-03-03 19:10:00 +01:00
parent a8e38a998f
commit 766d3eaa98
8 changed files with 16 additions and 16 deletions

View file

@ -102,7 +102,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, { exportDependencies: true });
: new ko.bindingContext(dataOrBindingContext, null, null, { "exportDependencies": true });
var templateName = resolveTemplateName(template, bindingContext['$data'], bindingContext);
executeTemplate(targetNodeOrNodeArray, true, templateName, bindingContext, options);
@ -122,7 +122,7 @@
// 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, {
arrayItemContext = parentBindingContext['createChildContext'](arrayValue, {
'extend': context => context['$index'] = index
});
@ -247,8 +247,8 @@
// Render once for this single data point (or use the viewModel if no data was provided)
var innerBindingContext = bindingContext;
if ('data' in options) {
innerBindingContext = bindingContext.createChildContext(options['data'], {
exportDependencies: true
innerBindingContext = bindingContext['createChildContext'](options['data'], {
'exportDependencies': true
});
}
templateComputed = renderTemplate(template, innerBindingContext, options, element);