diff --git a/vendors/knockout/build/fragments/source-references.js b/vendors/knockout/build/fragments/source-references.js index 12e9eecde..5da820fd7 100644 --- a/vendors/knockout/build/fragments/source-references.js +++ b/vendors/knockout/build/fragments/source-references.js @@ -24,7 +24,7 @@ knockoutDebugCallback([ 'src/binding/bindingAttributeSyntax.js', 'src/components/loaderRegistry.js', 'src/components/defaultLoader.js', - 'src/components/customElements.js', +// 'src/components/customElements.js', 'src/components/componentBinding.js', 'src/binding/defaultBindings/attr.js', // 'src/binding/defaultBindings/checked.js', diff --git a/vendors/knockout/build/output/knockout-latest.debug.js b/vendors/knockout/build/output/knockout-latest.debug.js index 76370956c..2e1431309 100644 --- a/vendors/knockout/build/output/knockout-latest.debug.js +++ b/vendors/knockout/build/output/knockout-latest.debug.js @@ -32,187 +32,159 @@ ko.exportProperty = (owner, publicName, object) => owner[publicName] = object; ko.version = "3.5.1-sm"; ko.exportSymbol('version', ko.version); -ko.utils = (() => { +ko.utils = { + arrayRemoveItem: (array, itemToRemove) => { + var index = array.indexOf(itemToRemove); + if (index > 0) { + array.splice(index, 1); + } + else if (index === 0) { + array.shift(); + } + }, - const - arrayCall = (name, arr, p1, p2) => Array.prototype[name].call(arr, p1, p2), - objectForEach = (obj, action) => obj && Object.entries(obj).forEach(prop => action(prop[0], prop[1])), - extend = (target, source) => { - source && Object.entries(source).forEach(prop => target[prop[0]] = prop[1]); - return target; - }, - // For details on the pattern for changing node classes - // see: https://github.com/knockout/knockout/issues/1597 - toggleDomNodeCssClass = (node, classNames, shouldHaveClass) => { - if (classNames) { - var addOrRemoveFn = shouldHaveClass ? 'add' : 'remove'; - classNames.split(/\s+/).forEach(className => - node.classList[addOrRemoveFn](className) - ); - } - }; + extend: (target, source) => { + source && Object.entries(source).forEach(prop => target[prop[0]] = prop[1]); + return target; + }, - return { - arrayRemoveItem: (array, itemToRemove) => { - var index = array.indexOf(itemToRemove); - if (index > 0) { - array.splice(index, 1); - } - else if (index === 0) { - array.shift(); - } - }, + objectForEach: (obj, action) => obj && Object.entries(obj).forEach(prop => action(prop[0], prop[1])), - extend: extend, + objectMap: (source, mapping, mappingOwner) => { + if (!source) + return source; + var target = {}; + Object.entries(source).forEach(prop => + target[prop[0]] = mapping.call(mappingOwner, prop[1], prop[0], source) + ); + return target; + }, - objectForEach: objectForEach, + emptyDomNode: domNode => { + while (domNode.firstChild) { + ko.removeNode(domNode.firstChild); + } + }, - objectMap: (source, mapping, mappingOwner) => { - if (!source) - return source; - var target = {}; - Object.entries(source).forEach(prop => - target[prop[0]] = mapping.call(mappingOwner, prop[1], prop[0], source) - ); - return target; - }, + moveCleanedNodesToContainerElement: nodes => { + // Ensure it's a real array, as we're about to reparent the nodes and + // we don't want the underlying collection to change while we're doing that. + var nodesArray = [...nodes]; + var templateDocument = (nodesArray[0] && nodesArray[0].ownerDocument) || document; - emptyDomNode: domNode => { - while (domNode.firstChild) { - ko.removeNode(domNode.firstChild); - } - }, + var container = templateDocument.createElement('div'); + nodes.forEach(node => container.append(ko.cleanNode(node))); + return container; + }, - moveCleanedNodesToContainerElement: nodes => { - // Ensure it's a real array, as we're about to reparent the nodes and - // we don't want the underlying collection to change while we're doing that. - var nodesArray = [...nodes]; - var templateDocument = (nodesArray[0] && nodesArray[0].ownerDocument) || document; + cloneNodes: (nodesArray, shouldCleanNodes) => + Array.prototype.map.call(nodesArray, shouldCleanNodes + ? node => ko.cleanNode(node.cloneNode(true)) + : node => node.cloneNode(true)), - var container = templateDocument.createElement('div'); - nodes.forEach(node => container.append(ko.cleanNode(node))); - return container; - }, + setDomNodeChildren: (domNode, childNodes) => { + ko.utils.emptyDomNode(domNode); + childNodes && domNode.append(...childNodes); + }, - cloneNodes: (nodesArray, shouldCleanNodes) => - arrayCall('map', nodesArray, shouldCleanNodes - ? node => ko.cleanNode(node.cloneNode(true)) - : node => node.cloneNode(true) - ), + fixUpContinuousNodeArray: (continuousNodeArray, parentNode) => { + // Before acting on a set of nodes that were previously outputted by a template function, we have to reconcile + // them against what is in the DOM right now. It may be that some of the nodes have already been removed, or that + // new nodes might have been inserted in the middle, for example by a binding. Also, there may previously have been + // leading comment nodes (created by rewritten string-based templates) that have since been removed during binding. + // So, this function translates the old "map" output array into its best guess of the set of current DOM nodes. + // + // Rules: + // [A] Any leading nodes that have been removed should be ignored + // These most likely correspond to memoization nodes that were already removed during binding + // See https://github.com/knockout/knockout/pull/440 + // [B] Any trailing nodes that have been remove should be ignored + // This prevents the code here from adding unrelated nodes to the array while processing rule [C] + // See https://github.com/knockout/knockout/pull/1903 + // [C] We want to output a continuous series of nodes. So, ignore any nodes that have already been removed, + // and include any nodes that have been inserted among the previous collection - setDomNodeChildren: (domNode, childNodes) => { - ko.utils.emptyDomNode(domNode); - childNodes && domNode.append.apply(domNode, childNodes); - }, + if (continuousNodeArray.length) { + // The parent node can be a virtual element; so get the real parent node + parentNode = (parentNode.nodeType === 8 && parentNode.parentNode) || parentNode; - fixUpContinuousNodeArray: (continuousNodeArray, parentNode) => { - // Before acting on a set of nodes that were previously outputted by a template function, we have to reconcile - // them against what is in the DOM right now. It may be that some of the nodes have already been removed, or that - // new nodes might have been inserted in the middle, for example by a binding. Also, there may previously have been - // leading comment nodes (created by rewritten string-based templates) that have since been removed during binding. - // So, this function translates the old "map" output array into its best guess of the set of current DOM nodes. - // - // Rules: - // [A] Any leading nodes that have been removed should be ignored - // These most likely correspond to memoization nodes that were already removed during binding - // See https://github.com/knockout/knockout/pull/440 - // [B] Any trailing nodes that have been remove should be ignored - // This prevents the code here from adding unrelated nodes to the array while processing rule [C] - // See https://github.com/knockout/knockout/pull/1903 - // [C] We want to output a continuous series of nodes. So, ignore any nodes that have already been removed, - // and include any nodes that have been inserted among the previous collection + // Rule [A] + while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) + continuousNodeArray.splice(0, 1); - if (continuousNodeArray.length) { - // The parent node can be a virtual element; so get the real parent node - parentNode = (parentNode.nodeType === 8 && parentNode.parentNode) || parentNode; + // Rule [B] + while (continuousNodeArray.length > 1 + && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode) + continuousNodeArray.length--; - // Rule [A] - while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) - continuousNodeArray.splice(0, 1); - - // Rule [B] - while (continuousNodeArray.length > 1 - && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode) - continuousNodeArray.length--; - - // Rule [C] - if (continuousNodeArray.length > 1) { - var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1]; - // Replace with the actual new continuous node set - continuousNodeArray.length = 0; - while (current !== last) { - continuousNodeArray.push(current); - current = current.nextSibling; - } - continuousNodeArray.push(last); + // Rule [C] + if (continuousNodeArray.length > 1) { + var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1]; + // Replace with the actual new continuous node set + continuousNodeArray.length = 0; + while (current !== last) { + continuousNodeArray.push(current); + current = current.nextSibling; } + continuousNodeArray.push(last); } - return continuousNodeArray; - }, + } + return continuousNodeArray; + }, - stringTrim: string => string == null ? '' : - string.trim ? - string.trim() : - string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, ''), + stringTrim: string => string == null ? '' : + string.trim ? + string.trim() : + string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, ''), - stringStartsWith: (string, startsWith) => { - string = string || ""; - if (startsWith.length > string.length) - return false; - return string.substring(0, startsWith.length) === startsWith; - }, + stringStartsWith: (string, startsWith) => { + string = string || ""; + if (startsWith.length > string.length) + return false; + return string.substring(0, startsWith.length) === startsWith; + }, - domNodeIsContainedBy: (node, containedByNode) => - containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node), + domNodeIsContainedBy: (node, containedByNode) => + containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node), - domNodeIsAttachedToDocument: node => ko.utils.domNodeIsContainedBy(node, node.ownerDocument.documentElement), + domNodeIsAttachedToDocument: node => ko.utils.domNodeIsContainedBy(node, node.ownerDocument.documentElement), - // For HTML elements, tagName will always be upper case; for XHTML elements, it'll be lower case. - // Possible future optimization: If we know it's an element from an XHTML document (not HTML), - // we don't need to do the .toLowerCase() as it will always be lower case anyway. - tagNameLower: element => element && element.tagName && element.tagName.toLowerCase(), + catchFunctionErrors: delegate => { + return ko['onError'] ? function () { + try { + return delegate.apply(this, arguments); + } catch (e) { + ko['onError'] && ko['onError'](e); + throw e; + } + } : delegate; + }, - catchFunctionErrors: delegate => { - return ko['onError'] ? function () { - try { - return delegate.apply(this, arguments); - } catch (e) { - ko['onError'] && ko['onError'](e); - throw e; - } - } : delegate; - }, + setTimeout: (handler, timeout) => setTimeout(ko.utils.catchFunctionErrors(handler), timeout), - setTimeout: (handler, timeout) => setTimeout(ko.utils.catchFunctionErrors(handler), timeout), + deferError: error => setTimeout(() => { + ko['onError'] && ko['onError'](error); + throw error; + }, 0), - deferError: error => setTimeout(() => { - ko['onError'] && ko['onError'](error); - throw error; - }, 0), + registerEventHandler: (element, eventType, handler) => { + var wrappedHandler = ko.utils.catchFunctionErrors(handler); - registerEventHandler: (element, eventType, handler) => { - var wrappedHandler = ko.utils.catchFunctionErrors(handler); + element.addEventListener(eventType, wrappedHandler, false); + }, - element.addEventListener(eventType, wrappedHandler, false); - }, + triggerEvent: (element, eventType) => { + if (!(element && element.nodeType)) + throw new Error("element must be a DOM node when calling triggerEvent"); - triggerEvent: (element, eventType) => { - if (!(element && element.nodeType)) - throw new Error("element must be a DOM node when calling triggerEvent"); + element.dispatchEvent(new Event(eventType)); + }, - element.dispatchEvent(new Event(eventType)); - }, + unwrapObservable: value => ko.isObservable(value) ? value() : value, - unwrapObservable: value => ko.isObservable(value) ? value() : value, - - peekObservable: value => ko.isObservable(value) ? value.peek() : value, - - toggleDomNodeCssClass: toggleDomNodeCssClass, - - setTextContent: (element, textContent) => - element.textContent = ko.utils.unwrapObservable(textContent) || "" - } -})(); + setTextContent: (element, textContent) => + element.textContent = ko.utils.unwrapObservable(textContent) || "" +}; ko.exportSymbol('utils', ko.utils); ko.exportSymbol('unwrap', ko.utils.unwrapObservable); // Convenient shorthand, because this is used so commonly @@ -1659,12 +1631,12 @@ ko.pureComputed = (evaluatorFunctionOrOptions, evaluatorFunctionTarget) => { // that are arbitrary objects. This is very convenient when implementing things like cascading dropdowns. ko.selectExtensions = { readValue : element => { - switch (ko.utils.tagNameLower(element)) { - case 'option': + switch (element.nodeName) { + case 'OPTION': if (element[hasDomDataExpandoProperty] === true) return ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey); return element.value; - case 'select': + case 'SELECT': return element.selectedIndex >= 0 ? ko.selectExtensions.readValue(element.options[element.selectedIndex]) : undefined; default: return element.value; @@ -1672,8 +1644,8 @@ ko.pureComputed = (evaluatorFunctionOrOptions, evaluatorFunctionTarget) => { }, writeValue: (element, value, allowUnset) => { - switch (ko.utils.tagNameLower(element)) { - case 'option': + switch (element.nodeName) { + case 'OPTION': if (typeof value === "string") { ko.utils.domData.set(element, ko.bindingHandlers.options.optionValueDomDataKey, undefined); delete element[hasDomDataExpandoProperty]; @@ -1688,7 +1660,7 @@ ko.pureComputed = (evaluatorFunctionOrOptions, evaluatorFunctionTarget) => { element.value = typeof value === "number" ? value : ""; } break; - case 'select': + case 'SELECT': if (value === "" || value === null) // A blank string or null value will select the caption value = undefined; var selection = -1; @@ -2058,8 +2030,7 @@ ko.expressionRewriting = (() => { 'nodeHasBindings': node => { switch (node.nodeType) { case 1: // Element - return node.getAttribute(defaultBindingAttributeName) != null - || ko.components['getComponentNameForNode'](node); + return node.getAttribute(defaultBindingAttributeName) != null; case 8: // Comment node return ko.virtualElements.hasBindingValue(node); default: return false; @@ -2067,15 +2038,13 @@ ko.expressionRewriting = (() => { }, 'getBindings': function(node, bindingContext) { - var bindingsString = this['getBindingsString'](node, bindingContext), - parsedBindings = bindingsString ? this['parseBindingsString'](bindingsString, bindingContext, node) : null; - return ko.components.addBindingsForCustomElement(parsedBindings, node, bindingContext, /* valueAccessors */ false); + var bindingsString = this['getBindingsString'](node, bindingContext); + return bindingsString ? this['parseBindingsString'](bindingsString, bindingContext, node) : null; }, 'getBindingAccessors': function(node, bindingContext) { - var bindingsString = this['getBindingsString'](node, bindingContext), - parsedBindings = bindingsString ? this['parseBindingsString'](bindingsString, bindingContext, node, { 'valueAccessors': true }) : null; - return ko.components.addBindingsForCustomElement(parsedBindings, node, bindingContext, /* valueAccessors */ true); + var bindingsString = this['getBindingsString'](node, bindingContext); + return bindingsString ? this['parseBindingsString'](bindingsString, bindingContext, node, { 'valueAccessors': true }) : null; }, // The following function is only used internally by this default provider. @@ -2126,18 +2095,6 @@ ko.expressionRewriting = (() => { ko.bindingHandlers = {}; - // The following element types will not be recursed into during binding. - var bindingDoesNotRecurseIntoElementTypes = { - // Don't want bindings that operate on text nodes to mutate