new YXmlFragment()
Extends
Methods
-
createTreeWalker(filter) → {YXmlTreeWalker}
-
Create a subtree of childNodes.
Parameters:
Name Type Description filterfunction 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 queryCSS_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 queryCSS_Selector The query on the children
- 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 _documentDocument <optional>
document The document object (you must define this when calling this method in nodejs)
hooksObject.<string, any> <optional>
{} Optional property to customize how hooks are presented in the DOM
bindingany <optional>
You should not set this property. This is used if DomBinding wants to create a association to the created DOM type.
-
toDomString() → {string}
-
Get the string representation of all the children of this YXmlFragment.
Returns:
string -The string representation of all children.