A working version but using non-legacy decorators should be reconsidered, and probably quite a few bugs left in the render loop
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import {defineElement, render, CustomElement, Host, ShadowDOM} from "../../../packages/csx-custom-elements";
|
||||
import {defineElement, render, CustomElement, Host, ShadowDOM, State} from "../../../packages/csx-custom-elements";
|
||||
import style from './todo-item.scss';
|
||||
|
||||
@defineElement('todo-item')
|
||||
export class TodoItem extends CustomElement{
|
||||
checked = false;// TODO annotate as prop (attribute)
|
||||
@State() checked = false;// TODO annotate as prop instead of state (attribute)
|
||||
@State() model; // TODO annotate as prop instead of state
|
||||
@State() text;
|
||||
|
||||
render(){
|
||||
return (
|
||||
@@ -27,12 +29,13 @@ export class TodoItem extends CustomElement{
|
||||
|
||||
handleChange = ()=>{
|
||||
this.dispatchEvent(new CustomEvent('check', {
|
||||
detail: (this.checked=!this.checked),
|
||||
detail: {checked: (this.checked=!this.checked), id: this.model},
|
||||
bubbles: true
|
||||
}));
|
||||
};
|
||||
handleClick = ()=>{
|
||||
this.dispatchEvent(new CustomEvent('remove', {
|
||||
detail: {id: this.model},
|
||||
bubbles: true
|
||||
}));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user