Interface IsElement<E extends Element>
- All Known Subinterfaces:
AttachableElement<E>, ElementAttributeMethods<E,B>, ElementClassListMethods<E, B>, ElementConsumerMethods<E, B>, ElementContainerDelegate<E, B>, ElementContainerMethods<E, B>, ElementEventMethods<E, B>, ElementHTMLMethods<E, B>, ElementIdMethods<E, B>, ElementQueryMethods<E>, ElementTextDelegate<E, B>, ElementTextMethods<E, B>, HTMLElementAttributeMethods<E, B>, HTMLElementDataMethods<E, B>, HTMLElementStyleMethods<E, B>, HTMLElementVisibilityMethods<E, B>, HTMLInputElementMethods<E, B>, HTMLSelectElementMethods<E, B>, HTMLTextAreaElementMethods<E, B>, MathMLElementStyleMethods<E, B>, SVGElementDataMethods<E, B>, SVGElementStyleMethods<E, B>
- All Known Implementing Classes:
HTMLContainerBuilder, HTMLElementBuilder, HTMLInputElementBuilder, HTMLSelectElementBuilder, HTMLTextAreaElementBuilder, Link, MathMLContainerMethods, MathMLElementBuilder, SVGContainerBuilder, SVGElementBuilder
public interface IsElement<E extends Element>
Interface for custom components returning a single element.
public class TodoElement implements IsElement<HTMLElement>, Attachable {
private final HTMLElement root;
private final HTMLInputElement toggle;
private final HTMLElement label;
private final HTMLButtonElement destroy;
private final HTMLInputElement summary;
private HandlerRegistration handlerRegistration;
TodoElement(Todo todo) {
root = li().data("item", todo.id)
.add(div().css("view")
.add(toggle = input(checkbox).css("toggle")
.checked(todo.completed)
.element())
.add(label = label().text(todo.text).element())
.add(destroy = button().css("destroy").element()))
.add(summary = input(text).css("edit").element())
.element();
root.classList.toggle("completed", todo.completed);
toggle.checked = todo.completed;
Attachable.register(root, this);
}
@Override
public HTMLElement element() {
return root;
}
@Override
public void attach(MutationRecord mutationRecord) {
handlerRegistration = HandlerRegistrations.compose(
bind(toggle, change, ev -> element()),
bind(label, dblclick, ev -> ...),
bind(destroy, click, ev -> ...),
bind(summary, keydown, ev -> ...),
bind(summary, blur, ev -> ...));
}
@Override
public void detach(MutationRecord mutationRecord) {
if (handlerRegistration != null) {
handlerRegistration.removeHandler();
}
}
}
-
Method Summary
-
Method Details
-
element
E element()- Returns:
- the element of the custom component
-