mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 14:37:02 +03:00
Cleanup KnockoutJS a bit
This commit is contained in:
parent
4cd5774257
commit
bc6a2b67c0
4 changed files with 55 additions and 65 deletions
|
|
@ -9,7 +9,7 @@ ko.selectExtensions = {
|
|||
switch (element.nodeName) {
|
||||
case 'OPTION':
|
||||
return (element[hasDomDataExpandoProperty] === true)
|
||||
? ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey)
|
||||
? ko.utils.domData.get(element, ko.bindingHandlers['options'].optionValueDomDataKey)
|
||||
: element.value;
|
||||
case 'SELECT':
|
||||
return element.selectedIndex >= 0
|
||||
|
|
@ -24,13 +24,13 @@ ko.selectExtensions = {
|
|||
switch (element.nodeName) {
|
||||
case 'OPTION':
|
||||
if (typeof value === "string") {
|
||||
ko.utils.domData.set(element, ko.bindingHandlers.options.optionValueDomDataKey, undefined);
|
||||
ko.utils.domData.set(element, ko.bindingHandlers['options'].optionValueDomDataKey, undefined);
|
||||
delete element[hasDomDataExpandoProperty];
|
||||
element.value = value;
|
||||
}
|
||||
else {
|
||||
// Store arbitrary object using DomData
|
||||
ko.utils.domData.set(element, ko.bindingHandlers.options.optionValueDomDataKey, value);
|
||||
ko.utils.domData.set(element, ko.bindingHandlers['options'].optionValueDomDataKey, value);
|
||||
element[hasDomDataExpandoProperty] = true;
|
||||
|
||||
// Special treatment of numbers is just for backward compatibility. KO 1.2.1 wrote numerical values to element.value.
|
||||
|
|
|
|||
|
|
@ -5,16 +5,11 @@
|
|||
'init': (element, valueAccessor, ignored1, ignored2, bindingContext) => {
|
||||
var currentViewModel,
|
||||
currentLoadingOperationId,
|
||||
afterRenderSub,
|
||||
disposeAssociatedComponentViewModel = () => {
|
||||
var currentViewModelDispose = currentViewModel && currentViewModel['dispose'];
|
||||
if (typeof currentViewModelDispose === 'function') {
|
||||
currentViewModelDispose.call(currentViewModel);
|
||||
}
|
||||
if (afterRenderSub) {
|
||||
afterRenderSub['dispose']();
|
||||
}
|
||||
afterRenderSub = null;
|
||||
currentViewModel = null;
|
||||
// Any in-flight loading operation is no longer relevant, so make sure we ignore its completion
|
||||
currentLoadingOperationId = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue