mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
new Error to Error
This commit is contained in:
parent
870019d2df
commit
644c8ad389
13 changed files with 44 additions and 44 deletions
|
|
@ -110,7 +110,7 @@ ko.utils = {
|
||||||
|
|
||||||
triggerEvent: (element, eventType) => {
|
triggerEvent: (element, eventType) => {
|
||||||
if (!element?.nodeType)
|
if (!element?.nodeType)
|
||||||
throw new Error("element must be a DOM node when calling triggerEvent");
|
throw Error("element must be a DOM node when calling triggerEvent");
|
||||||
|
|
||||||
element.dispatchEvent(new Event(eventType));
|
element.dispatchEvent(new Event(eventType));
|
||||||
},
|
},
|
||||||
|
|
@ -197,7 +197,7 @@ ko.utils.domNodeDisposal = (() => {
|
||||||
return {
|
return {
|
||||||
'addDisposeCallback' : (node, callback) => {
|
'addDisposeCallback' : (node, callback) => {
|
||||||
if (typeof callback != "function")
|
if (typeof callback != "function")
|
||||||
throw new Error("Callback must be a function");
|
throw Error("Callback must be a function");
|
||||||
getDisposeCallbacksCollection(node, 1).add(callback);
|
getDisposeCallbacksCollection(node, 1).add(callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -482,7 +482,7 @@ ko.dependencyDetection = {
|
||||||
registerDependency: subscribable => {
|
registerDependency: subscribable => {
|
||||||
if (currentFrame) {
|
if (currentFrame) {
|
||||||
if (!ko.isSubscribable(subscribable))
|
if (!ko.isSubscribable(subscribable))
|
||||||
throw new Error("Only subscribable things can act as dependencies");
|
throw Error("Only subscribable things can act as dependencies");
|
||||||
currentFrame.callback.call(currentFrame.callbackTarget, subscribable,
|
currentFrame.callback.call(currentFrame.callbackTarget, subscribable,
|
||||||
subscribable._id || (subscribable._id = ++lastId));
|
subscribable._id || (subscribable._id = ++lastId));
|
||||||
}
|
}
|
||||||
|
|
@ -585,7 +585,7 @@ ko['observableArray'] = initialValues => {
|
||||||
initialValues = initialValues || [];
|
initialValues = initialValues || [];
|
||||||
|
|
||||||
if (!Array.isArray(initialValues))
|
if (!Array.isArray(initialValues))
|
||||||
throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
|
throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
|
||||||
|
|
||||||
return Object.setPrototypeOf(ko.observable(initialValues), ko['observableArray']['fn']).extend({'trackArrayChanges':true});
|
return Object.setPrototypeOf(ko.observable(initialValues), ko['observableArray']['fn']).extend({'trackArrayChanges':true});
|
||||||
};
|
};
|
||||||
|
|
@ -831,7 +831,7 @@ ko.computed = (evaluatorFunctionOrOptions, options) => {
|
||||||
function computedObservable() {
|
function computedObservable() {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
if (typeof writeFunction !== "function") {
|
if (typeof writeFunction !== "function") {
|
||||||
throw new Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
|
throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
|
||||||
}
|
}
|
||||||
// Writing a value
|
// Writing a value
|
||||||
writeFunction(...arguments);
|
writeFunction(...arguments);
|
||||||
|
|
@ -1520,7 +1520,7 @@ ko.expressionRewriting = (() => {
|
||||||
++depth;
|
++depth;
|
||||||
}
|
}
|
||||||
if (!allowUnbalanced)
|
if (!allowUnbalanced)
|
||||||
throw new Error("Cannot find closing comment tag to match: " + startComment.nodeValue);
|
throw Error("Cannot find closing comment tag to match: " + startComment.nodeValue);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1575,7 +1575,7 @@ ko.expressionRewriting = (() => {
|
||||||
}
|
}
|
||||||
let first = node.firstChild;
|
let first = node.firstChild;
|
||||||
if (first && isEndComment(first)) {
|
if (first && isEndComment(first)) {
|
||||||
throw new Error("Found invalid end comment, as the first child of " + node);
|
throw Error("Found invalid end comment, as the first child of " + node);
|
||||||
}
|
}
|
||||||
return first;
|
return first;
|
||||||
},
|
},
|
||||||
|
|
@ -1843,7 +1843,7 @@ ko.bindingEvent = {
|
||||||
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable?.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
|
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable?.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
|
||||||
// It's currently an error to register a descendantsComplete handler for a node that was never registered as completing asynchronously.
|
// It's currently an error to register a descendantsComplete handler for a node that was never registered as completing asynchronously.
|
||||||
// That's because without the asyncContext, we don't have a way to know that all descendants have completed.
|
// That's because without the asyncContext, we don't have a way to know that all descendants have completed.
|
||||||
throw new Error("descendantsComplete event not supported for bindings on this node");
|
throw Error("descendantsComplete event not supported for bindings on this node");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2021,7 +2021,7 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext) {
|
||||||
|
|
||||||
// COMMENT_NODE
|
// COMMENT_NODE
|
||||||
if (node.nodeType === 8 && !ko.virtualElements.allowedBindings[bindingKey]) {
|
if (node.nodeType === 8 && !ko.virtualElements.allowedBindings[bindingKey]) {
|
||||||
throw new Error("The binding '" + bindingKey + "' cannot be used with comment nodes");
|
throw Error("The binding '" + bindingKey + "' cannot be used with comment nodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -2033,7 +2033,7 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext) {
|
||||||
// If this binding handler claims to control descendant bindings, make a note of this
|
// If this binding handler claims to control descendant bindings, make a note of this
|
||||||
if (initResult && initResult['controlsDescendantBindings']) {
|
if (initResult && initResult['controlsDescendantBindings']) {
|
||||||
if (bindingHandlerThatControlsDescendantBindings !== undefined)
|
if (bindingHandlerThatControlsDescendantBindings !== undefined)
|
||||||
throw new Error("Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + bindingKey + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
|
throw Error("Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + bindingKey + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
|
||||||
bindingHandlerThatControlsDescendantBindings = bindingKey;
|
bindingHandlerThatControlsDescendantBindings = bindingKey;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -2133,11 +2133,11 @@ ko.exportSymbol('applyBindings', ko.applyBindings);
|
||||||
|
|
||||||
'register': (componentName, config) => {
|
'register': (componentName, config) => {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
throw new Error('Invalid configuration for ' + componentName);
|
throw Error('Invalid configuration for ' + componentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultConfigRegistry[componentName]) {
|
if (defaultConfigRegistry[componentName]) {
|
||||||
throw new Error('Component ' + componentName + ' is already registered');
|
throw Error('Component ' + componentName + ' is already registered');
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfigRegistry[componentName] = config;
|
defaultConfigRegistry[componentName] = config;
|
||||||
|
|
@ -2156,7 +2156,7 @@ ko.exportSymbol('applyBindings', ko.applyBindings);
|
||||||
|
|
||||||
var defaultConfigRegistry = Object.create(null),
|
var defaultConfigRegistry = Object.create(null),
|
||||||
createViewModelKey = 'createViewModel',
|
createViewModelKey = 'createViewModel',
|
||||||
throwError = (componentName, message) => { throw new Error(`Component '${componentName}': ${message}`) },
|
throwError = (componentName, message) => { throw Error(`Component '${componentName}': ${message}`) },
|
||||||
|
|
||||||
// Takes a config object of the form { template: ..., viewModel: ... }, and asynchronously convert it
|
// Takes a config object of the form { template: ..., viewModel: ... }, and asynchronously convert it
|
||||||
// into the standard component definition format:
|
// into the standard component definition format:
|
||||||
|
|
@ -2237,7 +2237,7 @@ ko.exportSymbol('applyBindings', ko.applyBindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!componentName) {
|
if (!componentName) {
|
||||||
throw new Error('No component name specified');
|
throw Error('No component name specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
var asyncContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);
|
var asyncContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);
|
||||||
|
|
@ -2251,12 +2251,12 @@ ko.exportSymbol('applyBindings', ko.applyBindings);
|
||||||
|
|
||||||
// Instantiate and bind new component. Implicitly this cleans any old DOM nodes.
|
// Instantiate and bind new component. Implicitly this cleans any old DOM nodes.
|
||||||
if (!componentDefinition) {
|
if (!componentDefinition) {
|
||||||
throw new Error('Unknown component \'' + componentName + '\'');
|
throw Error('Unknown component \'' + componentName + '\'');
|
||||||
}
|
}
|
||||||
// cloneTemplateIntoElement
|
// cloneTemplateIntoElement
|
||||||
var template = componentDefinition['template'];
|
var template = componentDefinition['template'];
|
||||||
if (!template) {
|
if (!template) {
|
||||||
throw new Error('Component \'' + componentName + '\' has no template');
|
throw Error('Component \'' + componentName + '\' has no template');
|
||||||
}
|
}
|
||||||
ko.virtualElements.setDomNodeChildren(element, ko.utils.cloneNodes(template));
|
ko.virtualElements.setDomNodeChildren(element, ko.utils.cloneNodes(template));
|
||||||
|
|
||||||
|
|
@ -2642,7 +2642,7 @@ var captionPlaceholder = {};
|
||||||
ko.bindingHandlers['options'] = {
|
ko.bindingHandlers['options'] = {
|
||||||
'init': element => {
|
'init': element => {
|
||||||
if (!element.matches("SELECT"))
|
if (!element.matches("SELECT"))
|
||||||
throw new Error("options binding applies only to SELECT elements");
|
throw Error("options binding applies only to SELECT elements");
|
||||||
|
|
||||||
// Remove all existing <option>s.
|
// Remove all existing <option>s.
|
||||||
let l = element.length;
|
let l = element.length;
|
||||||
|
|
@ -2799,7 +2799,7 @@ ko.bindingHandlers['style'] = {
|
||||||
ko.bindingHandlers['submit'] = {
|
ko.bindingHandlers['submit'] = {
|
||||||
'init': (element, valueAccessor, allBindings, viewModel, bindingContext) => {
|
'init': (element, valueAccessor, allBindings, viewModel, bindingContext) => {
|
||||||
if (typeof valueAccessor() != "function")
|
if (typeof valueAccessor() != "function")
|
||||||
throw new Error("The value for a submit binding must be a function");
|
throw Error("The value for a submit binding must be a function");
|
||||||
element.addEventListener("submit", event => {
|
element.addEventListener("submit", event => {
|
||||||
var handlerReturnValue;
|
var handlerReturnValue;
|
||||||
var value = valueAccessor();
|
var value = valueAccessor();
|
||||||
|
|
@ -3079,14 +3079,14 @@ makeEventHandlerShortcut('click');
|
||||||
templateDocument = templateDocument || document;
|
templateDocument = templateDocument || document;
|
||||||
var elem = templateDocument.getElementById(template);
|
var elem = templateDocument.getElementById(template);
|
||||||
if (!elem)
|
if (!elem)
|
||||||
throw new Error("Cannot find template with ID " + template);
|
throw Error("Cannot find template with ID " + template);
|
||||||
return new ko.templateSources.domElement(elem);
|
return new ko.templateSources.domElement(elem);
|
||||||
}
|
}
|
||||||
if ([1,8].includes(template.nodeType)) {
|
if ([1,8].includes(template.nodeType)) {
|
||||||
// Anonymous template
|
// Anonymous template
|
||||||
return new ko.templateSources.anonymousTemplate(template);
|
return new ko.templateSources.anonymousTemplate(template);
|
||||||
}
|
}
|
||||||
throw new Error("Unknown template type: " + template);
|
throw Error("Unknown template type: " + template);
|
||||||
},
|
},
|
||||||
|
|
||||||
invokeForEachNodeInContinuousRange = (firstNode, lastNode, action) => {
|
invokeForEachNodeInContinuousRange = (firstNode, lastNode, action) => {
|
||||||
|
|
@ -3135,7 +3135,7 @@ makeEventHandlerShortcut('click');
|
||||||
|
|
||||||
// Loosely check result is an array of DOM nodes
|
// Loosely check result is an array of DOM nodes
|
||||||
if (!Array.isArray(renderedNodesArray) || (renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType != "number"))
|
if (!Array.isArray(renderedNodesArray) || (renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType != "number"))
|
||||||
throw new Error("Template engine must return an array of DOM nodes");
|
throw Error("Template engine must return an array of DOM nodes");
|
||||||
|
|
||||||
if (replaceChildren) {
|
if (replaceChildren) {
|
||||||
ko.virtualElements.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);
|
ko.virtualElements.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);
|
||||||
|
|
@ -3254,7 +3254,7 @@ makeEventHandlerShortcut('click');
|
||||||
let container = ko.utils.moveCleanedNodesToContainerElement(templateNodes); // This also removes the nodes from their current parent
|
let container = ko.utils.moveCleanedNodesToContainerElement(templateNodes); // This also removes the nodes from their current parent
|
||||||
new ko.templateSources.anonymousTemplate(element).nodes(container);
|
new ko.templateSources.anonymousTemplate(element).nodes(container);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Anonymous template defined, but no template content was provided");
|
throw Error("Anonymous template defined, but no template content was provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { 'controlsDescendantBindings': true };
|
return { 'controlsDescendantBindings': true };
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ ko.bindingEvent = {
|
||||||
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable?.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
|
} else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable?.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {
|
||||||
// It's currently an error to register a descendantsComplete handler for a node that was never registered as completing asynchronously.
|
// It's currently an error to register a descendantsComplete handler for a node that was never registered as completing asynchronously.
|
||||||
// That's because without the asyncContext, we don't have a way to know that all descendants have completed.
|
// That's because without the asyncContext, we don't have a way to know that all descendants have completed.
|
||||||
throw new Error("descendantsComplete event not supported for bindings on this node");
|
throw Error("descendantsComplete event not supported for bindings on this node");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -365,7 +365,7 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext) {
|
||||||
|
|
||||||
// COMMENT_NODE
|
// COMMENT_NODE
|
||||||
if (node.nodeType === 8 && !ko.virtualElements.allowedBindings[bindingKey]) {
|
if (node.nodeType === 8 && !ko.virtualElements.allowedBindings[bindingKey]) {
|
||||||
throw new Error("The binding '" + bindingKey + "' cannot be used with comment nodes");
|
throw Error("The binding '" + bindingKey + "' cannot be used with comment nodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -377,7 +377,7 @@ function applyBindingsToNodeInternal(node, sourceBindings, bindingContext) {
|
||||||
// If this binding handler claims to control descendant bindings, make a note of this
|
// If this binding handler claims to control descendant bindings, make a note of this
|
||||||
if (initResult && initResult['controlsDescendantBindings']) {
|
if (initResult && initResult['controlsDescendantBindings']) {
|
||||||
if (bindingHandlerThatControlsDescendantBindings !== undefined)
|
if (bindingHandlerThatControlsDescendantBindings !== undefined)
|
||||||
throw new Error("Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + bindingKey + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
|
throw Error("Multiple bindings (" + bindingHandlerThatControlsDescendantBindings + " and " + bindingKey + ") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");
|
||||||
bindingHandlerThatControlsDescendantBindings = bindingKey;
|
bindingHandlerThatControlsDescendantBindings = bindingKey;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ var captionPlaceholder = {};
|
||||||
ko.bindingHandlers['options'] = {
|
ko.bindingHandlers['options'] = {
|
||||||
'init': element => {
|
'init': element => {
|
||||||
if (!element.matches("SELECT"))
|
if (!element.matches("SELECT"))
|
||||||
throw new Error("options binding applies only to SELECT elements");
|
throw Error("options binding applies only to SELECT elements");
|
||||||
|
|
||||||
// Remove all existing <option>s.
|
// Remove all existing <option>s.
|
||||||
let l = element.length;
|
let l = element.length;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
ko.bindingHandlers['submit'] = {
|
ko.bindingHandlers['submit'] = {
|
||||||
'init': (element, valueAccessor, allBindings, viewModel, bindingContext) => {
|
'init': (element, valueAccessor, allBindings, viewModel, bindingContext) => {
|
||||||
if (typeof valueAccessor() != "function")
|
if (typeof valueAccessor() != "function")
|
||||||
throw new Error("The value for a submit binding must be a function");
|
throw Error("The value for a submit binding must be a function");
|
||||||
element.addEventListener("submit", event => {
|
element.addEventListener("submit", event => {
|
||||||
var handlerReturnValue;
|
var handlerReturnValue;
|
||||||
var value = valueAccessor();
|
var value = valueAccessor();
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!componentName) {
|
if (!componentName) {
|
||||||
throw new Error('No component name specified');
|
throw Error('No component name specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
var asyncContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);
|
var asyncContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);
|
||||||
|
|
@ -47,12 +47,12 @@
|
||||||
|
|
||||||
// Instantiate and bind new component. Implicitly this cleans any old DOM nodes.
|
// Instantiate and bind new component. Implicitly this cleans any old DOM nodes.
|
||||||
if (!componentDefinition) {
|
if (!componentDefinition) {
|
||||||
throw new Error('Unknown component \'' + componentName + '\'');
|
throw Error('Unknown component \'' + componentName + '\'');
|
||||||
}
|
}
|
||||||
// cloneTemplateIntoElement
|
// cloneTemplateIntoElement
|
||||||
var template = componentDefinition['template'];
|
var template = componentDefinition['template'];
|
||||||
if (!template) {
|
if (!template) {
|
||||||
throw new Error('Component \'' + componentName + '\' has no template');
|
throw Error('Component \'' + componentName + '\' has no template');
|
||||||
}
|
}
|
||||||
ko.virtualElements.setDomNodeChildren(element, ko.utils.cloneNodes(template));
|
ko.virtualElements.setDomNodeChildren(element, ko.utils.cloneNodes(template));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,11 @@
|
||||||
|
|
||||||
'register': (componentName, config) => {
|
'register': (componentName, config) => {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
throw new Error('Invalid configuration for ' + componentName);
|
throw Error('Invalid configuration for ' + componentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultConfigRegistry[componentName]) {
|
if (defaultConfigRegistry[componentName]) {
|
||||||
throw new Error('Component ' + componentName + ' is already registered');
|
throw Error('Component ' + componentName + ' is already registered');
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfigRegistry[componentName] = config;
|
defaultConfigRegistry[componentName] = config;
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
var defaultConfigRegistry = Object.create(null),
|
var defaultConfigRegistry = Object.create(null),
|
||||||
createViewModelKey = 'createViewModel',
|
createViewModelKey = 'createViewModel',
|
||||||
throwError = (componentName, message) => { throw new Error(`Component '${componentName}': ${message}`) },
|
throwError = (componentName, message) => { throw Error(`Component '${componentName}': ${message}`) },
|
||||||
|
|
||||||
// Takes a config object of the form { template: ..., viewModel: ... }, and asynchronously convert it
|
// Takes a config object of the form { template: ..., viewModel: ... }, and asynchronously convert it
|
||||||
// into the standard component definition format:
|
// into the standard component definition format:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ ko.dependencyDetection = {
|
||||||
registerDependency: subscribable => {
|
registerDependency: subscribable => {
|
||||||
if (currentFrame) {
|
if (currentFrame) {
|
||||||
if (!ko.isSubscribable(subscribable))
|
if (!ko.isSubscribable(subscribable))
|
||||||
throw new Error("Only subscribable things can act as dependencies");
|
throw Error("Only subscribable things can act as dependencies");
|
||||||
currentFrame.callback.call(currentFrame.callbackTarget, subscribable,
|
currentFrame.callback.call(currentFrame.callbackTarget, subscribable,
|
||||||
subscribable._id || (subscribable._id = ++lastId));
|
subscribable._id || (subscribable._id = ++lastId));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ ko.computed = (evaluatorFunctionOrOptions, options) => {
|
||||||
function computedObservable() {
|
function computedObservable() {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
if (typeof writeFunction !== "function") {
|
if (typeof writeFunction !== "function") {
|
||||||
throw new Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
|
throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");
|
||||||
}
|
}
|
||||||
// Writing a value
|
// Writing a value
|
||||||
writeFunction(...arguments);
|
writeFunction(...arguments);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ ko['observableArray'] = initialValues => {
|
||||||
initialValues = initialValues || [];
|
initialValues = initialValues || [];
|
||||||
|
|
||||||
if (!Array.isArray(initialValues))
|
if (!Array.isArray(initialValues))
|
||||||
throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
|
throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
|
||||||
|
|
||||||
return Object.setPrototypeOf(ko.observable(initialValues), ko['observableArray']['fn']).extend({'trackArrayChanges':true});
|
return Object.setPrototypeOf(ko.observable(initialValues), ko['observableArray']['fn']).extend({'trackArrayChanges':true});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@
|
||||||
templateDocument = templateDocument || document;
|
templateDocument = templateDocument || document;
|
||||||
var elem = templateDocument.getElementById(template);
|
var elem = templateDocument.getElementById(template);
|
||||||
if (!elem)
|
if (!elem)
|
||||||
throw new Error("Cannot find template with ID " + template);
|
throw Error("Cannot find template with ID " + template);
|
||||||
return new ko.templateSources.domElement(elem);
|
return new ko.templateSources.domElement(elem);
|
||||||
}
|
}
|
||||||
if ([1,8].includes(template.nodeType)) {
|
if ([1,8].includes(template.nodeType)) {
|
||||||
// Anonymous template
|
// Anonymous template
|
||||||
return new ko.templateSources.anonymousTemplate(template);
|
return new ko.templateSources.anonymousTemplate(template);
|
||||||
}
|
}
|
||||||
throw new Error("Unknown template type: " + template);
|
throw Error("Unknown template type: " + template);
|
||||||
},
|
},
|
||||||
|
|
||||||
invokeForEachNodeInContinuousRange = (firstNode, lastNode, action) => {
|
invokeForEachNodeInContinuousRange = (firstNode, lastNode, action) => {
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
// Loosely check result is an array of DOM nodes
|
// Loosely check result is an array of DOM nodes
|
||||||
if (!Array.isArray(renderedNodesArray) || (renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType != "number"))
|
if (!Array.isArray(renderedNodesArray) || (renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType != "number"))
|
||||||
throw new Error("Template engine must return an array of DOM nodes");
|
throw Error("Template engine must return an array of DOM nodes");
|
||||||
|
|
||||||
if (replaceChildren) {
|
if (replaceChildren) {
|
||||||
ko.virtualElements.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);
|
ko.virtualElements.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);
|
||||||
|
|
@ -187,7 +187,7 @@
|
||||||
let container = ko.utils.moveCleanedNodesToContainerElement(templateNodes); // This also removes the nodes from their current parent
|
let container = ko.utils.moveCleanedNodesToContainerElement(templateNodes); // This also removes the nodes from their current parent
|
||||||
new ko.templateSources.anonymousTemplate(element).nodes(container);
|
new ko.templateSources.anonymousTemplate(element).nodes(container);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Anonymous template defined, but no template content was provided");
|
throw Error("Anonymous template defined, but no template content was provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { 'controlsDescendantBindings': true };
|
return { 'controlsDescendantBindings': true };
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ ko.utils.domNodeDisposal = (() => {
|
||||||
return {
|
return {
|
||||||
'addDisposeCallback' : (node, callback) => {
|
'addDisposeCallback' : (node, callback) => {
|
||||||
if (typeof callback != "function")
|
if (typeof callback != "function")
|
||||||
throw new Error("Callback must be a function");
|
throw Error("Callback must be a function");
|
||||||
getDisposeCallbacksCollection(node, 1).add(callback);
|
getDisposeCallbacksCollection(node, 1).add(callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
2
vendors/knockout/src/utils.js
vendored
2
vendors/knockout/src/utils.js
vendored
|
|
@ -84,7 +84,7 @@ ko.utils = {
|
||||||
|
|
||||||
triggerEvent: (element, eventType) => {
|
triggerEvent: (element, eventType) => {
|
||||||
if (!element?.nodeType)
|
if (!element?.nodeType)
|
||||||
throw new Error("element must be a DOM node when calling triggerEvent");
|
throw Error("element must be a DOM node when calling triggerEvent");
|
||||||
|
|
||||||
element.dispatchEvent(new Event(eventType));
|
element.dispatchEvent(new Event(eventType));
|
||||||
},
|
},
|
||||||
|
|
|
||||||
4
vendors/knockout/src/virtualElements.js
vendored
4
vendors/knockout/src/virtualElements.js
vendored
|
|
@ -41,7 +41,7 @@
|
||||||
++depth;
|
++depth;
|
||||||
}
|
}
|
||||||
if (!allowUnbalanced)
|
if (!allowUnbalanced)
|
||||||
throw new Error("Cannot find closing comment tag to match: " + startComment.nodeValue);
|
throw Error("Cannot find closing comment tag to match: " + startComment.nodeValue);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
}
|
}
|
||||||
let first = node.firstChild;
|
let first = node.firstChild;
|
||||||
if (first && isEndComment(first)) {
|
if (first && isEndComment(first)) {
|
||||||
throw new Error("Found invalid end comment, as the first child of " + node);
|
throw Error("Found invalid end comment, as the first child of " + node);
|
||||||
}
|
}
|
||||||
return first;
|
return first;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue