Skip to content

Commit

Permalink
refactor: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
NateScarlet committed Mar 23, 2020
1 parent ff9e1a8 commit aafb6f8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/ts/toolbar/setToolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ export const disableToolbar = (toolbar: { [key: string]: HTMLElement }, names: s
};

const CLASS_DISABLED = 'vditor-menu--disabled'
function setEnabled(e: HTMLElement, v: boolean){
if(v){
e.classList.remove(CLASS_DISABLED)
} else {
e.classList.add(CLASS_DISABLED)
}
}

/**
* 设置工具栏内容启用/禁用状态。
Expand All @@ -67,7 +60,7 @@ export function setToolbarEnabled(
): void {
for (const [k, v] of Object.entries(toolbar)) {
if (!names || names.includes(k)) {
setEnabled(v, enabled);
v.classList.toggle(CLASS_DISABLED, !enabled);
}
}
}
Expand Down

0 comments on commit aafb6f8

Please sign in to comment.