Compare commits
2 Commits
72f38c1137
...
51f894c616
| Author | SHA1 | Date | |
|---|---|---|---|
| 51f894c616 | |||
| 3b0dce6fbe |
@ -54,6 +54,9 @@ export function State() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO a proper Prop-decorator
|
||||||
|
export {State as Prop};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This CustomElement class is to avoid having to do an ugly workaround in every custom-element:
|
* This CustomElement class is to avoid having to do an ugly workaround in every custom-element:
|
||||||
|
|||||||
@ -6,8 +6,6 @@ import {
|
|||||||
NodeTreeRenderer
|
NodeTreeRenderer
|
||||||
} from "./renderers";
|
} from "./renderers";
|
||||||
|
|
||||||
// TODO consider using existence of renderer.remove to identify whether a VNode is ChildNode or not
|
|
||||||
// TODO Rework all below so we can determine per type how to handle it (not all represent a childNode of the host etc...)
|
|
||||||
// TODO Element renderer (for things that are already DOM-elements)
|
// TODO Element renderer (for things that are already DOM-elements)
|
||||||
export function getNodeMeta(vnode){
|
export function getNodeMeta(vnode){
|
||||||
if(vnode===undefined||vnode===null) return undefined; // Indicate it shouldn't render
|
if(vnode===undefined||vnode===null) return undefined; // Indicate it shouldn't render
|
||||||
@ -49,7 +47,6 @@ export function getNodeMeta(vnode){
|
|||||||
export function render(vnode, opts = {}) {
|
export function render(vnode, opts = {}) {
|
||||||
// TODO innerHTML, innerText and other tags/props that are trickyer then just mapping value to attribute (see NodeTreeRenderer)
|
// TODO innerHTML, innerText and other tags/props that are trickyer then just mapping value to attribute (see NodeTreeRenderer)
|
||||||
// TODO ref-prop (should it only return once all child els are created and appended to the child?!)
|
// TODO ref-prop (should it only return once all child els are created and appended to the child?!)
|
||||||
// TODO Proper updating of a previous rendered vnode (we're working on it!)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -182,7 +179,7 @@ export function render(vnode, opts = {}) {
|
|||||||
else
|
else
|
||||||
item.host.removeChild(oldChild.element);
|
item.host.removeChild(oldChild.element);
|
||||||
}
|
}
|
||||||
queuedItems.push(child);// TODO where should the new child be inserted...
|
queuedItems.push(child);
|
||||||
}
|
}
|
||||||
previous = child.item;
|
previous = child.item;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@ export class MyTodo extends CustomElement{
|
|||||||
{this.todos.map(item =>
|
{this.todos.map(item =>
|
||||||
<todo-item
|
<todo-item
|
||||||
model={ item.id }
|
model={ item.id }
|
||||||
text={item.text}
|
|
||||||
checked={ item.checked }
|
checked={ item.checked }
|
||||||
>
|
>
|
||||||
{ item.text }
|
{ item.text }
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import {defineElement, render, CustomElement, Host} from "../../../packages/csx-custom-elements";
|
import {defineElement, render, CustomElement, Host, State} from "../../../packages/csx-custom-elements";
|
||||||
import style from './todo-input.scss';
|
import style from './todo-input.scss';
|
||||||
|
|
||||||
@defineElement('todo-input')
|
@defineElement('todo-input')
|
||||||
export class TodoInput extends CustomElement{
|
export class TodoInput extends CustomElement{
|
||||||
value = "";
|
@State() value = "";
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return (
|
return (
|
||||||
@ -27,7 +27,7 @@ export class TodoInput extends CustomElement{
|
|||||||
this.dispatchEvent(new CustomEvent('submit', {
|
this.dispatchEvent(new CustomEvent('submit', {
|
||||||
detail: this.value
|
detail: this.value
|
||||||
}));
|
}));
|
||||||
this.state = "";
|
this.value = "";
|
||||||
};
|
};
|
||||||
handleInput = ({target: {value}})=>{
|
handleInput = ({target: {value}})=>{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import {defineElement, render, CustomElement, Host, ShadowDOM, State} from "../../../packages/csx-custom-elements";
|
import {defineElement, render, CustomElement, Host, ShadowDOM, State, Prop} from "../../../packages/csx-custom-elements";
|
||||||
import style from './todo-item.scss';
|
import style from './todo-item.scss';
|
||||||
|
|
||||||
@defineElement('todo-item')
|
@defineElement('todo-item')
|
||||||
export class TodoItem extends CustomElement{
|
export class TodoItem extends CustomElement{
|
||||||
@State() checked = false;// TODO annotate as prop instead of state (attribute)
|
@Prop() checked = false;
|
||||||
@State() model; // TODO annotate as prop instead of state
|
@Prop() model;
|
||||||
@State() text;
|
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user