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}), onclick: messageBox.listeners.closeIcon}),
$element({id: `${id}-contents`, appendChild: tHTML(contents)}), $element({id: `${id}-contents`, appendChild: tHTML(contents)}),
$element({id: `${id}-buttons`, appendChild: $element({id: `${id}-buttons`, appendChild:
buttons.map((textContent, buttonIndex) => { buttons.map((content, buttonIndex) => content && $element({
if (!textContent) { tag: 'button',
return; buttonIndex,
} textContent: content.textContent || content,
let onclick = messageBox.listeners.button; onclick: content.onclick || messageBox.listeners.button,
if (typeof textContent === 'object') { }))
({onclick = onclick, textContent} = textContent);
}
return $element({
tag: 'button',
buttonIndex,
textContent,
onclick,
});
})
}), }),
]}), ]}),
]}); ]});