import {Segment} from "./Segment";
import {Helper} from "../../../../../../js/lib/pwa-lib";

export class LeafSegment extends Segment {

    constructor(element, leaf) {
        super(element);
        this.leaf = 'A';
        if (Helper.isNotNull(leaf)) {
            this.setLeaf(leaf);
        }
    }

    sameAs(otherSegment) {
        // debugger;
        return (otherSegment instanceof LeafSegment && otherSegment.leaf === this.leaf);
    }

    setLeaf(leaf) {
        this.leaf = leaf;
    }

    _updateElement() {
        this.element.querySelector(".leaf-element").removeAllChildren().appendChild(document.createTextNode(this.leaf));
    }
}