Package org.jboss.elemento
Class Elements
java.lang.Object
org.jboss.elemento.Elements
Builder and helper methods for working with
HTMLElement
s 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 ElementsBag
bag()
Deprecated.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> static String
Deprecated.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 boolean
failSafeRemove
(Node parent, Element child) Removes the child from parent if both parent and child are not null and parent contains child.static <E extends HTMLElement>
booleanfailSafeRemove
(Node parent, IsElement<E> child) Removes the child from parent if both parent and child are not null and parent contains child.static boolean
failSafeRemoveFromParent
(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 <E extends HTMLElement>
EDeprecated.Replaced byquerySelector(Node, By)
static <E extends HTMLElement,
F extends HTMLElement>
FDeprecated.Replaced byquerySelector(IsElement, By)
static Iterable
<HTMLElement> Deprecated.Replaced byquerySelectorAll(Node, By)
static <E extends HTMLElement>
Iterable<HTMLElement> Deprecated.Replaced byquerySelectorAll(IsElement, By)
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 void
Convenience 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 <E extends HTMLInputElement>
HTMLInputElementBuilder<E> inputElement
(String type, Class<E> jType) Returns a builder for the specified input element.static HTMLContainerBuilder
<HTMLModElement> ins()
static HTMLContainerBuilder
<HTMLModElement> static HTMLContainerBuilder
<HTMLModElement> static void
insertAfter
(Element newElement, Element after) Inserts elementnewElement
into the parent after elementafter
.static <E extends HTMLElement>
voidinsertAfter
(IsElement<E> newElement, Element after) Inserts elementnewElement
into the parent after elementafter
.static void
insertBefore
(Element newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
.static <E extends HTMLElement>
voidinsertBefore
(IsElement<E> newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
.static void
insertFirst
(Element parent, Element newElement) Inserts elementnewElement
as the first element intoparent
.static <E extends HTMLElement>
voidinsertFirst
(Element parent, IsElement<E> newElement) Inserts elementnewElement
as the first element intoparent
.static boolean
isAttached
(Node node) Fail-safe shortcut forNode.isConnected
static <E extends HTMLElement>
booleanisAttached
(IsElement<E> element) Returnstrue
if the element is connected by callingNode.isConnected
on the element'sIsElement.element()
.static boolean
isElementInView
(HTMLElement element) static boolean
isElementInView
(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 boolean
isVisible
(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 void
lazyAppend
(Element parent, Element child) Appends elementchild
to elementparent
if not already present.static <E extends HTMLElement>
voidlazyAppend
(Element parent, IsElement<E> child) Appends elementchild
to elementparent
if not already present.static void
lazyInsertAfter
(Element newElement, Element after) Inserts elementnewElement
into the parent after elementafter
if not already present.static void
lazyInsertAfter
(Element parent, Element newElement, Element after) Inserts elementnewElement
into the parent after elementafter
if not already present.static <E extends HTMLElement>
voidlazyInsertAfter
(Element parent, IsElement<E> newElement, Element after) Inserts elementnewElement
into the parent after elementafter
if not already present.static <E extends HTMLElement>
voidlazyInsertAfter
(IsElement<E> newElement, Element after) Inserts elementnewElement
into the parent after elementafter
if not already present.static void
lazyInsertBefore
(Element newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
if not already present.static void
lazyInsertBefore
(Element parent, Element newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
if not already present.static <E extends HTMLElement>
voidlazyInsertBefore
(Element parent, IsElement<E> newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
if not already present.static <E extends HTMLElement>
voidlazyInsertBefore
(IsElement<E> newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
if 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 void
onAttach
(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 void
onDetach
(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 void
removeChildrenFrom
(Element element) Removes all child elements fromelement
static <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 void
setVisible
(HTMLElement element, boolean visible) Shows / hide the specified element by modifying thedisplay
property.static <E extends HTMLElement>
voidsetVisible
(IsElement<E> element, boolean visible) Shows / hide the specified element by modifying thedisplay
property.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 <E extends HTMLTextAreaElement>
HTMLTextAreaElementBuilder<E> static String
Returns the text content of the given HTMLElement.static void
Changes 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 void
toggle
(HTMLElement element, String css, boolean condition) Adds the specified CSS class to the element ifcondition
istrue
, removes it otherwise.static void
toggle
(HTMLElement element, String css, Supplier<Boolean> condition) Adds the specified CSS class to the element ifcondition
istrue
, removes it otherwise.static <E extends HTMLElement>
voidAdds the specified CSS class to the element ifcondition
istrue
, removes it otherwise.static <E extends HTMLElement>
voidAdds the specified CSS class to the element ifcondition
istrue
, removes it otherwise.static String
tr()
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 String
uniqueId()
Deprecated.Replaced bvId.unique()
static String
Deprecated.Replaced bvId.unique(String, String...)
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 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
public static <E extends HTMLTextAreaElement> HTMLTextAreaElementBuilder<E> textarea(Class<E> jType) -
textarea
-
htmlElement
public static <E extends HTMLElement> HTMLElementBuilder<E> htmlElement(String element, Class<E> type) Returns a builder for the specified HTML element. -
wrapHtmlElement
Returns a builder for the existing HTML element. -
inputElement
public static <E extends HTMLInputElement> HTMLInputElementBuilder<E> inputElement(String type, Class<E> jType) Returns a builder for the specified input element. -
wrapInputElement
Returns a builder for the existing input element. -
wrapTextAreaElement
public static <E extends HTMLTextAreaElement> HTMLTextAreaElementBuilder<E> wrapTextAreaElement(E element) Returns a builder for the existing text area element. -
htmlContainer
public static <E extends HTMLElement> HTMLContainerBuilder<E> htmlContainer(String element, Class<E> type) Returns a builder for the specified HTML element. -
wrapHtmlContainer
Returns a builder for the existing HTML element. -
createHtmlElement
Creates the specified HTML 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
Returns an iterable interface for the child nodes of the given parent node. -
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
Appends elementchild
to elementparent
if not already present. If a parent already contains a child, this method does nothing. -
lazyAppend
Appends elementchild
to elementparent
if not already present. If a parent already contains a child, this method does nothing. -
insertAfter
Inserts elementnewElement
into the parent after elementafter
. -
insertAfter
Inserts elementnewElement
into the parent after elementafter
. -
lazyInsertAfter
Inserts elementnewElement
into the parent after elementafter
if not already present. If parent already containsnewElement
, this method does nothing. -
lazyInsertAfter
Inserts elementnewElement
into the parent after elementafter
if not already present. If parent already containsnewElement
, this method does nothing. -
lazyInsertAfter
Inserts elementnewElement
into the parent after elementafter
if not already present. If parent already containsnewElement
, this method does nothing. -
lazyInsertAfter
public static <E extends HTMLElement> void lazyInsertAfter(Element parent, IsElement<E> newElement, Element after) Inserts elementnewElement
into the parent after elementafter
if not already present. If parent already containsnewElement
, this method does nothing. -
insertBefore
Inserts elementnewElement
into the parent before elementbefore
. -
insertBefore
Inserts elementnewElement
into the parent before elementbefore
. -
lazyInsertBefore
Inserts elementnewElement
into the parent before elementbefore
if not already present. If parent already containsnewElement
, this method does nothing. -
lazyInsertBefore
public static <E extends HTMLElement> void lazyInsertBefore(IsElement<E> newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
if not already present. If parent already containsnewElement
, this method does nothing. -
lazyInsertBefore
Inserts elementnewElement
into the parent before elementbefore
if not already present. If parent already containsnewElement
, this method does nothing. -
lazyInsertBefore
public static <E extends HTMLElement> void lazyInsertBefore(Element parent, IsElement<E> newElement, Element before) Inserts elementnewElement
into the parent before elementbefore
if not already present. If parent already containsnewElement
, this method does nothing. -
insertFirst
Inserts elementnewElement
as the first element intoparent
. -
insertFirst
Inserts elementnewElement
as the first element intoparent
. -
removeChildrenFrom
Removes all child elements fromelement
-
removeChildrenFrom
Removes all child elements fromelement
-
failSafeRemoveFromParent
Removes the element from its parent if the element is not null and has a parent.- Returns:
true
if the element has been removed from its parent,false
otherwise.
-
failSafeRemoveFromParent
Removes the element from its parent if the element is not null and has a parent.- Returns:
true
if the element has been removed from its parent,false
otherwise.
-
failSafeRemove
Removes the child from parent if both parent and child are not null and parent contains child.- Returns:
true
if the element has been removed from its parent,false
otherwise.
-
failSafeRemove
Removes the child from parent if both parent and child are not null and parent contains child.- Returns:
true
if the element has been removed from its parent,false
otherwise.
-
isAttached
Returnstrue
if the element is connected by callingNode.isConnected
on the element'sIsElement.element()
.- See Also:
-
isAttached
Fail-safe shortcut forNode.isConnected
- See Also:
-
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.display
is notnone
) -
isVisible
Checks whether the given element is visible (i.e.display
is notnone
) -
setVisible
Shows / hide the specified element by modifying thedisplay
property. -
setVisible
Shows / hide the specified element by modifying thedisplay
property. -
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:
true
if 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
ResizeObserver
if 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
ResizeObserver
if 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 ifcondition
istrue
, 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 ifcondition
istrue
, removes it otherwise. -
toggle
Adds the specified CSS class to the element ifcondition
istrue
, 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 ifcondition
istrue
, 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.textContent
if 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.textContent
if 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
-
bag
Deprecated. -
uniqueId
Deprecated.Replaced bvId.unique()
-
uniqueId
Deprecated.Replaced bvId.unique(String, String...)
-
buildId
Deprecated.Replaced bvId.build(String, String...)
-
findAll
Deprecated.Replaced byquerySelectorAll(Node, By)
-
findAll
@Deprecated public static <E extends HTMLElement> Iterable<HTMLElement> findAll(IsElement<E> element, By selector) Deprecated.Replaced byquerySelectorAll(IsElement, By)
-
find
Deprecated.Replaced byquerySelector(Node, By)
-
find
@Deprecated public static <E extends HTMLElement,F extends HTMLElement> F find(IsElement<E> element, By selector) Deprecated.Replaced byquerySelector(IsElement, By)
-
Id.build(String, String...)