From e97cf8fa6b1b9e73e2493ef5f592da62d9812312 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 3 Mar 2024 19:20:51 +0100 Subject: [PATCH] Knockoutjs built latest --- .../build/output/knockout-latest.debug.js | 439 ++++++------------ .../knockout/build/output/knockout-latest.js | 130 +++--- 2 files changed, 204 insertions(+), 365 deletions(-) diff --git a/vendors/knockout/build/output/knockout-latest.debug.js b/vendors/knockout/build/output/knockout-latest.debug.js index a1ebe1f6a..7e25db51c 100644 --- a/vendors/knockout/build/output/knockout-latest.debug.js +++ b/vendors/knockout/build/output/knockout-latest.debug.js @@ -824,8 +824,8 @@ ko.computed = (evaluatorFunctionOrOptions, options) => { pure: false, isSleeping: false, readFunction: options["read"], - disposeWhenNodeIsRemoved: options["disposeWhenNodeIsRemoved"] || options.disposeWhenNodeIsRemoved || null, - disposeWhen: options["disposeWhen"] || options.disposeWhen, + disposeWhenNodeIsRemoved: options.disposeWhenNodeIsRemoved || null, + disposeWhen: options.disposeWhen, domNodeDisposalCallback: null, dependencyTracking: {}, dependenciesCount: 0, @@ -1004,14 +1004,8 @@ var computedFn = { return target['subscribe'](this.evaluatePossiblyAsync, this); }, evaluatePossiblyAsync() { - var computedObservable = this, - throttleEvaluationTimeout = computedObservable['throttleEvaluation']; - if (throttleEvaluationTimeout >= 0) { - clearTimeout(this[computedState].evaluationTimeoutInstance); - this[computedState].evaluationTimeoutInstance = setTimeout(() => - computedObservable.evaluateImmediate(true /*notifyChange*/) - , throttleEvaluationTimeout); - } else if (computedObservable._evalDelayed) { + var computedObservable = this; + if (computedObservable._evalDelayed) { computedObservable._evalDelayed(true /*isChange*/); } else { computedObservable.evaluateImmediate(true /*notifyChange*/); @@ -1285,7 +1279,7 @@ ko.selectExtensions = { } }, - writeValue: (element, value, allowUnset) => { + writeValue: (element, value) => { switch (element.nodeName) { case 'OPTION': if (typeof value === "string") { @@ -1314,7 +1308,7 @@ ko.selectExtensions = { break; } } - if (allowUnset || selection >= 0 || (noValue && element.size > 1)) { + if (selection >= 0 || (noValue && element.size > 1)) { element.selectedIndex = selection; } break; @@ -1438,9 +1432,6 @@ ko.expressionRewriting = (() => { return result; }, - // Two-way bindings include a write function that allow the handler to update the value even if it's not an observable. -// twoWayBindings = new Set, - preProcessBindings = (bindingsStringOrKeyValueArray) => { var resultStrings = [], @@ -1448,16 +1439,6 @@ ko.expressionRewriting = (() => { keyValueArray = parseObjectLiteral(bindingsStringOrKeyValueArray), processKeyValue = (key, val) => { - var /*writableVal,*/ obj = ko.bindingHandlers[key]; - if (obj?.['preprocess'] && !obj['preprocess'](val, key, processKeyValue)) - return; -/* - if (twoWayBindings.has(key) && (writableVal = getWriteableValue(val))) { - // For two-way bindings, provide a write method in case the value - // isn't a writable observable. - propertyAccessorResultStrings.push("'" + key + "':function(_z){" + writableVal + "=_z}"); - } -*/ // Values are wrapped in a function so that each value can be accessed independently val = 'function(){return ' + val + ' }'; resultStrings.push("'" + key + "':" + val); @@ -1474,10 +1455,6 @@ ko.expressionRewriting = (() => { }; return { - bindingRewriteValidators: [], - -// twoWayBindings: twoWayBindings, - parseObjectLiteral: parseObjectLiteral, preProcessBindings: preProcessBindings, @@ -1696,7 +1673,7 @@ ko.bindingHandlers = {}; // The ko.bindingContext constructor is only called directly to create the root context. For child // contexts, use bindingContext.createChildContext or bindingContext.extend. ko.bindingContext = class { - constructor(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, options) + constructor(dataItemOrAccessor, parentContext, extendCallback, options) { var self = this, shouldInheritData = dataItemOrAccessor === inheritParentVm, @@ -1725,7 +1702,6 @@ ko.bindingContext = class { self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo]; } } else { - self['$parents'] = []; self['$root'] = dataItem; // Export 'ko' in the binding context so it will be available in bindings and templates @@ -1739,13 +1715,9 @@ ko.bindingContext = class { if (shouldInheritData) { dataItem = self['$data']; } else { - self['$rawData'] = dataItemOrObservable; self['$data'] = dataItem; } - if (dataItemAlias) - self[dataItemAlias] = dataItem; - // The extendCallback function is provided when creating a child context or extending a context. // It handles the specific actions needed to finish setting up the binding context. Actions in this // function could also add dependencies to this binding context. @@ -1790,21 +1762,11 @@ ko.bindingContext = class { // 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 on each update. - 'createChildContext'(dataItemOrAccessor, dataItemAlias, extendCallback, options) { - if (!options && dataItemAlias && typeof dataItemAlias == "object") { - options = dataItemAlias; - dataItemAlias = options['as']; - extendCallback = options['extend']; - } - - return new ko.bindingContext(dataItemOrAccessor, this, dataItemAlias, (self, parentContext) => { + 'createChildContext'(dataItemOrAccessor, options) { + return new ko.bindingContext(dataItemOrAccessor, this, (self, parentContext) => { // Extend the context hierarchy by setting the appropriate pointers - self['$parentContext'] = parentContext; self['$parent'] = parentContext['$data']; - self['$parents'] = (parentContext['$parents'] || []).slice(0); - self['$parents'].unshift(self['$parent']); - if (extendCallback) - extendCallback(self); + options['extend']?.(self); }, options); } @@ -1812,7 +1774,7 @@ ko.bindingContext = class { // Similarly to "child" contexts, provide a function here to make sure that the correct values are set // when an observable view model is updated. 'extend'(properties, options) { - return new ko.bindingContext(inheritParentVm, this, null, self => + return new ko.bindingContext(inheritParentVm, this, self => ko.utils.extend(self, typeof(properties) == "function" ? properties(self) : properties) , options); } @@ -1909,12 +1871,6 @@ ko.bindingEvent = { } }; -function validateThatBindingIsAllowedForVirtualElements(bindingName) { - var validator = ko.virtualElements.allowedBindings[bindingName]; - if (!validator) - throw new Error("The binding '" + bindingName + "' cannot be used with virtual elements") -} - function applyBindingsToDescendantsInternal(bindingContext, elementOrVirtualElement) { var currentChild, nextInQueue = ko.virtualElements.firstChild(elementOrVirtualElement); @@ -1935,7 +1891,7 @@ function applyBindingsToNodeAndDescendantsInternal(bindingContext, nodeVerified) // (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)) - bindingContextForDescendants = applyBindingsToNodeInternal(nodeVerified, null, bindingContext)['bindingContextForDescendants']; + bindingContextForDescendants = applyBindingsToNodeInternal(nodeVerified, null, bindingContext); // Don't want bindings that operate on text nodes to mutate