mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
KnockoutJS scramble createChildContext
This commit is contained in:
parent
47cd902369
commit
4ee00d30ae
4 changed files with 5 additions and 5 deletions
|
|
@ -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
|
// 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 also depends on the parent view model, you must provide a function that returns the correct
|
||||||
// view model on each update.
|
// view model on each update.
|
||||||
'createChildContext'(dataItemOrAccessor, options) {
|
createChildContext(dataItemOrAccessor, options) {
|
||||||
return new ko.bindingContext(dataItemOrAccessor, this, (self, parentContext) => {
|
return new ko.bindingContext(dataItemOrAccessor, this, (self, parentContext) => {
|
||||||
// Extend the context hierarchy by setting the appropriate pointers
|
// Extend the context hierarchy by setting the appropriate pointers
|
||||||
self['$parentContext'] = parentContext;
|
self['$parentContext'] = parentContext;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function makeWithIfBinding(bindingKey, isWith, isNot) {
|
||||||
contextOptions['dataDependency'] = ko.dependencyDetection.computed();
|
contextOptions['dataDependency'] = ko.dependencyDetection.computed();
|
||||||
|
|
||||||
childContext = isWith
|
childContext = isWith
|
||||||
? bindingContext['createChildContext'](typeof value == "function" ? value : valueAccessor, contextOptions)
|
? bindingContext.createChildContext(typeof value == "function" ? value : valueAccessor, contextOptions)
|
||||||
: (ko.dependencyDetection.getDependenciesCount()
|
: (ko.dependencyDetection.getDependenciesCount()
|
||||||
? bindingContext['extend'](null, contextOptions)
|
? bindingContext['extend'](null, contextOptions)
|
||||||
: bindingContext
|
: bindingContext
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
'element': element,
|
'element': element,
|
||||||
'templateNodes': originalChildNodes
|
'templateNodes': originalChildNodes
|
||||||
});
|
});
|
||||||
ko.applyBindingsToDescendants(asyncContext['createChildContext'](currentViewModel, {
|
ko.applyBindingsToDescendants(asyncContext.createChildContext(currentViewModel, {
|
||||||
'extend': ctx => {
|
'extend': ctx => {
|
||||||
ctx['$component'] = currentViewModel;
|
ctx['$component'] = currentViewModel;
|
||||||
ctx['$componentTemplateNodes'] = originalChildNodes;
|
ctx['$componentTemplateNodes'] = originalChildNodes;
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@
|
||||||
// This will be called by setDomNodeChildrenFromArrayMapping to get the nodes to add to targetNode
|
// This will be called by setDomNodeChildrenFromArrayMapping to get the nodes to add to targetNode
|
||||||
var executeTemplateForArrayItem = (arrayValue, index) => {
|
var executeTemplateForArrayItem = (arrayValue, index) => {
|
||||||
// Support selecting template as a function of the data being rendered
|
// Support selecting template as a function of the data being rendered
|
||||||
arrayItemContext = parentBindingContext['createChildContext'](arrayValue, {
|
arrayItemContext = parentBindingContext.createChildContext(arrayValue, {
|
||||||
'extend': context => context['$index'] = index
|
'extend': context => context['$index'] = index
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@
|
||||||
// Render once for this single data point (or use the viewModel if no data was provided)
|
// Render once for this single data point (or use the viewModel if no data was provided)
|
||||||
var innerBindingContext = bindingContext;
|
var innerBindingContext = bindingContext;
|
||||||
if ('data' in options) {
|
if ('data' in options) {
|
||||||
innerBindingContext = bindingContext['createChildContext'](options['data'], {
|
innerBindingContext = bindingContext.createChildContext(options['data'], {
|
||||||
'exportDependencies': true
|
'exportDependencies': true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue