Replace some ko.exportSymbol('*') in favour of ko['*']

and drop ko.exportProperty()
This commit is contained in:
the-djmaze 2024-02-11 15:37:24 +01:00
parent 6c144b5a28
commit 7c1f70c51e
16 changed files with 145 additions and 173 deletions

View file

@ -12,7 +12,7 @@
currentViewModelDispose.call(currentViewModel);
}
if (afterRenderSub) {
afterRenderSub.dispose();
afterRenderSub['dispose']();
}
afterRenderSub = null;
currentViewModel = null;
@ -22,7 +22,7 @@
originalChildNodes = [...ko.virtualElements.childNodes(element)];
ko.virtualElements.emptyNode(element);
ko.utils.domNodeDisposal.addDisposeCallback(element, disposeAssociatedComponentViewModel);
ko.utils.domNodeDisposal['addDisposeCallback'](element, disposeAssociatedComponentViewModel);
ko.computed(() => {
var componentName = ko.utils.unwrapObservable(valueAccessor()),
@ -40,7 +40,7 @@
var asyncContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);
var loadingOperationId = currentLoadingOperationId = ++componentLoadingOperationUniqueId;
ko.components.get(componentName, componentDefinition => {
ko['components'].get(componentName, componentDefinition => {
// If this is the current load operation for this element
if (currentLoadingOperationId === loadingOperationId) {
// Clean up previous state

View file

@ -2,7 +2,7 @@
var loadingSubscribablesCache = Object.create(null), // Tracks component loads that are currently in flight
loadedDefinitionsCache = new Map(); // Tracks component loads that have already completed
ko.components = {
ko['components'] = {
get: (componentName, callback) => {
if (loadedDefinitionsCache.has(componentName)) {
callback(loadedDefinitionsCache.get(componentName));
@ -32,7 +32,7 @@
}
},
register: (componentName, config) => {
'register': (componentName, config) => {
if (!config) {
throw new Error('Invalid configuration for ' + componentName);
}
@ -102,7 +102,4 @@
var found = (result['template'] && result[createViewModelKey]);
callback(found ? result : null);
};
ko.exportSymbol('components', ko.components);
ko.exportSymbol('components.register', ko.components.register);
})();