class {
    onMount() {
        this.events = [];
    }

    handleAttach(color, event, node) {
        this.events.push({
            color: color,
            event: event,
            node: node
        });
    }
}

<div>
    <ul>
        <for(color in input.colors)>
            <li key=color on-attach('handleAttach', color)>
                ${color}
            </li>
        </for>
    </ul>
</div>