mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-04 10:54:21 +08:00
KnockoutJS drop unused templateNodes
This commit is contained in:
parent
ab1a75935f
commit
bb3fc79e09
1 changed files with 3 additions and 10 deletions
|
@ -18,8 +18,7 @@
|
||||||
currentViewModel = null;
|
currentViewModel = null;
|
||||||
// Any in-flight loading operation is no longer relevant, so make sure we ignore its completion
|
// Any in-flight loading operation is no longer relevant, so make sure we ignore its completion
|
||||||
currentLoadingOperationId = null;
|
currentLoadingOperationId = null;
|
||||||
},
|
};
|
||||||
originalChildNodes = [...ko.virtualElements.childNodes(element)];
|
|
||||||
|
|
||||||
ko.virtualElements.emptyNode(element);
|
ko.virtualElements.emptyNode(element);
|
||||||
ko.utils.domNodeDisposal['addDisposeCallback'](element, disposeAssociatedComponentViewModel);
|
ko.utils.domNodeDisposal['addDisposeCallback'](element, disposeAssociatedComponentViewModel);
|
||||||
|
@ -58,15 +57,9 @@
|
||||||
ko.virtualElements.setDomNodeChildren(element, ko.utils.cloneNodes(template));
|
ko.virtualElements.setDomNodeChildren(element, ko.utils.cloneNodes(template));
|
||||||
|
|
||||||
currentViewModel = componentDefinition['createViewModel'](componentParams, {
|
currentViewModel = componentDefinition['createViewModel'](componentParams, {
|
||||||
'element': element,
|
'element': element
|
||||||
'templateNodes': originalChildNodes
|
|
||||||
});
|
});
|
||||||
ko.applyBindingsToDescendants(asyncContext.createChildContext(currentViewModel, {
|
ko.applyBindingsToDescendants(asyncContext.createChildContext(currentViewModel, {}), element);
|
||||||
'extend': ctx => {
|
|
||||||
ctx['$component'] = currentViewModel;
|
|
||||||
ctx['$componentTemplateNodes'] = originalChildNodes;
|
|
||||||
}
|
|
||||||
}), element);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, { disposeWhenNodeIsRemoved: element });
|
}, { disposeWhenNodeIsRemoved: element });
|
||||||
|
|
Loading…
Add table
Reference in a new issue