Menu
pushmode.elements

Class AnySvgElement

PushMode » API Reference » pushmode.elements

    • Constructor Detail

      • AnySvgElement

        @InternalPushModeApi
        protected AnySvgElement()
        Creates new empty element. Applications never call this method directly. PushMode provides derived classes for all standard elements.
      • AnySvgElement

        @InternalPushModeApi
        protected AnySvgElement(AnySvgElement other)
        Creates deep mutable copy of another element. Applications never call this method directly. Method clone() should be used to create deep mutable clones.
        Parameters:
        other - Element to clone.
        Throws:
        NullPointerException - The parameter is null.
    • Method Detail

      • clone

        public abstract AnySvgElement clone()
        Description copied from class: DomElement
        Creates mutable deep clone of this element. All child nodes are cloned recursively. The clone is completely independent of this element.
        Specified by:
        clone in class DomElement
        Returns:
        Deep mutable clone.
      • key

        public AnySvgElement key(Object key)
        Description copied from class: DomElement
        Sets element's pairing key. Any object implementing Object.equals(Object) and Object.hashCode() can be used as a key. Key, if set, must be unique among siblings in the DOM tree. Once set, the key is available from DomElement.key(). If the key is set to null, DomElement.key() will return DomElement.id().
        While DomElement.id() is sent to the browser, is a String, and it should be unique in the document, DomElement.key() is used only server-side, can be of any type, and it only needs to be unique among sibling elements.
        Key is used in hierarchical DOM diff to pair corresponding elements in cases where some DOM nodes have been inserted or removed from parent's child list. If DomElement.key() is null, DOM diff uses element position to pair elements in compared DOM trees, which might result in unnecessarily big diffs if an element is inserted at the beginning of a long list. Absence of key thus doesn't impact functionality, only performance. And even then it matters only if siblings are inserted or removed.
        Overrides:
        key in class DomElement
        Parameters:
        key - New element key. Any object implementing Object.equals(Object) and Object.hashCode() can be used as a key. Key, if set, must be unique among siblings in the DOM tree. If this parameter is null, DomElement.key() will return DomElement.id().
        Returns:
        this
      • id

        public AnySvgElement id(String id)
        Description copied from class: DomElement
        Sets element's ID. Element ID is serialized as an id attribute in HTML. It must therefore fulfill criteria for proper element ID in HTML, which most importantly means the ID should be unique in the document. Element ID has a special meaning in PushMode. Listeners require the element to have an ID. Listeners on ID-less elements are ignored. Once set, the ID is available from DomElement.id() method. ID is the default value of DomElement.key().
        Overrides:
        id in class DomElement
        Parameters:
        id - New element ID.
        Returns:
        this
      • clazz

        public AnySvgElement clazz(String clazz)
        Description copied from class: DomElement
        Sets class attribute. If the attribute is already set, this method appends new value to the old value separated by space.
        Overrides:
        clazz in class DomElement
        Parameters:
        clazz - Text to set/append to the class attribute. This method has no effect if the parameter is null.
        Returns:
        this
      • data

        public AnySvgElement data(String key,
                                  String value)
        Description copied from class: DomElement
        Sets data-* attribute.
        Overrides:
        data in class DomElement
        Parameters:
        key - Name of the attribute if formed from its key and 'data-' prefix, e.g. key hello will set attribute data-hello. This method has no effect if the parameter is null.
        value - Text to write to the data-[key] attribute. This method has no effect if the parameter is null.
        Returns:
        this
      • style

        public AnySvgElement style(String style)
        Description copied from class: DomElement
        Sets style attribute. If the attribute is already set, this method appends new value to the old value separated by semicolon.
        Overrides:
        style in class DomElement
        Parameters:
        style - Text to set/append to the style attribute. This method has no effect if the parameter is null.
        Returns:
        this
      • add

        public <C extends DomContentAnySvgElement add(C... children)
        Description copied from class: DomElement
        Adds all nodes in an array to this element.
        Overrides:
        add in class DomElement
        Parameters:
        children - Array of child nodes to add. This method has no effect if the parameter is null. Array items that are null are skipped.
        Returns:
        this
        See Also:
        DomElement.add(DomContent)
      • text

        public AnySvgElement text(String text)
        Description copied from class: DomElement
        Adds literal text to this element The text is first wrapped in DomText. If the text is null or empty, this method has no effect.
        Overrides:
        text in class DomElement
        Parameters:
        text - Text to add. This method has no effect if the text is null or empty.
        Returns:
        this
        See Also:
        DomElement.add(DomContent)
      • freeze

        public AnySvgElement freeze()
        Description copied from class: DomElement
        Creates frozen deep clone of this element. Mutating methods throw IllegalStateException when executed on frozen element. Frozen elements can be safely shared by all threads. Freezing is recursive. Frozen elements therefore cannot contain mutable nodes.
        Freezing applies several transformations to the cloned element, so that these transformations don't have to be performed repeatedly during rendering. All DomFragment descendants are recursively inlined into their respective parents, so that the frozen element contains no DomFragment descendants. Freezing the element causes all consecutive text nodes to be concatenated into single node. If the resulting text node is empty, it is removed. Listeners are discarded on this and descendant elements with null DomElement.id(). All internal arrays are compacted, so that the frozen DOM tree takes up minimum amount of memory. None of these transformations modifies the original element in any way.
        Overrides:
        freeze in class DomElement
        Returns:
        Deep frozen clone. Returns this if this element is already frozen.