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

YXmlElement

Extends:

ItemTypeYArrayYXmlFragment → 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.

Inherited Summary

From class Type
public

getPathTo(type: YType): Array<string>

Compute the path from this type to the specified target.

public

Observe all events that are created on this type.

public

Observe all events that are created by this type and its children.

public

Unregister an observer function.

public

Unregister an observer function.

From class YArray
public get

length: *

Computes the length of this YArray.

public

[Symbol.iterator](): {"next": *, "_item": *, "_itemElement": *, "_count": *}

public

delete(index: Integer, length: Integer)

Deletes elements starting from an index.

public

Executes a provided function on once on overy element of this YArray.

public

get(index: Integer): *

Returns the i-th element from a YArray.

public

insert(index: Integer, content: Array)

Inserts new content at an index.

public

Returns an Array with the result of calling a provided function on every element of this YArray.

public

push(content: Array)

Appends content to this YArray.

public

Transforms this YArray to a JavaScript Array.

public

Transforms this Shared Type to a JSON object.

From class YXmlFragment
public

createTreeWalker(filter: Function): TreeWalker

Create a subtree of childNodes.

public

Returns the first YXmlElement that matches the query.

public

Returns all YXmlElements that match the query.

public

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

Creates a Dom Element that mirrors this YXmlElement.

public

Get the string representation of all the children of this YXmlFragment.

Public Constructors

public constructor() source

Override:

Type#constructor

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.

Override:

YXmlFragment#toDom

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

Override:

YXmlFragment#toString

Return:

String

The string representation of this type.