package org.dominokit.domino.view.slots;

import elemental2.dom.HTMLBodyElement;
import elemental2.dom.HTMLElement;
import jsinterop.base.Js;
import org.dominokit.domino.api.client.mvp.slots.Slot;
import org.dominokit.domino.api.shared.extension.Content;
import org.dominokit.domino.ui.utils.DominoElement;

import static java.util.Objects.nonNull;

public class BodyElementSlot implements Slot {

    private DominoElement<HTMLBodyElement> body = DominoElement.body();

    private static final BodyElementSlot INSTANCE = new BodyElementSlot();


    public static BodyElementSlot create(){
        return INSTANCE;
    }

    private BodyElementSlot(){}

    @Override
    public void updateContent(Content content) {
        body.clearElement();
        body.appendChild(Js.<HTMLElement>uncheckedCast(content.get()));
    }
}

@@ -540,16 +540,52 @@
 lot();%0A%0A
+    private Content currentContent;%0A
 %0A    pub
@@ -761,27 +761,236 @@
     
-body.clearElement()
+if(nonNull(currentContent))%7B%0A            HTMLElement contentElement = Js.uncheckedCast(currentContent.get());%0A            DominoElement.of(contentElement)%0A                    .remove();%0A        %7D%0A        currentContent = content
 ;%0A  

enhance testing