add console error

pull/490/head
Cory LaViska 2021-07-26 08:20:18 -04:00
rodzic d6e6f2cb25
commit e938f94ffc
2 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -6,6 +6,10 @@ Components with the <sl-badge type="warning" pill>Experimental</sl-badge> badge
_During the beta period, these restrictions may be relaxed in the event of a mission-critical bug._ 🐛
## Next
- Added a console error that appears when menu items have duplicate values in `sl-select`
## 2.0.0-beta.47
This release improves how component dependencies are imported. If you've been cherry picking, you no longer need to import component dependencies manually. This significantly improves developer experience, making Shoelace even easier to use. For transparency, component dependencies will continue to be listed in the docs.

Wyświetl plik

@ -305,6 +305,17 @@ export default class SlSelect extends LitElement {
// Wait for items to render before gathering labels otherwise the slot won't exist
const items = this.getItems();
// Check for duplicate values in menu items
const values: string[] = [];
items.map(item => {
if (values.includes(item.value)) {
console.error(`Duplicate value found in <sl-select> menu item: '${item.value}'`, item);
}
values.push(item.value);
});
await Promise.all(items.map(item => item.render)).then(() => this.syncItemsFromValue());
}