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

@ -151,7 +151,7 @@ class AsyncCompleteContext {
this.asyncDescendants = new Set;
this.childrenComplete = false;
bindingInfo.asyncContext || ko.utils.domNodeDisposal.addDisposeCallback(node, asyncContextDispose);
bindingInfo.asyncContext || ko.utils.domNodeDisposal['addDisposeCallback'](node, asyncContextDispose);
if (ancestorBindingInfo?.asyncContext) {
ancestorBindingInfo.asyncContext.asyncDescendants.add(node);
@ -360,7 +360,7 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext) {
var callback = bindings[ko.bindingEvent.childrenComplete]();
if (callback) {
var nodes = ko.virtualElements.childNodes(node);
nodes.length && callback(nodes, ko.dataFor(nodes[0]));
nodes.length && callback(nodes, ko['dataFor'](nodes[0]));
}
});
}
@ -435,7 +435,7 @@ function getBindingContext(viewModelOrBindingContext, extendContextCallback) {
: new ko.bindingContext(viewModelOrBindingContext, undefined, undefined, extendContextCallback);
}
ko.applyBindingAccessorsToNode = (node, bindings, viewModelOrBindingContext) =>
ko['applyBindingAccessorsToNode'] = (node, bindings, viewModelOrBindingContext) =>
applyBindingsToNodeInternal(node, bindings, getBindingContext(viewModelOrBindingContext));
ko.applyBindingsToDescendants = (viewModelOrBindingContext, rootNode) => {
@ -457,7 +457,7 @@ ko.applyBindings = function (viewModelOrBindingContext, rootNode, extendContextC
};
// Retrieving binding context from arbitrary nodes
ko.dataFor = node => {
ko['dataFor'] = node => {
// We can only do something meaningful for elements and comment nodes (in particular, not text nodes, as IE can't store domdata for them)
var context = node && [1,8].includes(node.nodeType) && ko.storedBindingContextForNode(node);
return context ? context['$data'] : undefined;
@ -465,5 +465,3 @@ ko.dataFor = node => {
ko.exportSymbol('bindingHandlers', ko.bindingHandlers);
ko.exportSymbol('applyBindings', ko.applyBindings);
ko.exportSymbol('applyBindingAccessorsToNode', ko.applyBindingAccessorsToNode);
ko.exportSymbol('dataFor', ko.dataFor);

View file

@ -5,7 +5,7 @@ ko.bindingHandlers['value'] = {
// If the value binding is placed on a radio/checkbox, then just pass through to checkedValue and quit
if (isInputElement && (element.type == "checkbox" || element.type == "radio")) {
ko.applyBindingAccessorsToNode(element, { 'checkedValue': valueAccessor });
ko['applyBindingAccessorsToNode'](element, { 'checkedValue': valueAccessor });
return;
}

View file

@ -106,7 +106,7 @@
// Stop tracking changes to the mapping for these nodes
if (mapData.dependentObservable) {
mapData.dependentObservable.dispose();
mapData.dependentObservable['dispose']();
mapData.dependentObservable = undefined;
}