From 8a461e7a3db9b0c49abdd6208bb7c277f0ecd445 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 14 Apr 2024 15:14:23 +0200 Subject: [PATCH] Speedup Knockout a bit --- .../build/output/knockout-latest.debug.js | 120 +++++++---------- .../knockout/build/output/knockout-latest.js | 124 +++++++++--------- .../src/binding/bindingAttributeSyntax.js | 113 +++++++--------- vendors/knockout/src/templating/templating.js | 7 +- 4 files changed, 164 insertions(+), 200 deletions(-) diff --git a/vendors/knockout/build/output/knockout-latest.debug.js b/vendors/knockout/build/output/knockout-latest.debug.js index 18366c092..28307b49b 100644 --- a/vendors/knockout/build/output/knockout-latest.debug.js +++ b/vendors/knockout/build/output/knockout-latest.debug.js @@ -1776,14 +1776,14 @@ ko.bindingContext = class { } }; -function asyncContextDispose(node) { +const asyncContextDispose = node => { var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey), asyncContext = bindingInfo?.asyncContext; if (asyncContext) { bindingInfo.asyncContext = null; asyncContext.notifyAncestor(); } -} +}; class AsyncCompleteContext { constructor(node, bindingInfo, ancestorBindingInfo) { @@ -1867,7 +1867,7 @@ ko.bindingEvent = { } }; -function applyBindingsToDescendantsInternal(bindingContext, elementOrVirtualElement) { +const applyBindingsToDescendantsInternal = (bindingContext, elementOrVirtualElement) => { var currentChild, nextInQueue = ko.virtualElements.firstChild(elementOrVirtualElement); while (currentChild = nextInQueue) { @@ -1876,17 +1876,15 @@ function applyBindingsToDescendantsInternal(bindingContext, elementOrVirtualElem applyBindingsToNodeAndDescendantsInternal(bindingContext, currentChild); } ko.bindingEvent.notify(elementOrVirtualElement, ko.bindingEvent.childrenComplete); -} +}; -function applyBindingsToNodeAndDescendantsInternal(bindingContext, nodeVerified) { +const applyBindingsToNodeAndDescendantsInternal = (bindingContext, nodeVerified) => { var bindingContextForDescendants = bindingContext; - var isElement = (nodeVerified.nodeType === 1); - // Perf optimisation: Apply bindings only if... // (1) We need to store the binding info for the node (all element nodes) // (2) It might have bindings (e.g., it has a data-bind attribute, or it's a marker for a containerless template) - if (isElement || ko.bindingProvider.nodeHasBindings(nodeVerified)) + if ((1 === nodeVerified.nodeType) || ko.bindingProvider.nodeHasBindings(nodeVerified)) bindingContextForDescendants = applyBindingsToNodeInternal(nodeVerified, null, bindingContext); // Don't want bindings that operate on text nodes to mutate