|
| 1 | +### Import : |
| 2 | +```js |
| 3 | +const HTMLSimpleDOM = brackets.getModule("language/HTMLSimpleDOM") |
| 4 | +``` |
| 5 | + |
| 6 | +<a name="SimpleNode"></a> |
| 7 | + |
| 8 | +## SimpleNode |
| 9 | +**Kind**: global class |
| 10 | + |
| 11 | +* [SimpleNode](#SimpleNode) |
| 12 | + * [new SimpleNode(properties)](#new_SimpleNode_new) |
| 13 | + * [.update()](#SimpleNode+update) |
| 14 | + * [.updateAttributeSignature()](#SimpleNode+updateAttributeSignature) |
| 15 | + * [.isElement()](#SimpleNode+isElement) ⇒ <code>bool</code> |
| 16 | + * [.isText()](#SimpleNode+isText) ⇒ <code>bool</code> |
| 17 | + |
| 18 | +<a name="new_SimpleNode_new"></a> |
| 19 | + |
| 20 | +### new SimpleNode(properties) |
| 21 | +A SimpleNode represents one node in a SimpleDOM tree. Each node can have |
| 22 | +any set of properties on it, though there are a couple of assumptions made. |
| 23 | +Elements will have `children` and `attributes` properties. Text nodes will have a `content` |
| 24 | +property. All Elements will have a `tagID` and text nodes *can* have one. |
| 25 | + |
| 26 | + |
| 27 | +| Param | Type | Description | |
| 28 | +| --- | --- | --- | |
| 29 | +| properties | <code>Object</code> | the properties provided will be set on the new object. | |
| 30 | + |
| 31 | +<a name="SimpleNode+update"></a> |
| 32 | + |
| 33 | +### simpleNode.update() |
| 34 | +Updates signatures used to optimize the number of comparisons done during |
| 35 | +diffing. This is important to call if you change: |
| 36 | + |
| 37 | +* children |
| 38 | +* child node attributes |
| 39 | +* text content of a text node |
| 40 | +* child node text |
| 41 | + |
| 42 | +**Kind**: instance method of [<code>SimpleNode</code>](#SimpleNode) |
| 43 | +<a name="SimpleNode+updateAttributeSignature"></a> |
| 44 | + |
| 45 | +### simpleNode.updateAttributeSignature() |
| 46 | +Updates the signature of this node's attributes. Call this after making attribute changes. |
| 47 | + |
| 48 | +**Kind**: instance method of [<code>SimpleNode</code>](#SimpleNode) |
| 49 | +<a name="SimpleNode+isElement"></a> |
| 50 | + |
| 51 | +### simpleNode.isElement() ⇒ <code>bool</code> |
| 52 | +Is this node an element node? |
| 53 | + |
| 54 | +**Kind**: instance method of [<code>SimpleNode</code>](#SimpleNode) |
| 55 | +**Returns**: <code>bool</code> - true if it is an element |
| 56 | +<a name="SimpleNode+isText"></a> |
| 57 | + |
| 58 | +### simpleNode.isText() ⇒ <code>bool</code> |
| 59 | +Is this node a text node? |
| 60 | + |
| 61 | +**Kind**: instance method of [<code>SimpleNode</code>](#SimpleNode) |
| 62 | +**Returns**: <code>bool</code> - true if it is text |
| 63 | +<a name="Builder"></a> |
| 64 | + |
| 65 | +## Builder |
| 66 | +**Kind**: global class |
| 67 | + |
| 68 | +* [Builder](#Builder) |
| 69 | + * [new Builder(text, startOffset, startOffsetPos)](#new_Builder_new) |
| 70 | + * [.getID](#Builder+getID) ⇒ <code>int</code> |
| 71 | + * [.build(strict, markCache)](#Builder+build) ⇒ [<code>SimpleNode</code>](#SimpleNode) |
| 72 | + * [.getNewID()](#Builder+getNewID) ⇒ <code>int</code> |
| 73 | + |
| 74 | +<a name="new_Builder_new"></a> |
| 75 | + |
| 76 | +### new Builder(text, startOffset, startOffsetPos) |
| 77 | +A Builder creates a SimpleDOM tree of SimpleNode objects representing the |
| 78 | +"important" contents of an HTML document. It does not include things like comments. |
| 79 | +The nodes include information about their position in the text provided. |
| 80 | + |
| 81 | + |
| 82 | +| Param | Type | Description | |
| 83 | +| --- | --- | --- | |
| 84 | +| text | <code>string</code> | The text to parse | |
| 85 | +| startOffset | <code>int</code> | starting offset in the text | |
| 86 | +| startOffsetPos | <code>Object</code> | line/ch position in the text | |
| 87 | + |
| 88 | +<a name="Builder+getID"></a> |
| 89 | + |
| 90 | +### builder.getID ⇒ <code>int</code> |
| 91 | +Returns the best tag ID for the new tag object given. |
| 92 | +The default implementation just calls `getNewID` |
| 93 | +and returns a unique ID. |
| 94 | + |
| 95 | +**Kind**: instance property of [<code>Builder</code>](#Builder) |
| 96 | +**Returns**: <code>int</code> - unique tag ID |
| 97 | + |
| 98 | +| Param | Type | Description | |
| 99 | +| --- | --- | --- | |
| 100 | +| newTag | <code>Object</code> | tag object to potentially inspect to choose an ID | |
| 101 | + |
| 102 | +<a name="Builder+build"></a> |
| 103 | + |
| 104 | +### builder.build(strict, markCache) ⇒ [<code>SimpleNode</code>](#SimpleNode) |
| 105 | +Builds the SimpleDOM. |
| 106 | + |
| 107 | +**Kind**: instance method of [<code>Builder</code>](#Builder) |
| 108 | +**Returns**: [<code>SimpleNode</code>](#SimpleNode) - root of tree or null if parsing failed |
| 109 | + |
| 110 | +| Param | Type | Description | |
| 111 | +| --- | --- | --- | |
| 112 | +| strict | <code>bool</code> | if errors are detected, halt and return null | |
| 113 | +| markCache | <code>Object</code> | a cache that can be used in ID generation (is passed to `getID`) | |
| 114 | + |
| 115 | +<a name="Builder+getNewID"></a> |
| 116 | + |
| 117 | +### builder.getNewID() ⇒ <code>int</code> |
| 118 | +Returns a new tag ID. |
| 119 | + |
| 120 | +**Kind**: instance method of [<code>Builder</code>](#Builder) |
| 121 | +**Returns**: <code>int</code> - unique tag ID |
| 122 | +<a name="build"></a> |
| 123 | + |
| 124 | +## build(text, strict) ⇒ [<code>SimpleNode</code>](#SimpleNode) |
| 125 | +Builds a SimpleDOM from the text provided. If `strict` mode is true, parsing |
| 126 | +will halt as soon as any error is seen and null will be returned. |
| 127 | + |
| 128 | +**Kind**: global function |
| 129 | +**Returns**: [<code>SimpleNode</code>](#SimpleNode) - root of tree or null if strict failed |
| 130 | + |
| 131 | +| Param | Type | Description | |
| 132 | +| --- | --- | --- | |
| 133 | +| text | <code>string</code> | Text of document to parse | |
| 134 | +| strict | <code>bool</code> | True for strict parsing | |
| 135 | + |
0 commit comments