Class Elements
java.lang.Object
org.jboss.elemento.Elements
Builder and helper methods for working with
HTMLElements and/or IsElement.
/* The code below, builds the following HTML snippet
<section class="main">
<input class="toggle-all" type="checkbox">
<label for="toggle-all">Mark all as complete</label>
<ul class="todo-list">
<li>
<div class="view">
<input class="toggle" type="checkbox" checked>
<label>Taste Elemento</label>
<button class="destroy"></button>
</div>
<input class="edit">
</li>
</ul>
</section>
*/
TodoRepository repository = new TodoRepository();
HTMLElement section = section().css("main")
.add(input(checkbox).id("toggle-all").css("toggle-all"))
.add(label()
.apply(l -> l.htmlFor = "toggle-all")
.text("Mark all as complete"))
.add(ul().css("todo-list")
.run(ul -> {
for (Todo todo : repository.todos()) {
ul.add(li()
.add(div().css("view")
.add(input(checkbox)
.css("toggle")
.checked(todo.completed))
.add(label().text(todo.text))
.add(button().css("destroy")))
.add(input(text).css("edit")));
}
}))
.element();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiona()static HTMLContainerBuilder<HTMLElement> abbr()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> address()static HTMLContainerBuilder<HTMLElement> static HTMLElementBuilder<HTMLAreaElement> area()static HTMLElementBuilder<HTMLAreaElement> static HTMLContainerBuilder<HTMLElement> article()static HTMLContainerBuilder<HTMLElement> static <T extends Node>
Function<T, HTMLElement> Casts toHTMLElement.static HTMLContainerBuilder<HTMLElement> aside()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLAudioElement> audio()static HTMLContainerBuilder<HTMLAudioElement> static HTMLContainerBuilder<HTMLElement> b()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLQuoteElement> static HTMLContainerBuilder<HTMLQuoteElement> blockquote(Element element) static HTMLContainerBuilder<HTMLBodyElement> body()Returns an HTML content builder for the document body.static HTMLElementBuilder<HTMLBRElement> br()static HTMLElementBuilder<HTMLBRElement> button()button(ButtonType type) canvas()caption()static Iterable<HTMLElement> children(HTMLElement parent) Returns an iterable interface for the child elements of the given parent element.Returns an iterable interface for the child nodes of the given parent node.static <E extends HTMLElement>
Iterable<HTMLElement> Returns an iterable interface for the child elements of the given parent element.static HTMLContainerBuilder<HTMLElement> cite()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static <E extends HTMLElement>
EFinds the closest HTML elements for the given selector.static <E extends HTMLElement, F extends HTMLElement>
FFinds the closest HTML elements for the given selector.static HTMLContainerBuilder<HTMLElement> code()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> col()colgroup()static <E extends HTMLElement>
EcreateHtmlElement(String element, Class<E> type) Creates the specified HTML element.datalist()static HTMLContainerBuilder<HTMLElement> dd()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLModElement> del()static HTMLContainerBuilder<HTMLModElement> static HTMLContainerBuilder<HTMLModElement> static HTMLContainerBuilder<HTMLElement> dfn()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLDivElement> div()static HTMLContainerBuilder<HTMLDivElement> static HTMLContainerBuilder<HTMLDListElement> dl()static HTMLContainerBuilder<HTMLDListElement> static HTMLContainerBuilder<HTMLElement> dt()static HTMLContainerBuilder<HTMLElement> static <E> Iterable<E> elements(jsinterop.base.JsArrayLike<E> nodes) Returns an iterable interface for the elements in the given array-like.static HTMLContainerBuilder<HTMLElement> em()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLElementBuilder<HTMLEmbedElement> embed()static HTMLElementBuilder<HTMLEmbedElement> static booleanfailSafeRemove(Node parent, Element child) Removes the child from the parent if both parent and child are not null and the parent contains the child.static <E extends HTMLElement>
booleanfailSafeRemove(Node parent, IsElement<E> child) Removes the child from the parent if both parent and child are not null and the parent contains the child.static booleanfailSafeRemoveFromParent(Element element) Removes the element from its parent if the element is not null and has a parent.static <E extends HTMLElement>
booleanfailSafeRemoveFromParent(IsElement<E> element) Removes the element from its parent if the element is not null and has a parent.fieldset()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> figcaption(Element element) static HTMLContainerBuilder<HTMLElement> figure()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> footer()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLFormElement> form()static HTMLContainerBuilder<HTMLFormElement> h(int n) static HTMLContainerBuilder<HTMLElement> header()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> hgroup()static HTMLContainerBuilder<HTMLElement> static HTMLElementBuilder<HTMLHRElement> hr()static HTMLElementBuilder<HTMLHRElement> static <E extends HTMLElement>
HTMLContainerBuilder<E> htmlContainer(String element, Class<E> type) Returns a builder for the specified HTML element.static <E extends HTMLElement>
HTMLElementBuilder<E> htmlElement(String element, Class<E> type) Returns a builder for the specified HTML element.Returns a predicate for HTML elements.static HTMLContainerBuilder<HTMLElement> i()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> iframe()static HTMLElementBuilder<HTMLImageElement> img()static HTMLElementBuilder<HTMLImageElement> static HTMLElementBuilder<HTMLImageElement> static voidConvenience method to set the inner HTML of the given element.static <E extends Element>
voidConvenience method to set the inner HTML of the given element.static <E extends HTMLInputElement>
HTMLInputElementBuilder<E> static HTMLContainerBuilder<HTMLModElement> ins()static HTMLContainerBuilder<HTMLModElement> static HTMLContainerBuilder<HTMLModElement> static voidinsertAfter(Element newElement, Element after) Inserts elementnewElementinto the parent after elementafter.static <E extends HTMLElement>
voidinsertAfter(IsElement<E> newElement, Element after) Inserts elementnewElementinto the parent after elementafter.static voidinsertBefore(Element newElement, Element before) Inserts elementnewElementinto the parent before elementbefore.static <E extends HTMLElement>
voidinsertBefore(IsElement<E> newElement, Element before) Inserts elementnewElementinto the parent before elementbefore.static voidinsertFirst(Element parent, Element newElement) Inserts elementnewElementas the first element intoparent.static <E extends HTMLElement>
voidinsertFirst(Element parent, IsElement<E> newElement) Inserts elementnewElementas the first element intoparent.static booleanisAttached(Node node) Fail-safe shortcut forNode.isConnectedstatic <E extends HTMLElement>
booleanisAttached(IsElement<E> element) Returnstrueif the element is connected by callingNode.isConnectedon the element'sIsElement.element().static booleanisElementInView(HTMLElement element) static booleanisElementInView(HTMLElement container, HTMLElement element, boolean partial) This function returns whether an element is within the viewable area of a container.static <E extends HTMLElement>
booleanisElementInView(HTMLElement container, IsElement<E> element, boolean partial) static <E extends HTMLElement>
booleanisElementInView(IsElement<E> element) static <E extends HTMLElement>
booleanisElementInView(IsElement<E> container, HTMLElement element, boolean partial) static <E extends HTMLElement, F extends HTMLElement>
booleanisElementInView(IsElement<E> container, IsElement<F> element, boolean partial) static booleanisVisible(HTMLElement element) Checks whether the given element is visible (i.e.static <E extends HTMLElement>
booleanChecks whether the given element is visible (i.e.static Iterator<HTMLElement> iterator(HTMLElement parent) Returns an iterator over the children of the given parent element.Returns an iterator over the children of the given parent node.static <E> Iterator<E> iterator(jsinterop.base.JsArrayLike<E> data) Returns an iterator over the given array-like.static <E extends HTMLElement>
Iterator<HTMLElement> Returns an iterator over the children of the given parent element.static HTMLContainerBuilder<HTMLElement> kbd()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLLabelElement> label()static HTMLContainerBuilder<HTMLLabelElement> static HTMLContainerBuilder<HTMLLabelElement> static voidlazyAppend(Element parent, Element child) Appends elementchildto elementparentif not already present.static <E extends HTMLElement>
voidlazyAppend(Element parent, IsElement<E> child) Appends elementchildto elementparentif not already present.static voidlazyInsertAfter(Element newElement, Element after) Inserts elementnewElementinto the parent after elementafterif not already present.static voidlazyInsertAfter(Element parent, Element newElement, Element after) Inserts elementnewElementinto the parent after elementafterif not already present.static <E extends HTMLElement>
voidlazyInsertAfter(Element parent, IsElement<E> newElement, Element after) Inserts elementnewElementinto the parent after elementafterif not already present.static <E extends HTMLElement>
voidlazyInsertAfter(IsElement<E> newElement, Element after) Inserts elementnewElementinto the parent after elementafterif not already present.static voidlazyInsertBefore(Element newElement, Element before) Inserts elementnewElementinto the parent before elementbeforeif not already present.static voidlazyInsertBefore(Element parent, Element newElement, Element before) Inserts elementnewElementinto the parent before elementbeforeif not already present.static <E extends HTMLElement>
voidlazyInsertBefore(Element parent, IsElement<E> newElement, Element before) Inserts elementnewElementinto the parent before elementbeforeif not already present.static <E extends HTMLElement>
voidlazyInsertBefore(IsElement<E> newElement, Element before) Inserts elementnewElementinto the parent before elementbeforeif not already present.legend()static HTMLContainerBuilder<HTMLLIElement> li()static HTMLContainerBuilder<HTMLLIElement> static HTMLContainerBuilder<HTMLElement> main()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLMapElement> map()static HTMLContainerBuilder<HTMLMapElement> static HTMLContainerBuilder<HTMLElement> mark()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLMeterElement> meter()static HTMLContainerBuilder<HTMLMeterElement> static HTMLContainerBuilder<HTMLMeterElement> static HTMLContainerBuilder<HTMLElement> nav()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> noscript()static HTMLContainerBuilder<HTMLElement> object()static HTMLContainerBuilder<HTMLOListElement> ol()static HTMLContainerBuilder<HTMLOListElement> static voidonAttach(HTMLElement element, ObserverCallback callback) Registers a callback when an element is appended to the document body.static <E extends HTMLElement>
voidonAttach(IsElement<E> element, ObserverCallback callback) Registers a callback when an element is appended to the document body.static voidonDetach(HTMLElement element, ObserverCallback callback) Registers a callback when an element is removed from the document body.static <E extends HTMLElement>
voidonDetach(IsElement<E> element, ObserverCallback callback) Registers a callback when an element is removed from the document body.optgroup()static HTMLElementBuilder<HTMLOptionElement> option()static HTMLElementBuilder<HTMLOptionElement> static HTMLElementBuilder<HTMLOptionElement> output()p()static HTMLElementBuilder<HTMLParamElement> param()static HTMLElementBuilder<HTMLParamElement> picture()static HTMLContainerBuilder<HTMLPreElement> pre()static HTMLContainerBuilder<HTMLPreElement> progress()static HTMLContainerBuilder<HTMLQuoteElement> q()static HTMLContainerBuilder<HTMLQuoteElement> static HTMLContainerBuilder<HTMLQuoteElement> static <E extends HTMLElement>
EquerySelector(Node node, By selector) Finds a single HTML element for the given selector.static <E extends HTMLElement, F extends HTMLElement>
FquerySelector(IsElement<E> element, By selector) Finds a single HTML element for the given selector.static Iterable<HTMLElement> querySelectorAll(Node node, By selector) Finds all HTML elements for the given selector.static <E extends HTMLElement>
Iterable<HTMLElement> querySelectorAll(IsElement<E> element, By selector) Finds all HTML elements for the given selector.static voidremoveChildrenFrom(Element element) Removes all child elements fromelementstatic <E extends HTMLElement>
voidremoveChildrenFrom(IsElement<E> element) Removes all child elements fromelement.static <E extends HTMLElement>
ResizeObserverCleanupresizeObserver(E element, ResizeCallback callback) Register a resize observer for the given element.static <E extends HTMLElement>
ResizeObserverCleanupresizeObserver(IsElement<E> element, ResizeCallback callback) Register a resize observer for the given element.static HTMLElementBuilder<HTMLScriptElement> script()static HTMLElementBuilder<HTMLScriptElement> static HTMLContainerBuilder<HTMLElement> section()static HTMLContainerBuilder<HTMLElement> select()static voidsetVisible(HTMLElement element, boolean visible) Shows / hide the specified element by modifying thedisplayproperty.static <E extends HTMLElement>
voidsetVisible(IsElement<E> element, boolean visible) Shows / hide the specified element by modifying thedisplayproperty.static HTMLContainerBuilder<HTMLElement> small()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLElementBuilder<HTMLSourceElement> source()static HTMLElementBuilder<HTMLSourceElement> static HTMLContainerBuilder<HTMLElement> span()static HTMLContainerBuilder<HTMLElement> static Stream<HTMLElement> stream(HTMLElement parent) Returns a stream for the child elements of the given parent element.Returns a stream for the child nodes of the given parent node.static <E> Stream<E> stream(jsinterop.base.JsArrayLike<E> nodes) Returns a stream for the elements in the given array-like.static <E extends HTMLElement>
Stream<HTMLElement> Returns a stream for the child elements of the given parent element.static HTMLContainerBuilder<HTMLElement> strong()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> sub()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> sup()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLTableElement> table()static HTMLContainerBuilder<HTMLTableElement> tbody()td()textarea()static StringReturns the text content of the given HTMLElement.static voidChanges the text of the first text node (if any) or adds the given text as a new text node.Returns the text content of the given element.static <E extends Element>
voidChanges the text of the first text node (if any) or adds the given text as a new text node.tfoot()th()thead()static HTMLContainerBuilder<HTMLElement> time()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static voidtoggle(HTMLElement element, String css, boolean condition) Adds the specified CSS class to the element ifconditionistrue, removes it otherwise.static voidtoggle(HTMLElement element, String css, Supplier<Boolean> condition) Adds the specified CSS class to the element ifconditionistrue, removes it otherwise.static <E extends HTMLElement>
voidAdds the specified CSS class to the element ifconditionistrue, removes it otherwise.static <E extends HTMLElement>
voidAdds the specified CSS class to the element ifconditionistrue, removes it otherwise.static Stringtr()static HTMLElementBuilder<HTMLTrackElement> track()static HTMLElementBuilder<HTMLTrackElement> static HTMLContainerBuilder<HTMLElement> u()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLUListElement> ul()static HTMLContainerBuilder<HTMLUListElement> static HTMLContainerBuilder<HTMLElement> var()static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLElement> static HTMLContainerBuilder<HTMLVideoElement> video()static HTMLContainerBuilder<HTMLVideoElement> static HTMLElementBuilder<HTMLElement> wbr()static HTMLElementBuilder<HTMLElement> static <E extends HTMLElement>
HTMLContainerBuilder<E> wrapHtmlContainer(E element) Returns a builder for the existing HTML element.static <E extends HTMLElement>
HTMLElementBuilder<E> wrapHtmlElement(E element) Returns a builder for the existing HTML element.static <E extends HTMLInputElement>
HTMLInputElementBuilder<E> wrapInputElement(E element) Returns a builder for the existing input element.static <E extends HTMLSelectElement>
HTMLSelectElementBuilder<E> wrapSelectElement(E element) Returns a builder for the existing select element.static <E extends HTMLTextAreaElement>
HTMLTextAreaElementBuilder<E> wrapTextAreaElement(E element) Returns a builder for the existing text area element.
-
Method Details
-
body
Returns an HTML content builder for the document body. -
address
-
address
-
article
-
article
-
aside
-
aside
-
h
-
h
-
h
-
header
-
header
-
hgroup
-
hgroup
-
section
-
section
-
blockquote
-
blockquote
-
dd
-
dd
-
div
-
div
-
dl
-
dl
-
dt
-
dt
-
figcaption
-
figcaption
-
figure
-
figure
-
hr
-
hr
-
li
-
li
-
main
-
main
-
ol
-
ol
-
p
-
p
-
pre
-
pre
-
ul
-
ul
-
a
-
a
-
a
-
a
-
abbr
-
abbr
-
abbr
-
b
-
b
-
b
-
br
-
br
-
cite
-
cite
-
cite
-
code
-
code
-
code
-
dfn
-
dfn
-
dfn
-
em
-
em
-
em
-
i
-
i
-
i
-
kbd
-
kbd
-
kbd
-
mark
-
mark
-
mark
-
q
-
q
-
q
-
small
-
small
-
small
-
span
-
span
-
strong
-
strong
-
strong
-
sub
-
sub
-
sub
-
sup
-
sup
-
sup
-
time
-
time
-
time
-
u
-
u
-
u
-
var
-
var
-
var
-
wbr
-
wbr
-
area
-
area
-
audio
-
audio
-
img
-
img
-
img
-
map
-
map
-
picture
-
picture
-
track
-
track
-
video
-
video
-
canvas
-
canvas
-
embed
-
embed
-
iframe
-
iframe
-
iframe
-
object
-
object
-
param
-
param
-
source
-
source
-
noscript
-
noscript
-
script
-
script
-
del
-
del
-
del
-
ins
-
ins
-
ins
-
caption
-
caption
-
col
-
col
-
colgroup
-
colgroup
-
table
-
table
-
tbody
-
tbody
-
td
-
td
-
tfoot
-
tfoot
-
th
-
th
-
thead
-
thead
-
tr
-
tr
-
button
-
button
-
button
-
button
-
datalist
-
datalist
-
fieldset
-
fieldset
-
form
-
form
-
input
-
input
-
input
public static <E extends HTMLInputElement> HTMLInputElementBuilder<E> input(String type, Class<E> jType) -
input
-
label
-
label
-
label
-
legend
-
legend
-
meter
-
meter
-
meter
-
optgroup
-
optgroup
-
option
-
option
-
option
-
output
-
output
-
output
-
progress
-
progress
-
select
-
select
-
textarea
-
textarea
-
htmlElement
public static <E extends HTMLElement> HTMLElementBuilder<E> htmlElement(String element, Class<E> type) Returns a builder for the specified HTML element. -
htmlContainer
public static <E extends HTMLElement> HTMLContainerBuilder<E> htmlContainer(String element, Class<E> type) Returns a builder for the specified HTML element. -
createHtmlElement
Creates the specified HTML element. -
wrapHtmlElement
Returns a builder for the existing HTML element. -
wrapHtmlContainer
Returns a builder for the existing HTML element. -
wrapInputElement
Returns a builder for the existing input element. -
wrapSelectElement
public static <E extends HTMLSelectElement> HTMLSelectElementBuilder<E> wrapSelectElement(E element) Returns a builder for the existing select element. -
wrapTextAreaElement
public static <E extends HTMLTextAreaElement> HTMLTextAreaElementBuilder<E> wrapTextAreaElement(E element) Returns a builder for the existing text area element. -
querySelectorAll
Finds all HTML elements for the given selector. -
querySelectorAll
public static <E extends HTMLElement> Iterable<HTMLElement> querySelectorAll(IsElement<E> element, By selector) Finds all HTML elements for the given selector. -
querySelector
Finds a single HTML element for the given selector. -
querySelector
public static <E extends HTMLElement, F extends HTMLElement> F querySelector(IsElement<E> element, By selector) Finds a single HTML element for the given selector. -
closest
Finds the closest HTML elements for the given selector.- See Also:
-
closest
public static <E extends HTMLElement, F extends HTMLElement> F closest(IsElement<E> element, By selector) Finds the closest HTML elements for the given selector.- See Also:
-
iterator
Returns an iterator over the given array-like. The iterator does not support theIterator.remove()operation. -
iterator
Returns an iterator over the children of the given parent node. The iterator supports theIterator.remove()operation, which removes the current node from its parent. -
iterator
Returns an iterator over the children of the given parent element. The iterator supports theIterator.remove()operation, which removes the current node from its parent. -
iterator
Returns an iterator over the children of the given parent element. The iterator supports theIterator.remove()operation, which removes the current node from its parent. -
elements
Returns an iterable interface for the elements in the given array-like. -
children
-
children
Returns an iterable interface for the child elements of the given parent element. -
children
Returns an iterable interface for the child elements of the given parent element. -
htmlElements
-
asHtmlElement
Casts toHTMLElement. Make sure to filter for HTML elements before using this function. -
stream
Returns a stream for the elements in the given array-like.HTMLElement parent = querySelector(body(), By.data("foo", "bar")); if (parent != null) { List<HTMLElement> htmlElements = stream(parent) .filter(htmlElements()) .map(asHtmlElement()) .collect(toList()); } -
stream
Returns a stream for the child nodes of the given parent node.HTMLElement parent = querySelector(body(), By.data("foo", "bar")); if (parent != null) { List<HTMLElement> htmlElements = stream(parent) .filter(htmlElements()) .map(asHtmlElement()) .collect(toList()); } -
stream
Returns a stream for the child elements of the given parent element.HTMLElement parent = querySelector(body(), By.data("foo", "bar")); if (parent != null) { List<HTMLElement> htmlElements = stream(parent) .filter(htmlElements()) .map(asHtmlElement()) .collect(toList()); } -
stream
Returns a stream for the child elements of the given parent element.HTMLElement parent = querySelector(body(), By.data("foo", "bar")); if (parent != null) { List<HTMLElement> htmlElements = stream(parent) .filter(htmlElements()) .map(asHtmlElement()) .collect(toList()); } -
lazyAppend
-
lazyAppend
Appends elementchildto elementparentif not already present. If a parent already contains a child, this method does nothing. -
insertAfter
-
insertAfter
Inserts elementnewElementinto the parent after elementafter. -
lazyInsertAfter
-
lazyInsertAfter
Inserts elementnewElementinto the parent after elementafterif not already present. If parent already containsnewElement, this method does nothing. -
lazyInsertAfter
-
lazyInsertAfter
public static <E extends HTMLElement> void lazyInsertAfter(Element parent, IsElement<E> newElement, Element after) Inserts elementnewElementinto the parent after elementafterif not already present. If parent already containsnewElement, this method does nothing. -
insertBefore
-
insertBefore
Inserts elementnewElementinto the parent before elementbefore. -
lazyInsertBefore
-
lazyInsertBefore
public static <E extends HTMLElement> void lazyInsertBefore(IsElement<E> newElement, Element before) Inserts elementnewElementinto the parent before elementbeforeif not already present. If parent already containsnewElement, this method does nothing. -
lazyInsertBefore
-
lazyInsertBefore
public static <E extends HTMLElement> void lazyInsertBefore(Element parent, IsElement<E> newElement, Element before) Inserts elementnewElementinto the parent before elementbeforeif not already present. If parent already containsnewElement, this method does nothing. -
insertFirst
-
insertFirst
Inserts elementnewElementas the first element intoparent. -
removeChildrenFrom
Removes all child elements fromelement -
removeChildrenFrom
Removes all child elements fromelement.If the element implements
ElementContainerDelegatethe child elements are removed from the container delegate. If you don't want that, explicitly callremoveChildrenFrom(element.element()). -
failSafeRemoveFromParent
Removes the element from its parent if the element is not null and has a parent.- Returns:
trueif the element has been removed from its parent,falseotherwise.
-
failSafeRemoveFromParent
Removes the element from its parent if the element is not null and has a parent.- Returns:
trueif the element has been removed from its parent,falseotherwise.
-
failSafeRemove
-
failSafeRemove
Removes the child from the parent if both parent and child are not null and the parent contains the child.- Returns:
trueif the element has been removed from its parent,falseotherwise.
-
isAttached
Returnstrueif the element is connected by callingNode.isConnectedon the element'sIsElement.element().- See Also:
-
isAttached
-
onAttach
Registers a callback when an element is appended to the document body. Note that the callback will be called only once, if the element is appended more than once, a new callback should be registered.- Parameters:
element- the HTML element which is going to be added to the bodycallback-ObserverCallback
-
onAttach
public static <E extends HTMLElement> void onAttach(IsElement<E> element, ObserverCallback callback) Registers a callback when an element is appended to the document body. Note that the callback will be called only once, if the element is appended more than once, a new callback should be registered.- Parameters:
element- the element which is going to be added to the bodycallback-ObserverCallback
-
onDetach
Registers a callback when an element is removed from the document body. Note that the callback will be called only once, if the element is removed and re-appended, a new callback should be registered.- Parameters:
element- the HTML element which is going to be removed from the bodycallback-ObserverCallback
-
onDetach
public static <E extends HTMLElement> void onDetach(IsElement<E> element, ObserverCallback callback) Registers a callback when an element is removed from the document body. Note that the callback will be called only once, if the element is removed and re-appended, a new callback should be registered.- Parameters:
element- the element which is going to be removed from the bodycallback-ObserverCallback
-
isVisible
Checks whether the given element is visible (i.e.displayis notnone) -
isVisible
Checks whether the given element is visible (i.e.displayis notnone) -
setVisible
Shows / hide the specified element by modifying thedisplayproperty. -
setVisible
Shows / hide the specified element by modifying thedisplayproperty. -
isElementInView
public static <E extends HTMLElement> boolean isElementInView(IsElement<E> container, HTMLElement element, boolean partial) -
isElementInView
-
isElementInView
-
isElementInView
public static <E extends HTMLElement> boolean isElementInView(HTMLElement container, IsElement<E> element, boolean partial) -
isElementInView
public static <E extends HTMLElement, F extends HTMLElement> boolean isElementInView(IsElement<E> container, IsElement<F> element, boolean partial) -
isElementInView
This function returns whether an element is within the viewable area of a container. If partial is true, then this function will return true even if only part of the element is in view.- Parameters:
container- The container to check if the element is in view of.element- The element to check if it is in viewpartial- true if a partial view is allowed- Returns:
trueif the component is in view.
-
resizeObserver
public static <E extends HTMLElement> ResizeObserverCleanup resizeObserver(IsElement<E> element, ResizeCallback callback) Register a resize observer for the given element. The observer will call the provided callback whenever the size of the element changes.Uses the native
ResizeObserverif available. Falls back towindow.addEventListener("resize", callback), otherwise.- Type Parameters:
E- The type of element being observed, which must extend from HTMLElement.- Parameters:
element- The element to observe for size changes.callback- The callback function to be called when the size of the element changes.- Returns:
- A cleanup function that can be used to unregister the observer.
-
resizeObserver
public static <E extends HTMLElement> ResizeObserverCleanup resizeObserver(E element, ResizeCallback callback) Register a resize observer for the given element. The observer will call the provided callback whenever the size of the element changes.Uses the native
ResizeObserverif available. Falls back towindow.addEventListener("resize", callback), otherwise.- Type Parameters:
E- The type of element being observed, which must extend from HTMLElement.- Parameters:
element- The element to observe for size changes.callback- The callback function to be called when the size of the element changes.- Returns:
- A cleanup function that can be used to unregister the observer.
-
toggle
Adds the specified CSS class to the element ifconditionistrue, removes it otherwise. -
toggle
public static <E extends HTMLElement> void toggle(IsElement<E> element, String css, boolean condition) Adds the specified CSS class to the element ifconditionistrue, removes it otherwise. -
toggle
Adds the specified CSS class to the element ifconditionistrue, removes it otherwise. -
toggle
public static <E extends HTMLElement> void toggle(IsElement<E> element, String css, Supplier<Boolean> condition) Adds the specified CSS class to the element ifconditionistrue, removes it otherwise. -
textNode
Returns the text content of the given HTMLElement.- Parameters:
element- The HTMLElement to retrieve the text content from.- Returns:
- The text content of the HTMLElement. If there is a text node present, it returns the value of the text node. If there is no text node, returns the text content of the element.
-
textNode
Returns the text content of the given element.- Type Parameters:
E- the type constraint for the element- Parameters:
element- the element from which to extract the text content- Returns:
- the text content of the element, or null if the element is null
-
textNode
Changes the text of the first text node (if any) or adds the given text as a new text node. Use this method instead ofNode.textContentif you want to preserve existing child elements.- Parameters:
element- The HTMLElement to retrieve the text content from.text- The text to set
-
textNode
Changes the text of the first text node (if any) or adds the given text as a new text node. Use this method instead ofNode.textContentif you want to preserve existing child elements.- Type Parameters:
E- the type constraint for the element- Parameters:
element- The HTMLElement to retrieve the text content from.text- The text to set
-
toString
-
toString
-