Add toggle event and change when checked-change event is fired.

This commit is contained in:
Peter Kaske 2022-04-05 14:57:14 +02:00
parent 9983a48880
commit a9f07a5614
2 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@tp/tp-checkbox", "name": "@tp/tp-checkbox",
"version": "1.0.2", "version": "1.0.3",
"description": "", "description": "",
"main": "tp-checkbox.js", "main": "tp-checkbox.js",
"scripts": { "scripts": {

View File

@ -90,7 +90,13 @@ class TpCheckbox extends Inert(ControlState(FormElement(LitElement))) {
toggle() { toggle() {
this.checked = !this.checked; this.checked = !this.checked;
this.dispatchEvent(new CustomEvent('checked-changed', { detail: this.checked, bubbles: true, composed: true })); this.dispatchEvent(new CustomEvent('toggled', { detail: this.checked, bubbles: true, composed: true }));
}
updated(changes) {
if (changes.has('checked')) {
this.dispatchEvent(new CustomEvent('checked-changed', { detail: this.checked, bubbles: true, composed: true }));
}
} }
get value() { get value() {