diff --git a/src/block.ts b/src/block.ts index a259e99..9edf08e 100644 --- a/src/block.ts +++ b/src/block.ts @@ -193,16 +193,16 @@ export class Block { } } - addChild(blockSignal: MaybeSignal, position?: number): void { - const block = getValue(blockSignal); - block.parent = this; + addChild(block: MaybeSignal, position?: number): void { + const blockValue = getValue(block); + blockValue.parent = this; this.children ??= []; if (typeof position === "number") { - this.children.splice(position, 0, blockSignal); + this.children.splice(position, 0, block); } else { - this.children.push(blockSignal); + this.children.push(block); } - block.mount(); + blockValue.mount(); this.changed = true; } @@ -216,12 +216,12 @@ export class Block { this.changed = true; } - removeChild(blockSignal: MaybeSignal): void { - const block = getValue(blockSignal); - block.parent = undefined; - block.unmount(); + removeChild(block: MaybeSignal): void { + const blockValue = getValue(block); + blockValue.parent = undefined; + blockValue.unmount(); - const index = this.children?.findIndex((value) => value === block || value === blockSignal); + const index = this.children?.findIndex((value) => value === blockValue || value === block); if (typeof index !== "number" || index === -1) return; this.children!.splice(index, 1); diff --git a/src/style_block.ts b/src/style_block.ts index 7a4c217..182e499 100644 --- a/src/style_block.ts +++ b/src/style_block.ts @@ -134,6 +134,15 @@ export class StyleBlock extends Block { this.changed = true; } + static i = 0; + almostTheSame(other: Block): boolean { + if (other instanceof StyleBlock) { + if (this.style !== other.style) return false; + } + + return super.almostTheSame(other); + } + forceUpdate(): void { this.updateLines(); super.forceUpdate();