YXml.YXmlFragment()

Represents a list of YXmlElement.and YXmlText types. A YxmlFragment is similar to a YXmlElement, but it does not have a nodeName and it does not have attributes. Though it can be bound to a DOM element - in this case the attributes and the nodeName are not shared.

new YXmlFragment()

Extends

Methods

createTreeWalker(filter) → {YXmlTreeWalker}

Create a subtree of childNodes.

Parameters:
Name Type Description
filter function

Function that is called on each child element and returns a Boolean indicating whether the child is to be included in the subtree.

Returns:
YXmlTreeWalker -

A subtree and a position within it.

Example
const walker = elem.createTreeWalker(dom => dom.nodeName === 'div')
for (let node in walker) {
  // `node` is a div node
  nop(node)
}

querySelector(query) → {YXmlElement|YXmlText|YXmlHook|null}

Returns the first YXmlElement that matches the query. Similar to DOM's querySelector.

Query support:

  • tagname TODO:
  • id
  • attribute
Parameters:
Name Type Description
query CSS_Selector

The query on the children.

Returns:
YXmlElement | YXmlText | YXmlHook | null -

The first element that matches the query or null.

querySelectorAll(query) → {Array.<(YXmlElement|YXmlText|YXmlHook|null)>}

Returns all YXmlElements that match the query. Similar to Dom's querySelectorAll.

Parameters:
Name Type Description
query CSS_Selector

The query on the children

Returns:
Array.<(YXmlElement|YXmlText|YXmlHook|null)> -

The elements that match this query.

To Do:
  • Does not yet support all queries. Currently only query by tagName.

toDom(_documentopt, hooksopt, bindingopt) → {Node}

Creates a Dom Element that mirrors this YXmlElement.

Parameters:
Name Type Attributes Default Description
_document Document <optional>
document

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

hooks Object.<string, any> <optional>
{}

Optional property to customize how hooks are presented in the DOM

binding any <optional>

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

Returns:
Node -

The Dom Element

toDomString() → {string}

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

Returns:
string -

The string representation of all children.