com.vaadin.flow.component.shared.
Class SlotUtils
Util methods for handling child elements inside slots.
Author:
Vaadin Ltd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addToSlot
(HasElement parent, String slot, Component... components) Adds components to the specified slot in the parent component.
static void
addToSlot
(HasElement parent, String slot, Element... elements) Adds elements to the specified slot in the parent component.
static void
clearSlot
(HasElement parent, String slot) Removes every child element of the parent that are in the specified slot.
static Component
getChildInSlot
(HasElement parent, String slot) Gets the first child component of the parent that is in the specified slot.
getElementsInSlot
(HasElement parent, String slot) Gets all the child elements of the parent that are in the specified slot.
static void
setSlot
(HasElement parent, String slot, Component... components) Clears the specific slot in the parent component and adds components to it.
static void
setSlot
(HasElement parent, String slot, Element... elements) Clears the specific slot in the parent component and adds elements to it.
-
Constructor Details
-
SlotUtils
public SlotUtils()
-
-
Method Details
-
getElementsInSlot
Gets all the child elements of the parent that are in the specified slot.
Parameters:
parent
- the component to get children from, notnull
slot
- the name of the slot inside the parent, notnull
Returns:
the child elements of the parent that are inside the slot
-
clearSlot
Removes every child element of the parent that are in the specified slot.
Parameters:
parent
- the component whose slot to clearslot
- the name of the slot to clear -
getChildInSlot
Gets the first child component of the parent that is in the specified slot.
Parameters:
parent
- the component to get child from, notnull
slot
- the name of the slot inside the parent, notnull
Returns:
a child component of the parent in the specified slot, or
null
if none is found -
addToSlot
Adds components to the specified slot in the parent component.
Parameters:
parent
- the parent component to add the components to, notnull
slot
- the name of the slot inside the parent, notnull
components
- components to add to the specified slot.Throws:
IllegalArgumentException
- if any of the components is aText
component.NullPointerException
- if the components array is null. -
addToSlot
Adds elements to the specified slot in the parent component.
Parameters:
parent
- the parent component to add the elements to, notnull
slot
- the name of the slot inside the parent, notnull
elements
- elements to add to the specified slot.Throws:
NullPointerException
- if the elements array is null. -
setSlot
Clears the specific slot in the parent component and adds components to it.
Parameters:
parent
- the parent component to add the components to, notnull
slot
- the name of the slot inside the parent, notnull
components
- components to add to the specified slot.Throws:
NullPointerException
- if the components array is null. -
setSlot
Clears the specific slot in the parent component and adds elements to it.
Parameters:
parent
- the parent component to add the elements to, notnull
slot
- the name of the slot inside the parent, notnull
elements
- elements to add to the specified slot.Throws:
NullPointerException
- if the elements array is null.
-