Constructor
new ContentParser(content, cbopt) → {DocumentFragment|Node}
Create a new ContentParser instance.
Create a new ContentParser instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
content |
string | Node | HTML string or DOM Node to be parsed. |
|
cb |
function |
<optional> |
Optional callback (currently unused). |
- Source:
Returns:
The parsed DOM fragment or node.
- Type
- DocumentFragment | Node
Methods
add(contents) → {Node}
Processes a DOM Node by cloning its structure (if needed) and adding data-ref
attributes.
Processes a DOM Node by cloning its structure (if needed) and adding data-ref
attributes.
Parameters:
Name | Type | Description |
---|---|---|
contents |
Node | A DOM Node or DocumentFragment to process. |
- Source:
Returns:
The processed content with references.
- Type
- Node
addRefs(content)
Walks the content tree and adds a data-ref
attribute (UUID) to each element.
Walks the content tree and adds a data-ref
attribute (UUID) to each element.
Also preserves original id
attributes via data-id
.
Parameters:
Name | Type | Description |
---|---|---|
content |
Node | A DOM Node or DocumentFragment to annotate. |
- Source:
destroy()
Cleans up the parser's references and DOM structure.
Cleans up the parser's references and DOM structure.
- Source:
find(ref) → {HTMLElement|undefined}
Finds a DOM node by its reference ID (this.refs must be pre-populated externally).
Finds a DOM node by its reference ID (this.refs must be pre-populated externally).
Parameters:
Name | Type | Description |
---|---|---|
ref |
string | The |
- Source:
Returns:
The associated element, if found.
- Type
- HTMLElement | undefined
parse(markup, mimeopt) → {DocumentFragment}
Parses an HTML string into a DocumentFragment and adds data-ref
attributes.
Parses an HTML string into a DocumentFragment and adds data-ref
attributes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
markup |
string | The HTML markup to parse. |
|
mime |
string |
<optional> |
Optional MIME type (currently unused). |
- Source:
Returns:
A document fragment with processed nodes.
- Type
- DocumentFragment