Home Reference Source
import YXmlElement from 'yjs/src/Types/YXml/YXmlElement.js'
public class | source

YXmlElement

Extends:

src/Types/YXml/YXml.js~YXmlFragment → YXmlElement

An YXmlElement imitates the behavior of a {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}.

  • An YXmlElement has attributes (key value pairs)
  • An YXmlElement has childElements that must inherit from YXmlElement

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Method Summary

Public Methods
public

getAttribute(attributeName: String): String

Returns an attribute value that belongs to the attribute name.

public

Returns all attribute name/value pairs in a JSON Object.

public

removeAttribute(attributeName: String): *

Removes an attribute from this YXmlElement.

public

setAttribute(attributeName: String, attributeValue: String): *

Sets or updates an attribute.

public

toDom(_document: Document, hooks: Object<key:hookDefinition>, binding: DomBinding): Element

Creates a Dom Element that mirrors this YXmlElement.

public

Returns the string representation of this YXmlElement.

Public Constructors

public constructor() source

Public Members

public nodeName: * source

Public Methods

public getAttribute(attributeName: String): String source

Returns an attribute value that belongs to the attribute name.

Params:

NameTypeAttributeDescription
attributeName String

The attribute name that identifies the queried value.

Return:

String

The queried attribute value.

public getAttributes(): Object source

Returns all attribute name/value pairs in a JSON Object.

Return:

Object

A JSON Object that describes the attributes.

public removeAttribute(attributeName: String): * source

Removes an attribute from this YXmlElement.

Params:

NameTypeAttributeDescription
attributeName String

The attribute name that is to be removed.

Return:

*

public setAttribute(attributeName: String, attributeValue: String): * source

Sets or updates an attribute.

Params:

NameTypeAttributeDescription
attributeName String

The attribute name that is to be set.

attributeValue String

The attribute value that is to be set.

Return:

*

public toDom(_document: Document, hooks: Object<key:hookDefinition>, binding: DomBinding): Element source

Creates a Dom Element that mirrors this YXmlElement.

Params:

NameTypeAttributeDescription
_document Document
  • optional
  • default: document

The document object (you must define this when calling this method in nodejs)

hooks Object<key:hookDefinition>
  • optional
  • default: {}

Optional property to customize how hooks are presented in the DOM

binding DomBinding
  • optional

You should not set this property. This is used if DomBinding wants to create a association to the created DOM type.

public toString(): String source

Returns the string representation of this YXmlElement. The attributes are ordered by attribute-name, so you can easily use this method to compare YXmlElements

Return:

String

The string representation of this type.