Refactor: messageBox

This commit is contained in:
eight 2017-11-09 09:09:27 +08:00
parent f070d7ff8e
commit 137198e951

View File

@ -69,21 +69,12 @@ function messageBox({
onclick: messageBox.listeners.closeIcon}),
$element({id: `${id}-contents`, appendChild: tHTML(contents)}),
$element({id: `${id}-buttons`, appendChild:
buttons.map((textContent, buttonIndex) => {
if (!textContent) {
return;
}
let onclick = messageBox.listeners.button;
if (typeof textContent === 'object') {
({onclick = onclick, textContent} = textContent);
}
return $element({
tag: 'button',
buttonIndex,
textContent,
onclick,
});
})
buttons.map((content, buttonIndex) => content && $element({
tag: 'button',
buttonIndex,
textContent: content.textContent || content,
onclick: content.onclick || messageBox.listeners.button,
}))
}),
]}),
]});