2020-11-26 16:45:25 +01:00
|
|
|
export { config } from "./config";
|
|
|
|
|
|
|
|
|
|
export { toggler } from "./toggler";
|
|
|
|
|
export { createBlock } from "./block_compiler";
|
|
|
|
|
export { list } from "./list";
|
|
|
|
|
export { multi } from "./multi";
|
|
|
|
|
export { text } from "./text";
|
|
|
|
|
export { html } from "./html";
|
|
|
|
|
|
|
|
|
|
export interface VNode<T = any> {
|
|
|
|
|
mount(parent: HTMLElement, afterNode: Node | null): void;
|
|
|
|
|
moveBefore(other: T | null, afterNode: Node | null): void;
|
|
|
|
|
patch(other: T, withBeforeRemove: boolean): void;
|
|
|
|
|
beforeRemove(): void;
|
|
|
|
|
remove(): void;
|
|
|
|
|
firstNode(): Node | undefined;
|
|
|
|
|
|
|
|
|
|
el?: undefined | HTMLElement | Text;
|
|
|
|
|
parentEl?: undefined | HTMLElement;
|
|
|
|
|
isOnlyChild?: boolean | undefined;
|
|
|
|
|
key?: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type BDom = VNode<any>;
|
|
|
|
|
|
2021-10-22 17:30:20 +02:00
|
|
|
export function mount(vnode: VNode, fixture: HTMLElement, afterNode: Node | null = null) {
|
|
|
|
|
vnode.mount(fixture, afterNode);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function patch(vnode1: VNode, vnode2: VNode, withBeforeRemove: boolean = false) {
|
|
|
|
|
vnode1.patch(vnode2, withBeforeRemove);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function remove(vnode: VNode, withBeforeRemove: boolean = false) {
|
|
|
|
|
if (withBeforeRemove) {
|
|
|
|
|
vnode.beforeRemove();
|
|
|
|
|
}
|
|
|
|
|
vnode.remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function withKey(vnode: VNode, key: any) {
|
|
|
|
|
vnode.key = key;
|
|
|
|
|
return vnode;
|
|
|
|
|
}
|