niddle
v0.2.6
Published
A super fast html parser and manipulator written in rust.
Downloads
17
Maintainers
Readme
niddle • Docs
niddle
Classes
NodeRepr
Constructors
new NodeRepr()
new NodeRepr():
NodeRepr
The node object, cann't be instantiated in javascript. So call the constructor will throw an error.
Returns
Defined in
Methods
append()
append(
newChild
):void
Append a child node to this node, after existing children.
The child node will be remove from its previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newChild
| NodeRepr
|
Returns
void
Defined in
appendSequence()
appendSequence(
newChildren
):void
Append some children nodes to this node by order, after existing children.
These children nodes will be remove from their previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newChildren
| NodeRepr
[] |
Returns
void
Defined in
clone()
clone():
NodeRepr
Clone this node to a new instance, not clone its descendants.
Returns
Defined in
cloneRecursive()
cloneRecursive():
NodeRepr
Clone this node to a new instance, including its all descendants.
Returns
Defined in
getAttribute()
getAttribute(
name
):string
Get attribute value of this node by given name.
Parameters
| Parameter | Type |
| ------ | ------ |
| name
| string
|
Returns
string
Defined in
getAttributes()
getAttributes():
Record
<string
,string
>
Get attributes K-V object of this node.
Returns
Record
<string
, string
>
Defined in
getChildren()
getChildren():
NodeRepr
[]
Get all children nodes of this node.
Returns
NodeRepr
[]
Defined in
innerHtml()
innerHtml():
string
Get the serialized html of this node, only including its all descendants.
Returns
string
Defined in
insertAfter()
insertAfter(
newSibling
):void
Insert a new sibling after this node.
The sibling node will be remove from its previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newSibling
| NodeRepr
|
Returns
void
Defined in
insertBefore()
insertBefore(
newSibling
):void
Insert a new sibling before this node.
The sibling node will be remove from its previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newSibling
| NodeRepr
|
Returns
void
Defined in
insertSequenceAfter()
insertSequenceAfter(
newSiblings
):void
Insert some siblings after this node.
These sibling nodes will be remove from their previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newSiblings
| NodeRepr
[] |
Returns
void
Defined in
insertSequenceBefore()
insertSequenceBefore(
newSiblings
):void
Insert some siblings before this node.
These sibling nodes will be remove from their previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newSiblings
| NodeRepr
[] |
Returns
void
Defined in
outerHtml()
outerHtml():
string
Get the serialized html of this node, including its all descendants and itelf.
Returns
string
Defined in
prepend()
prepend(
newChild
):void
Prepend a child node to this node, before existing children.
The child node will be remove from its previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newChild
| NodeRepr
|
Returns
void
Defined in
prependSequence()
prependSequence(
newChildren
):void
Prepend some children nodes to this node by order, before existing children.
These children nodes will be remove from their previous position.
Parameters
| Parameter | Type |
| ------ | ------ |
| newChildren
| NodeRepr
[] |
Returns
void
Defined in
remove()
remove():
void
Remove a node from its parent and siblings. Children are not affected.
Returns
void
Defined in
removeAllAttributes()
removeAllAttributes():
void
Remove all attributes of this node.
Returns
void
Defined in
removeAttribute()
removeAttribute(
name
):void
Remove an attribute of this node by name.
Parameters
| Parameter | Type |
| ------ | ------ |
| name
| string
|
Returns
void
Defined in
select()
select(selectors)
select(
selectors
):NodeRepr
Select the the fist node that match the given css selector, like document.querySelector.
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| string
|
Returns
Defined in
select(selectors)
select(
selectors
):NodeRepr
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| "html"
|
Returns
Defined in
select(selectors)
select(
selectors
):NodeRepr
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| "head"
|
Returns
Defined in
select(selectors)
select(
selectors
):NodeRepr
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| "body"
|
Returns
Defined in
select(selectors)
select(
selectors
):NodeRepr
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| "html"
|
Returns
Defined in
select(selectors)
select(
selectors
):NodeRepr
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| "head"
|
Returns
Defined in
select(selectors)
select(
selectors
):NodeRepr
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| "body"
|
Returns
Defined in
selectAll()
selectAll(
selectors
):NodeRepr
[]
Select all nodes that match the given css selector, like document.querySelectorAll.
Parameters
| Parameter | Type |
| ------ | ------ |
| selectors
| string
|
Returns
NodeRepr
[]
Defined in
setAttribute()
setAttribute(
name
,value
):void
Assign an attribute K-V to this node
Parameters
| Parameter | Type |
| ------ | ------ |
| name
| string
|
| value
| string
|
Returns
void
Defined in
setAttributes()
setAttributes(
attrs
):void
Assign attributes K-V object to this node.
Parameters
| Parameter | Type |
| ------ | ------ |
| attrs
| Record
<string
, string
> |
Returns
void
Defined in
text()
text():
string
Get all text nodes content of this node, including its all descendants and itelf.
Returns
string
Defined in
Functions
parse()
parse(
html
):NodeRepr
Parse string input to a html tree, return the root node.
Parameters
| Parameter | Type |
| ------ | ------ |
| html
| string
|