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
@@ -197,7 +197,7 @@ export default class Setting extends Component {
append($right, $arrow);
}
const event = proxy($item, 'click', (event) => {
const event = proxy($item, 'click', async (event) => {
if (hasChildren) {
this.init(item.selector, item.width);
} else {
@@ -208,7 +208,7 @@ export default class Setting extends Component {
}
if (item._parentItem && item._parentItem.onSelect) {
const result = item._parentItem.onSelect.call(this.art, item, $item, event);
const result = await item._parentItem.onSelect.call(this.art, item, $item, event);
if (item._parentItem._$tooltip) {
if (typeof result === 'string' || typeof result === 'number') {
item._parentItem._$tooltip.innerHTML = result;
+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;
}