public final class PolymerUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
addReadyListener(elemental.dom.Element polymerElement,
Runnable listener)
Adds the
listener which will be invoked when the
polymerElement becomes "ready" meaning that it's method
ready is called. |
static elemental.json.JsonValue |
createModelTree(Object object)
Makes an attempt to convert an object into json.
|
static void |
fireReadyEvent(elemental.dom.Element polymerElement)
Fires the ready event for the
polymerElement. |
static elemental.dom.Element |
getCustomElement(elemental.dom.Node root,
elemental.json.JsonArray path)
Gets the custom element using
path of indices starting from the
root. |
static elemental.dom.Element |
getDomElementById(elemental.dom.Node shadowRootParent,
String id)
Deprecated.
This is Polymer specific. Use
ElementUtil.getElementById(Node, String) for the
generic version |
static elemental.dom.Element |
getDomRoot(elemental.dom.Node templateElement)
Returns the shadow root of the
templateElement. |
static elemental.dom.Node |
getElementInShadowRootById(elemental.dom.ShadowRoot shadowRoot,
String id)
Deprecated.
This is not in use anywhere and can be removed
|
static String |
getTag(StateNode node)
Gets the tag name of the
node. |
static boolean |
hasTag(elemental.dom.Node node,
String tag)
Deprecated.
Use the generic
ElementUtil.hasTag(Node, String)
instead |
static void |
invokeWhenDefined(String tagName,
Runnable runnable)
Invokes the
runnable when the custom element with the given
tagName is initialized (its DOM structure becomes available). |
static boolean |
isInShadowRoot(elemental.dom.Element element)
Returns true if and only if the element has a shadow root ancestor.
|
static boolean |
isPolymerElement(elemental.dom.Element htmlNode)
Checks whether the
htmlNode is a polymer 2 element. |
static boolean |
isReady(elemental.dom.Node shadowRootParent)
Returns
true if the DOM structure of the polymer custom element
shadowRootParent is ready (meaning that it has shadow root and
its shadow root may be queried for children referenced by id). |
static boolean |
mayBePolymerElement(elemental.dom.Element htmlNode)
Deprecated.
This is not in use anywhere and can be removed
|
static elemental.dom.Node |
searchForElementInShadowRoot(elemental.dom.ShadowRoot shadowRoot,
String cssQuery)
Deprecated.
This is not in use anywhere and can be removed
|
static void |
setListValueByIndex(elemental.dom.Element htmlNode,
String path,
int listIndex,
elemental.json.JsonValue newValue)
Sets new value for list element for specified
htmlNode. |
static void |
setProperty(elemental.dom.Element element,
String path,
Object value)
Sets a property to an element by using the Polymer
set method. |
static void |
splice(elemental.dom.Element htmlNode,
String path,
int startIndex,
int deleteCount,
elemental.json.JsonArray itemsToAdd)
Calls Polymer
splice method on specified htmlNode. |
static void |
storeNodeId(elemental.dom.Node domNode,
int id,
String path)
Store the StateNode.id into the polymer property under 'nodeId'
|
public static void setListValueByIndex(elemental.dom.Element htmlNode,
String path,
int listIndex,
elemental.json.JsonValue newValue)
htmlNode.htmlNode - node to call set method onpath - polymer model path to propertylistIndex - list index to set element intonewValue - new value to be set at desired indexpublic static void splice(elemental.dom.Element htmlNode,
String path,
int startIndex,
int deleteCount,
elemental.json.JsonArray itemsToAdd)
splice method on specified htmlNode.
Splice call is made via apply method in order to force the method
to treat itemsToAdd as numerous parameters, not a single one.htmlNode - node to call splice method onpath - polymer model path to propertystartIndex - start index of a list for splice operationdeleteCount - number of elements to delete from the list after startIndexitemsToAdd - elements to add after startIndexpublic static void storeNodeId(elemental.dom.Node domNode,
int id,
String path)
domNode - polymer dom nodeid - id of a state nodepath - polymer model path to propertypublic static elemental.json.JsonValue createModelTree(Object object)
object - the object to convert to jsonnull for nullpublic static boolean isPolymerElement(elemental.dom.Element htmlNode)
htmlNode is a polymer 2 element.htmlNode - HTML element to checktrue if the htmlNode is a polymer element@Deprecated public static boolean mayBePolymerElement(elemental.dom.Element htmlNode)
htmlNode can turn into polymer 2 element
later.
Lazy loaded dependencies can load Polymer later than the element itself gets processed by the Flow. This method helps to determine such elements.
htmlNode - HTML element to checktrue if the htmlNode can become a polymer 2
element@Deprecated public static elemental.dom.Node searchForElementInShadowRoot(elemental.dom.ShadowRoot shadowRoot, String cssQuery)
shadowRoot - shadow root elementcssQuery - css querynull for no matches@Deprecated public static elemental.dom.Node getElementInShadowRootById(elemental.dom.ShadowRoot shadowRoot, String id)
shadowRoot - shadow root elementid - element idnull for no matches@Deprecated public static elemental.dom.Element getDomElementById(elemental.dom.Node shadowRootParent, String id)
ElementUtil.getElementById(Node, String) for the
generic versionshadowRootParent.shadowRootParent - the parent whose shadow root contains the element with the
idid - the identifier of the element to search forid inside the shadow root of
the parentpublic static boolean isReady(elemental.dom.Node shadowRootParent)
true if the DOM structure of the polymer custom element
shadowRootParent is ready (meaning that it has shadow root and
its shadow root may be queried for children referenced by id).shadowRootParent - the polymer custom elementtrue if the shadowRootParent element is ready@Deprecated public static boolean hasTag(elemental.dom.Node node, String tag)
ElementUtil.hasTag(Node, String)
insteadnode has required tag.node - the node to checktag - the required tag nametrue if the node has required tag namepublic static elemental.dom.Element getCustomElement(elemental.dom.Node root,
elemental.json.JsonArray path)
path of indices starting from the
root.root - the root element to start frompath - the indices path identifying the custom element.root by the path of indicespublic static elemental.dom.Element getDomRoot(elemental.dom.Node templateElement)
templateElement.templateElement - the owner of the shadow rootpublic static void invokeWhenDefined(String tagName, Runnable runnable)
runnable when the custom element with the given
tagName is initialized (its DOM structure becomes available).tagName - the name of the custom elementrunnable - the command to run when the element if initializedpublic static String getTag(StateNode node)
node.node - the node to get the tag name frompublic static void addReadyListener(elemental.dom.Element polymerElement,
Runnable listener)
listener which will be invoked when the
polymerElement becomes "ready" meaning that it's method
ready is called.
The listener won't be called if the element is already "ready" and the listener will be removed immediately once it's executed.
polymerElement - the custom (polymer) element to listen its readiness statelistener - the callback to execute once the element becomes readypublic static void fireReadyEvent(elemental.dom.Element polymerElement)
polymerElement.polymerElement - the custom (polymer) element whose state is "ready"public static void setProperty(elemental.dom.Element element,
String path,
Object value)
set method.element - the element to set the property topath - the path of the propertyvalue - the valuepublic static boolean isInShadowRoot(elemental.dom.Element element)
element - the element to testCopyright © 2000–2026 Vaadin Ltd. All rights reserved.