mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +03:00
Dropped more unused knockoutjs code
This commit is contained in:
parent
b79d9de1a0
commit
1d57a62ddd
14 changed files with 408 additions and 635 deletions
|
|
@ -6,18 +6,6 @@
|
|||
|
||||
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 <script> and <textarea> contents,
|
||||
// because it's unexpected and a potential XSS issue.
|
||||
// Also bindings should not operate on <template> elements since this breaks in Internet Explorer
|
||||
// and because such elements' contents are always intended to be bound in a different context
|
||||
// from where they appear in the document.
|
||||
'script': true,
|
||||
'textarea': true,
|
||||
'template': true
|
||||
};
|
||||
|
||||
// Use an overridable method for retrieving binding handlers so that plugins may support dynamically created handlers
|
||||
ko['getBindingHandler'] = bindingKey => ko.bindingHandlers[bindingKey];
|
||||
|
||||
|
|
@ -326,7 +314,12 @@
|
|||
if (shouldApplyBindings)
|
||||
bindingContextForDescendants = applyBindingsToNodeInternal(nodeVerified, null, bindingContext)['bindingContextForDescendants'];
|
||||
|
||||
if (bindingContextForDescendants && !bindingDoesNotRecurseIntoElementTypes[ko.utils.tagNameLower(nodeVerified)]) {
|
||||
// Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,
|
||||
// because it's unexpected and a potential XSS issue.
|
||||
// Also bindings should not operate on <template> elements since this breaks in Internet Explorer
|
||||
// and because such elements' contents are always intended to be bound in a different context
|
||||
// from where they appear in the document.
|
||||
if (bindingContextForDescendants && nodeVerified.matches && !nodeVerified.matches('SCRIPT,TEXTAREA,TEMPLATE')) {
|
||||
applyBindingsToDescendantsInternal(bindingContextForDescendants, nodeVerified);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
vendors/knockout/src/binding/bindingProvider.js
vendored
13
vendors/knockout/src/binding/bindingProvider.js
vendored
|
|
@ -9,8 +9,7 @@
|
|||
'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;
|
||||
|
|
@ -18,15 +17,13 @@
|
|||
},
|
||||
|
||||
'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.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
var classesWrittenByBindingKey = '__ko__cssValue';
|
||||
var classesWrittenByBindingKey = '__ko__cssValue',
|
||||
toggleClasses = (node, classNames, force) => {
|
||||
if (classNames) {
|
||||
classNames.split(/\s+/).forEach(className =>
|
||||
node.classList.toggle(className, force)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers['css'] = {
|
||||
'update': (element, valueAccessor) => {
|
||||
|
|
@ -6,13 +13,13 @@ ko.bindingHandlers['css'] = {
|
|||
if (value !== null && typeof value == "object") {
|
||||
ko.utils.objectForEach(value, (className, shouldHaveClass) => {
|
||||
shouldHaveClass = ko.utils.unwrapObservable(shouldHaveClass);
|
||||
ko.utils.toggleDomNodeCssClass(element, className, shouldHaveClass);
|
||||
toggleClasses(element, className, !!shouldHaveClass);
|
||||
});
|
||||
} else {
|
||||
value = ko.utils.stringTrim(value);
|
||||
ko.utils.toggleDomNodeCssClass(element, element[classesWrittenByBindingKey], false);
|
||||
toggleClasses(element, element[classesWrittenByBindingKey], false);
|
||||
element[classesWrittenByBindingKey] = value;
|
||||
ko.utils.toggleDomNodeCssClass(element, value, true);
|
||||
toggleClasses(element, value, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ ko.bindingHandlers['foreach'] = {
|
|||
makeTemplateValueAccessor: valueAccessor => {
|
||||
return () => {
|
||||
var modelValue = valueAccessor(),
|
||||
unwrappedValue = ko.utils.peekObservable(modelValue); // Unwrap without setting a dependency here
|
||||
// Unwrap without setting a dependency here
|
||||
unwrappedValue = ko.isObservable(modelValue) ? modelValue.peek() : modelValue;
|
||||
|
||||
// If unwrappedValue is the array, pass in the wrapped value on its own
|
||||
// The value will be unwrapped and tracked within the template binding
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var captionPlaceholder = {};
|
||||
ko.bindingHandlers['options'] = {
|
||||
'init': element => {
|
||||
if (ko.utils.tagNameLower(element) !== "select")
|
||||
if (!element.matches("SELECT"))
|
||||
throw new Error("options binding applies only to SELECT elements");
|
||||
|
||||
// Remove all existing <option>s.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
ko.bindingHandlers['value'] = {
|
||||
'init': (element, valueAccessor, allBindings) => {
|
||||
var tagName = ko.utils.tagNameLower(element),
|
||||
isInputElement = tagName == "input";
|
||||
var isSelectElement = element.matches("SELECT"),
|
||||
isInputElement = element.matches("INPUT");
|
||||
|
||||
// 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")) {
|
||||
|
|
@ -79,7 +79,7 @@ ko.bindingHandlers['value'] = {
|
|||
var valueHasChanged = newValue !== elementValue;
|
||||
|
||||
if (valueHasChanged || elementValue === undefined) {
|
||||
if (tagName === "select") {
|
||||
if (isSelectElement) {
|
||||
var allowUnset = allBindings.get('valueAllowUnset');
|
||||
ko.selectExtensions.writeValue(element, newValue, allowUnset);
|
||||
if (!allowUnset && newValue !== ko.selectExtensions.readValue(element)) {
|
||||
|
|
@ -94,7 +94,7 @@ ko.bindingHandlers['value'] = {
|
|||
};
|
||||
}
|
||||
|
||||
if (tagName === "select") {
|
||||
if (isSelectElement) {
|
||||
var updateFromModelComputed;
|
||||
ko.bindingEvent.subscribe(element, ko.bindingEvent.childrenComplete, () => {
|
||||
if (!updateFromModelComputed) {
|
||||
|
|
|
|||
12
vendors/knockout/src/binding/selectExtensions.js
vendored
12
vendors/knockout/src/binding/selectExtensions.js
vendored
|
|
@ -6,12 +6,12 @@
|
|||
// 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;
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
},
|
||||
|
||||
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];
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue