Class PotentialElement


public class PotentialElement extends Element
EXPERIMENTAL and subject to change. Do not use this in production code.

A simple Element implementation (not an actual dom object) that can serve as stand in to be used by IsRenderable widgets before they are fully built. For example, it can accumulate simple set*() values to be used when the widget is actually ready to render. Thus, most IsRenderable widget code can be written without taking into account whether or not the widget has yet been rendered.

invalid reference
DOM#appendChild
is aware of PotentialElement, and calls its resolve() method. This triggers a call to UIObject.resolvePotentialElement(), which widgets can customize to get a real Element in place at the last moment. TODO(rdcastro): Cover all unsupported methods with helpful error messages.
  • Constructor Details

    • PotentialElement

      protected PotentialElement()
  • Method Details

    • as

      public static PotentialElement as(Element e)
    • build

      public static PotentialElement build(UIObject o)
      Builds a new PotentialElement with the tag name set to "div".
      See Also:
    • build

      public static PotentialElement build(UIObject o, String tagName)
      Builds a new PotentialElement. This element keeps track of the UIObject so that it can call UIObject.resolvePotentialElement() to get a real element when that is needed.
    • createBuilderFor

      public static HtmlElementBuilder createBuilderFor(Element potentialElement)
      Creates an HtmlElementBuilder instance inheriting all attributes set for the given PotentialElement.
      Parameters:
      potentialElement - assumed to be a PotentialElement, used as basis for the builder
      Returns:
      a propertly configured HtmlElementBuilder instance
    • isPotential

      public static boolean isPotential(JavaScriptObject o)
      Tests whether a given JavaScriptObject represents a PotentialElement.
      Parameters:
      o - the JavaScriptObject to be tested
      Returns:
      true if the given object is a PotentialElement instance
    • resolve

      public static Element resolve(Element maybePotential)
      If given a PotentialElement, returns the real Element to be built from it. Otherwise returns the given Element itself.

      Note that a PotentialElement can only be resolved once. Making repeated calls to this method with the same PotentialElement is an error.

    • setResolver

      final Element setResolver(UIObject resolver)