com.vaadin.flow.dom.
Class ElementUtil
Provides utility methods for Element
.
Since:
1.0
Author:
Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionGets the element mapped to the given state node.
fromJsoup
(org.jsoup.nodes.Node node) Converts a given JSoup
Node
and its children into a matchingElement
hierarchy.static boolean
isCustomElement
(Element element) Checks whether the given element is a custom element or not.
static boolean
Checks whether the given element is a
script
or not.static boolean
isValidAttributeName
(String attribute) Checks if the given attribute name is valid.
static boolean
Checks if the given style property name is valid.
static boolean
isValidStylePropertyValue
(String value) Checks if the given style property value is valid.
static boolean
isValidTagName
(String tag) Checks if the given tag name is valid.
static void
setComponent
(Element element, Component component) Defines a mapping between this element and the given
Component
.static void
setIgnoreParentInert
(Element element, boolean ignoreParentInert) Sets whether or not the element should inherit or not inherit its parent's inert state.
static void
Sets whether or not the given element is inert.
static org.jsoup.nodes.Node
Converts the given element and its children to a JSoup node with children.
static void
Validates the given style property name and throws an exception if the name is invalid.
static void
validateStylePropertyValue
(String value) Checks if the given style property value is valid.
-
Method Details
-
isValidTagName
Checks if the given tag name is valid.
Parameters:
tag
- the tag nameReturns:
true if the string is valid as a tag name, false otherwise
-
isValidAttributeName
Checks if the given attribute name is valid.
Parameters:
attribute
- the name of the attribute in lower caseReturns:
true if the name is valid, false otherwise
-
validateStylePropertyName
Validates the given style property name and throws an exception if the name is invalid.
Parameters:
name
- the style property name to validate -
isValidStylePropertyName
Checks if the given style property name is valid.
Parameters:
name
- the name to validateReturns:
true if the name is valid, false otherwise
-
isValidStylePropertyValue
Checks if the given style property value is valid.
Parameters:
value
- the value to validateReturns:
true if the value is valid, false otherwise
-
validateStylePropertyValue
Checks if the given style property value is valid.
Throws an exception if it's certain the value is invalid
Parameters:
value
- the value to validate -
setComponent
Defines a mapping between this element and the given
Component
.An element can only be mapped to one component and the mapping cannot be changed. The only exception is
Composite
which can overwrite the mapping for its content.Parameters:
element
- the element to map to the componentcomponent
- the component this element is attached to -
toJsoup
Converts the given element and its children to a JSoup node with children.
Parameters:
document
- A JSoup documentelement
- The element to convertReturns:
A JSoup node containing the converted element
-
fromJsoup
Converts a given JSoup
Node
and its children into a matchingElement
hierarchy.Only nodes of type
TextNode
andElement
are converted - other node types return an empty optional.Parameters:
node
- JSoup node to convertReturns:
element with the matching hierarchy as the given node, or empty
-
isCustomElement
Checks whether the given element is a custom element or not.
Custom elements (Web Components) are recognized by having at least one dash in the tag name.
Parameters:
element
- the element to checkReturns:
true
if a custom element,false
if not -
isScript
Checks whether the given element is a
script
or not.Parameters:
element
- the element to checkReturns:
true
if a script,false
if not -
setIgnoreParentInert
Sets whether or not the element should inherit or not inherit its parent's inert state. Default value is
false
.Parameters:
element
- the element to updateignoreParentInert
-true
for ignoring parent inert,false
for not ignoringSee Also:
-
setInert
Sets whether or not the given element is inert. When an element is inert, it does not receive any updates or interaction from the client side. The inert state is inherited to all child elements, unless those are ignoring the inert state.
Parameters:
element
- the element to updateinert
-true
for inertSee Also:
-
from
Gets the element mapped to the given state node.
Parameters:
node
- the state node, notnull
Returns:
the element for the node, or an empty Optional if the state node is not mapped to any particular element.
-