com.vaadin.flow.dom.
Class Element
- java.lang.Object
-
- com.vaadin.flow.dom.Node<Element>
-
- com.vaadin.flow.dom.Element
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Element(StateNode node, ElementStateProvider stateProvider)
Private constructor for initializing with an existing node and state provider.
Element(String tag)
Creates an element using the given tag name.
-
Method Summary
All Methods Modifier and Type Method Description Registration
addAttachListener(ElementAttachListener attachListener)
Adds an attach listener for this element.
Registration
addDetachListener(ElementDetachListener detachListener)
Adds a detach listener for this element.
DomListenerRegistration
addEventListener(String eventType, DomEventListener listener)
Adds an event listener for the given event type.
Registration
addPropertyChangeListener(String name, PropertyChangeListener listener)
Adds a property change listener which is triggered when the property's value is updated on the server side.
DomListenerRegistration
addPropertyChangeListener(String propertyName, String domEventName, PropertyChangeListener listener)
Adds a property change listener and configures the property to be synchronized to the server when a given DOM event is fired.
<T extends Component>
Tas(Class<T> componentType)
Creates a new component instance using this element.
ShadowRoot
attachShadow()
Attaches shadow root node.
void
callFunction(String functionName, Serializable... arguments)
Deprecated.
UsecallJsFunction(String,Serializable...)
instead since it also allows getting return value back.PendingJavaScriptResult
callJsFunction(String functionName, Serializable... arguments)
Calls the given function on the element with the given arguments.
static Element
createText(String text)
Creates a text node with the given text.
void
executeJavaScript(String expression, Serializable... parameters)
Deprecated.
UseexecuteJs(String,Serializable...)
instead since it also allows getting return value back.PendingJavaScriptResult
executeJs(String expression, Serializable... parameters)
Asynchronously runs the given JavaScript expression in the browser in the context of this element.
static Element
get(StateNode node)
Gets the element mapped to the given state node.
static Element
get(StateNode node, ElementStateProvider stateProvider)
Gets the element mapped to the given state node and element state provider.
String
getAttribute(String attribute)
Gets the value of the given attribute.
Stream<String>
getAttributeNames()
Gets the defined attribute names.
Element
getChild(int index)
Returns the child element at the given position.
int
getChildCount()
Gets the number of child elements.
Stream<Element>
getChildren()
Gets all the children of this element.
ClassList
getClassList()
Gets the set of CSS class names used for this element.
Optional<Component>
getComponent()
Gets the component this element has been mapped to, if any.
String
getOuterHTML()
Gets the outer HTML for the element.
Element
getParent()
Gets the parent element.
String
getProperty(String name)
Gets the value of the given property as a string.
boolean
getProperty(String name, boolean defaultValue)
Gets the value of the given property as a boolean, or the given default value if the underlying value is
null
.double
getProperty(String name, double defaultValue)
Gets the value of the given property as a double, or the given default value if the underlying value is
null
int
getProperty(String name, int defaultValue)
Gets the value of the given property as an integer, or the given default value if the underlying value is
null
String
getProperty(String name, String defaultValue)
Gets the value of the given property as a string.
Stream<String>
getPropertyNames()
Gets the defined property names.
Serializable
getPropertyRaw(String name)
Gets the raw property value without any value conversion.
protected Element
getSelf()
Gets the narrow typed reference to this object.
Optional<ShadowRoot>
getShadowRoot()
Gets the shadow root of the element, if any.
Style
getStyle()
Gets the style instance for managing element inline styles.
String
getTag()
Gets the tag name for the element.
String
getText()
Gets the text content of this element.
String
getTextRecursively()
Gets the text content of this element tree.
ThemeList
getThemeList()
Gets the set of the theme names applied to the corresponding element in
theme
attribute.boolean
hasAttribute(String attribute)
Checks if the given attribute has been set.
boolean
hasProperty(String name)
Checks whether this element has a property with the given name.
boolean
isEnabled()
Get the enabled state of the element.
boolean
isTextNode()
Checks whether this element represents a text node.
boolean
isVisible()
Gets the element visibility value.
Element
removeAttribute(String attribute)
Removes the given attribute.
Element
removeFromParent()
Removes this element from its parent.
Element
removeFromTree()
Removes this element from its parent and state tree.
Element
removeProperty(String name)
Removes the given property.
Element
scrollIntoView()
Executes the similarly named DOM method on the client side.
Element
setAttribute(String attribute, boolean value)
Sets the given attribute to the given boolean value.
Element
setAttribute(String attribute, AbstractStreamResource resource)
Sets the given attribute to the given
StreamResource
value.Element
setAttribute(String attribute, String value)
Sets the given attribute to the given value.
Element
setEnabled(boolean enabled)
Sets the enabled state of the element.
Element
setProperty(String name, boolean value)
Sets the given property to the given boolean value.
Element
setProperty(String name, double value)
Sets the given property to the given numeric value.
Element
setProperty(String name, String value)
Sets the given property to the given string value.
Element
setPropertyBean(String name, Object value)
Sets the given property to the given bean, converted to a JSON object.
Element
setPropertyJson(String name, elemental.json.JsonValue value)
Sets the given property to the given JSON value.
<T> Element
setPropertyList(String name, List<T> value)
Sets the given property to the given list of beans or primitive values, converted to a JSON array.
Element
setPropertyMap(String name, Map<String,?> value)
Sets the given property to the given map of beans or primitive values, converted to a JSON object.
Element
setText(String textContent)
Sets the text content of this element, replacing any existing children.
Element
setVisible(boolean visible)
Sets the element visibility value.
String
toString()
-
Methods inherited from class com.vaadin.flow.dom.Node
accept, appendChild, appendVirtualChild, ensureChildHasParent, equals, getNode, getParentNode, getStateProvider, hashCode, indexOfChild, insertChild, isVirtualChild, removeAllChildren, removeChild, removeChild, removeVirtualChild, setChild
-
-
-
-
Constructor Detail
-
Element
protected Element(StateNode node, ElementStateProvider stateProvider)
Private constructor for initializing with an existing node and state provider.
Parameters:
node
- the state node, not nullstateProvider
- the state provider, not null
-
Element
public Element(String tag)
Creates an element using the given tag name.
Parameters:
tag
- the tag name of the element. Must be a non-empty string and can contain letters, numbers and dashes (-)
-
-
Method Detail
-
get
public static Element get(StateNode node)
Gets the element mapped to the given state node.
Parameters:
node
- the state node, notnull
Returns:
the element for the node, not
null
-
get
public static Element get(StateNode node, ElementStateProvider stateProvider)
Gets the element mapped to the given state node and element state provider.
Parameters:
node
- the state nodestateProvider
- the element state providerReturns:
an element for the node and state provider, not
null
-
getChildCount
public int getChildCount()
Gets the number of child elements.
If the property "innerHTML" has been set explicitly then its value (the new element structure) won't be populated on the server side and this method will return
0
.Overrides:
getChildCount
in classNode<Element>
Returns:
the number of child elements
See Also:
-
getChild
public Element getChild(int index)
Returns the child element at the given position.
If property "innerHTML" has been set explicitly then its value (the new element structure) won't be populated on the server side and this method will not work.
-
getChildren
public Stream<Element> getChildren()
Gets all the children of this element.
If property "innerHTML" has been set explicitly then its value (the new element structure) won't be populated on the server side and this method returns an empty stream.
Overrides:
getChildren
in classNode<Element>
Returns:
a stream of children
See Also:
-
createText
public static Element createText(String text)
Creates a text node with the given text.
Parameters:
text
- the text in the node,null
is interpreted as an empty stringReturns:
an element representing the text node, never
null
-
getTag
public String getTag()
Gets the tag name for the element.
Returns:
the tag name
-
setAttribute
public Element setAttribute(String attribute, String value)
Sets the given attribute to the given value.
Attribute names are considered case insensitive and all names will be converted to lower case automatically.
An attribute always has a String key and a String value.
Note: An empty attribute value ("") will be rendered as <div something> and not <div something="">.
Note that setting the attribute
class
will override anything that has been set previously viagetClassList()
.Note that you cannot set the attribute
style
using this method. Instead you should usegetStyle()
object.Note that attribute changes made on the server are sent to the client but attribute changes made on the client side are not reflected back to the server.
Parameters:
attribute
- the name of the attributevalue
- the value of the attribute, not nullReturns:
this element
-
setAttribute
public Element setAttribute(String attribute, boolean value)
Sets the given attribute to the given boolean value. Setting the value to
true
will internally set the value to""
, which will be rendered as <div name>, i.e. without any explicit value. Setting the value tofalse
is a shorthand for removing the attribute.Use
hasAttribute(String)
to check whether a boolean attribute has been set.Attribute names are considered case insensitive and all names will be converted to lower case automatically.
Parameters:
attribute
- the name of the attributevalue
- the value of the attributeReturns:
this element
See Also:
-
setAttribute
public Element setAttribute(String attribute, AbstractStreamResource resource)
Sets the given attribute to the given
StreamResource
value.Attribute names are considered case insensitive and all names will be converted to lower case automatically.
This is a convenience method to register a
StreamResource
instance into the session and use the registered resource URI as an element attribute.Parameters:
attribute
- the name of the attributeresource
- the resource value, not nullReturns:
this element
See Also:
-
getAttribute
public String getAttribute(String attribute)
Gets the value of the given attribute.
Attribute names are considered case insensitive and all names will be converted to lower case automatically.
An attribute always has a String key and a String value.
Note that for attribute
class
the contents of thegetClassList()
collection are returned as a single concatenated string.Note that for attribute
style
the contents of thegetStyle()
object are returned as a single concatenated string.Note that attribute changes made on the server are sent to the client but attribute changes made on the client side are not reflected back to the server.
Parameters:
attribute
- the name of the attributeReturns:
the value of the attribute or null if the attribute has not been set
-
hasAttribute
public boolean hasAttribute(String attribute)
Checks if the given attribute has been set.
Attribute names are considered case insensitive and all names will be converted to lower case automatically.
Note that attribute changes made on the server are sent to the client but attribute changes made on the client side are not reflected back to the server.
Parameters:
attribute
- the name of the attributeReturns:
true if the attribute has been set, false otherwise
-
getAttributeNames
public Stream<String> getAttributeNames()
Gets the defined attribute names.
Attribute names are considered case insensitive and all names will be converted to lower case automatically.
Note that attribute changes made on the server are sent to the client but attribute changes made on the client side are not reflected back to the server.
Returns:
a stream of defined attribute names
-
removeAttribute
public Element removeAttribute(String attribute)
Removes the given attribute.
Attribute names are considered case insensitive and all names will be converted to lower case automatically.
If the attribute has not been set, does nothing.
Note that attribute changes made on the server are sent to the client but attribute changes made on the client side are not reflected back to the server.
Parameters:
attribute
- the name of the attributeReturns:
this element
-
addEventListener
public DomListenerRegistration addEventListener(String eventType, DomEventListener listener)
Adds an event listener for the given event type.
Event listeners are triggered in the order they are registered.
Parameters:
eventType
- the type of event to listen to, notnull
listener
- the listener to add, notnull
Returns:
a handle that can be used for configuring or removing the listener
See Also:
-
removeFromParent
public Element removeFromParent()
Removes this element from its parent.
Has no effect if the element does not have a parent
Returns:
this element
-
removeFromTree
public Element removeFromTree()
Removes this element from its parent and state tree.
Returns:
this element
-
getParent
public Element getParent()
Gets the parent element.
The method may return
null
if the parent is not an element but aNode
.Returns:
the parent element or null if this element does not have a parent or the parent is not an element
See Also:
-
setProperty
public Element setProperty(String name, String value)
Sets the given property to the given string value.
Note in order to update the following properties, you need to use the specific API for that:
Properties with different API Property Method classList / className getClassList()
style getStyle()
textContent getText()
andgetTextRecursively()
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.The "innerHTML" property has an impact on the descendants structure of the element. So setting the "innerHTML" property removes all the children.
Parameters:
name
- the property name, notnull
value
- the property valueReturns:
this element
-
setProperty
public Element setProperty(String name, boolean value)
Sets the given property to the given boolean value.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name, notnull
value
- the property valueReturns:
this element
-
setProperty
public Element setProperty(String name, double value)
Sets the given property to the given numeric value.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name, notnull
value
- the property valueReturns:
this element
-
setPropertyJson
public Element setPropertyJson(String name, elemental.json.JsonValue value)
Sets the given property to the given JSON value.
Please note that this method does not accept
null
as a value, sinceJson.createNull()
should be used instead for JSON values.Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name, notnull
value
- the property value, notnull
Returns:
this element
-
setPropertyBean
public Element setPropertyBean(String name, Object value)
Sets the given property to the given bean, converted to a JSON object.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name, notnull
value
- the property value, notnull
Returns:
this element
-
setPropertyList
public <T> Element setPropertyList(String name, List<T> value)
Sets the given property to the given list of beans or primitive values, converted to a JSON array.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Type Parameters:
T
- the type of items in the listParameters:
name
- the property name, notnull
value
- the property value, notnull
Returns:
this element
-
setPropertyMap
public Element setPropertyMap(String name, Map<String,?> value)
Sets the given property to the given map of beans or primitive values, converted to a JSON object.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name, notnull
value
- the property value, notnull
Returns:
this element
-
addPropertyChangeListener
public Registration addPropertyChangeListener(String name, PropertyChangeListener listener)
Adds a property change listener which is triggered when the property's value is updated on the server side.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name to add the listener for, notnull
listener
- listener to get notifications about property value changes, notnull
Returns:
an event registration handle for removing the listener
See Also:
addPropertyChangeListener(String, String, PropertyChangeListener)
-
addPropertyChangeListener
public DomListenerRegistration addPropertyChangeListener(String propertyName, String domEventName, PropertyChangeListener listener)
Adds a property change listener and configures the property to be synchronized to the server when a given DOM event is fired. #see
addPropertyChangeListener(String, PropertyChangeListener)
Parameters:
propertyName
- the name of the element property to listen to, notnull
domEventName
- the name of the DOM event for which the property should be synchronized to the server, notnull
listener
- the property change listener not add, notnull
Returns:
a handle that can be used for configuring or removing the listener
Since:
1.3
-
getProperty
public String getProperty(String name, String defaultValue)
Gets the value of the given property as a string. The returned value is converted to a string if it has been set as some other type.
Parameters:
name
- the property name, notnull
defaultValue
- the value to return if the property is not set, or if the value isnull
Returns:
the property value
-
getProperty
public String getProperty(String name)
Gets the value of the given property as a string.
Parameters:
name
- the property name, notnull
Returns:
the property value, or
null
if no value is set
-
getProperty
public boolean getProperty(String name, boolean defaultValue)
Gets the value of the given property as a boolean, or the given default value if the underlying value is
null
.A value defined as some other type than boolean is converted according to JavaScript semantics:
- String values are
true
, except for the empty string. - Numerical values are
true
, except for 0 andNaN
. - JSON object and JSON array values are always
true
.
Parameters:
name
- the property name, notnull
defaultValue
- the value to return if the property is not set, or if the value isnull
Returns:
the property value
- String values are
-
getProperty
public double getProperty(String name, double defaultValue)
Gets the value of the given property as a double, or the given default value if the underlying value is
null
A value defined as some other type than double is converted according to JavaScript semantics:
- String values are parsed to a number.
NaN
is returned if the string can't be parsed. - boolean
true
is 1, booleanfalse
is 0. - JSON object and JSON array values are always
NaN
.
Parameters:
name
- the property name, notnull
defaultValue
- the value to return if the property is not set, or if the value isnull
Returns:
the property value
- String values are parsed to a number.
-
getProperty
public int getProperty(String name, int defaultValue)
Gets the value of the given property as an integer, or the given default value if the underlying value is
null
The value is converted in the same way as for
getProperty(String, double)
, and then truncated toint
.Parameters:
name
- the property name, notnull
defaultValue
- the value to return if the property is not set, or if the value isnull
Returns:
the property value
-
getPropertyRaw
public Serializable getPropertyRaw(String name)
Gets the raw property value without any value conversion. The type of the value is
String
,Double
,Boolean
orJsonValue
.null
is returned if there is no property with the given name or if the value is set tonull
.Parameters:
name
- the property name, not nullReturns:
the raw property value, or
null
-
removeProperty
public Element removeProperty(String name)
Removes the given property.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
andDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name, notnull
Returns:
this element
-
hasProperty
public boolean hasProperty(String name)
Checks whether this element has a property with the given name.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Parameters:
name
- the property name, notnull
Returns:
true
if the property is present; otherwisefalse
-
getPropertyNames
public Stream<String> getPropertyNames()
Gets the defined property names.
Note that properties changed on the server are updated on the client but changes made on the client side are not reflected back to the server unless configured using
addPropertyChangeListener(String, String, PropertyChangeListener)
orDomListenerRegistration.synchronizeProperty(String)
.Returns:
a stream of defined property names
-
isTextNode
public boolean isTextNode()
Checks whether this element represents a text node.
Returns:
true
if this element is a text node; otherwisefalse
-
setText
public Element setText(String textContent)
Sets the text content of this element, replacing any existing children.
Parameters:
textContent
- the text content to set,null
is interpreted as an empty stringReturns:
this element
-
getText
public String getText()
Gets the text content of this element. This includes only the text from any immediate child text nodes, but ignores text inside child elements. Use
getTextRecursively()
to get the full text that recursively includes the text content of the entire element tree.Returns:
the text content of this element
See Also:
-
getTextRecursively
public String getTextRecursively()
Gets the text content of this element tree. This includes the text content of all child nodes recursively. Use
getText()
to only get the text from text nodes that are immediate children of this element.Returns:
the text content of this element and all child elements
See Also:
-
getClassList
public ClassList getClassList()
Gets the set of CSS class names used for this element. The returned set can be modified to add or remove class names. The contents of the set is also reflected in the value of the
class
attribute.Despite the name implying a list being returned, the return type is actually a
Set
since the in-browser return value behaves like aSet
in Java.Returns:
a list of class names, never
null
-
getThemeList
public ThemeList getThemeList()
Gets the set of the theme names applied to the corresponding element in
theme
attribute. The set returned can be modified to add or remove the theme names, changes to the set will be reflected in the attribute value.Despite the name implying a list being returned, the return type is actually a
Set
since the in-browser return value behaves like aSet
in Java.Returns:
a list of theme names, never
null
-
getStyle
public Style getStyle()
Gets the style instance for managing element inline styles.
Returns:
the style object for the element
-
getComponent
public Optional<Component> getComponent()
Gets the component this element has been mapped to, if any.
Returns:
an optional component, or an empty optional if no component has been mapped to this element
-
addAttachListener
public Registration addAttachListener(ElementAttachListener attachListener)
Adds an attach listener for this element. It is invoked when the element is attached to a UI.
When a hierarchy of elements is being attached, the event is fired child-first.
Parameters:
attachListener
- the attach listener to addReturns:
an event registration handle for removing the listener
-
addDetachListener
public Registration addDetachListener(ElementDetachListener detachListener)
Adds a detach listener for this element. It is invoked when the element is detached from a UI.
When a hierarchy of elements is being detached, the event is fired child-first.
Parameters:
detachListener
- the detach listener to addReturns:
an event registration handle for removing the listener
-
getOuterHTML
public String getOuterHTML()
Gets the outer HTML for the element.
This operation recursively iterates the element and all children and should not be called unnecessarily.
Returns:
the outer HTML for the element
-
as
public <T extends Component> T as(Class<T> componentType)
Creates a new component instance using this element.
You can use this method when you have an element instance and want to use it through the API of a
Component
class.This method makes the component instance use the underlying element but does not attach the new component instance to the element so that
getComponent()
would return the component instance. This means thatgetParent()
,getChildren()
and possibly other methods which rely onElement
->Component
mappings will not work.To also map the element to the
Component
instance, useComponent.from(Element, Class)
Type Parameters:
T
- the component typeParameters:
componentType
- the component typeReturns:
the component instance connected to the given element
See Also:
-
callFunction
@Deprecated public void callFunction(String functionName, Serializable... arguments)
Deprecated.UsecallJsFunction(String,Serializable...)
instead since it also allows getting return value back.Calls the given function on the element with the given arguments.
The function will be called after all pending DOM updates have completed, at the same time that
Page.executeJs(String, Serializable...)
calls are invoked.If the element is not attached, the function call will be deferred until the element is attached.
Parameters:
functionName
- the name of the function to call, may contain dots to indicate a function on a property.arguments
- the arguments to pass to the function. Must be of a type supported by the communication mechanism, as defined byJsonCodec
See Also:
-
callJsFunction
public PendingJavaScriptResult callJsFunction(String functionName, Serializable... arguments)
Calls the given function on the element with the given arguments.
It is possible to get access to the return value of the execution by registering a handler with the returned pending result. If no handler is registered, the return value will be ignored.
The function will be called after all pending DOM updates have completed, at the same time that
Page.executeJs(String, Serializable...)
calls are invoked.If the element is not attached, the function call will be deferred until the element is attached.
Parameters:
functionName
- the name of the function to call, may contain dots to indicate a function on a property.arguments
- the arguments to pass to the function. Must be of a type supported by the communication mechanism, as defined byJsonCodec
Returns:
a pending result that can be used to get a return value from the execution
See Also:
-
executeJavaScript
@Deprecated public void executeJavaScript(String expression, Serializable... parameters)
Deprecated.UseexecuteJs(String,Serializable...)
instead since it also allows getting return value back.Asynchronously runs the given JavaScript expression in the browser in the context of this element. This element will be available to the expression as
this
. The given parameters will be available as variables named$0
,$1
, and so on. Supported parameter types are:String
Integer
Double
Boolean
JsonValue
Element
(will be sent asnull
if the server-side element instance is not attached when the invocation is sent to the client)
'prefix' + $0
instead of'prefix$0'
andvalue[$0]
instead ofvalue.$0
since JavaScript variables aren't evaluated inside strings or property names.Parameters:
expression
- the JavaScript expression to invokeparameters
- parameters to pass to the expression
-
executeJs
public PendingJavaScriptResult executeJs(String expression, Serializable... parameters)
Asynchronously runs the given JavaScript expression in the browser in the context of this element. The returned
PendingJavaScriptResult
can be used to retrieve anyreturn
value from the JavaScript expression. If no return value handler is registered, the return value will be ignored.This element will be available to the expression as
this
. The given parameters will be available as variables named$0
,$1
, and so on. Supported parameter types are:String
Integer
Double
Boolean
JsonValue
Element
(will be sent asnull
if the server-side element instance is not attached when the invocation is sent to the client)
'prefix' + $0
instead of'prefix$0'
andvalue[$0]
instead ofvalue.$0
since JavaScript variables aren't evaluated inside strings or property names.Parameters:
expression
- the JavaScript expression to invokeparameters
- parameters to pass to the expressionReturns:
a pending result that can be used to get a value returned from the expression
-
attachShadow
public ShadowRoot attachShadow()
Attaches shadow root node.
Returns:
the attached shadow root
-
getShadowRoot
public Optional<ShadowRoot> getShadowRoot()
Gets the shadow root of the element, if any.
Returns:
an optional shadow root node, or an empty optional if no shadow root has been attached
-
setVisible
public Element setVisible(boolean visible)
Sets the element visibility value.
Parameters:
visible
- the element visibility valueReturns:
this element
-
isVisible
public boolean isVisible()
Gets the element visibility value.
Returns:
true
if the element is visible,false
otherwise
-
setEnabled
public Element setEnabled(boolean enabled)
Sets the enabled state of the element.
Parameters:
enabled
- the enabled stateReturns:
the element
-
isEnabled
public boolean isEnabled()
Get the enabled state of the element.
Object may be enabled by itself by but if its ascendant is disabled then it's considered as (implicitly) disabled.
Returns:
true
if node is enabled,false
otherwise
-
getSelf
protected Element getSelf()
Description copied from class:
Node
Gets the narrow typed reference to this object.
-
scrollIntoView
public Element scrollIntoView()
Executes the similarly named DOM method on the client side.
Returns:
the element
See Also:
-
-