Replace babel command decorators with proper knockout command decorators

This commit is contained in:
djmaze 2021-02-19 12:09:20 +01:00
parent b6d8fa5b3f
commit 540b12ed26
27 changed files with 181 additions and 132 deletions

15
dev/External/ko.js vendored
View file

@ -86,23 +86,10 @@ ko.bindingHandlers.command = {
init: (element, fValueAccessor, fAllBindingsAccessor, viewModel, bindingContext) => {
const command = fValueAccessor();
if (!command || !command.isCommand) {
if (!command || !command.enabled || !command.canExecute) {
throw new Error('Value should be a command');
}
if (!command.enabled) {
command.enabled = ko.observable(true);
}
if (!command.canExecute) {
const __realCanExecute = command.__realCanExecute;
if (isFunction(__realCanExecute)) {
command.canExecute = ko.computed(() => command.enabled() && __realCanExecute.call(viewModel, viewModel));
} else {
command.canExecute = ko.computed(() => command.enabled() && !!__realCanExecute);
}
}
element.classList.add('command');
ko.bindingHandlers['FORM'==element.nodeName ? 'submit' : 'click'].init(
element,