onSelect can return a promise

This commit is contained in:
Harvey committed 2022-04-27 15:44:06 +08:00
1 parent ec6b439d39
commit f4ade95551
6 files changed
+904 -42

No files matched your search

+2 -2
View File
@@ -123,7 +123,7 @@ export default class Component {
hover($ref, setLeft);
proxy($list, 'click', (event) => {
proxy($list, 'click', async (event) => {
const path = event.composedPath() || [];
const $item = path.find((item) => hasClass(item, 'art-selector-item'));
if (!$item) return;
@@ -132,7 +132,7 @@ export default class Component {
const find = option.selector[index] || {};
$value.innerText = $item.innerText;
if (option.onSelect) {
const result = option.onSelect.call(this.art, find, $item, event);
const result = await option.onSelect.call(this.art, find, $item, event);
if (typeof result === 'string' || typeof result === 'number') {
$value.innerHTML = result;
}