Allow to restore the selection by setting the value.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tp/tp-multi-toggle",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"description": "",
|
||||
"main": "tp-multi-toggle.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -62,6 +62,16 @@ class TpMultiToggle extends FormElement(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
set value(val) {
|
||||
this.querySelectorAll('tp-button').forEach(el => {
|
||||
if (el.getAttribute(this.attr || 'id') === val) {
|
||||
el.setAttribute('selected', '');
|
||||
} else {
|
||||
el.removeAttribute('selected');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.boundClick = this.onClick.bind(this);
|
||||
|
||||
Reference in New Issue
Block a user