HTMLSimpleDOM
Import :
const HTMLSimpleDOM = brackets.getModule("language/HTMLSimpleDOM")
SimpleNode
Kind: global class
new SimpleNode(properties)
A SimpleNode represents one node in a SimpleDOM tree. Each node can have
any set of properties on it, though there are a couple of assumptions made.
Elements will have children
and attributes
properties. Text nodes will have a content
property. All Elements will have a tagID
and text nodes can have one.
Param | Type | Description |
---|---|---|
properties | Object | the properties provided will be set on the new object. |
simpleNode.update()
Updates signatures used to optimize the number of comparisons done during diffing. This is important to call if you change:
- children
- child node attributes
- text content of a text node
- child node text
Kind: instance method of SimpleNode
simpleNode.updateAttributeSignature()
Updates the signature of this node's attributes. Call this after making attribute changes.
Kind: instance method of SimpleNode
simpleNode.isElement() ⇒ bool
Is this node an element node?
Kind: instance method of SimpleNode
Returns: bool
- true if it is an element
simpleNode.isText() ⇒ bool
Is this node a text node?
Kind: instance method of SimpleNode
Returns: bool
- true if it is text
Builder
Kind: global class
new Builder(text, startOffset, startOffsetPos)
A Builder creates a SimpleDOM tree of SimpleNode objects representing the "important" contents of an HTML document. It does not include things like comments. The nodes include information about their position in the text provided.
Param | Type | Description |
---|---|---|
text | string | The text to parse |
startOffset | int | starting offset in the text |
startOffsetPos | Object | line/ch position in the text |
builder.getID ⇒ int
Returns the best tag ID for the new tag object given.
The default implementation just calls getNewID
and returns a unique ID.
Kind: instance property of Builder
Returns: int
- unique tag ID
Param | Type | Description |
---|---|---|
newTag | Object | tag object to potentially inspect to choose an ID |
builder.build(strict, markCache) ⇒ SimpleNode
Builds the SimpleDOM.
Kind: instance method of Builder
Returns: SimpleNode
- root of tree or null if parsing failed
Param | Type | Description |
---|---|---|
strict | bool | if errors are detected, halt and return null |
markCache | Object | a cache that can be used in ID generation (is passed to getID ) |
builder.getNewID() ⇒ int
Returns a new tag ID.
Kind: instance method of Builder
Returns: int
- unique tag ID
build(text, strict) ⇒ SimpleNode
Builds a SimpleDOM from the text provided. If strict
mode is true, parsing
will halt as soon as any error is seen and null will be returned.
Kind: global function
Returns: SimpleNode
- root of tree or null if strict failed
Param | Type | Description |
---|---|---|
text | string | Text of document to parse |
strict | bool | True for strict parsing |