2021-07-03 00:05:50 +02:00
|
|
|
export class HTMLParseResult {
|
|
|
|
constructor(bodyNode) {
|
|
|
|
this._bodyNode = bodyNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
get rootNodes() {
|
2021-07-07 23:12:24 +02:00
|
|
|
return Array.from(this._bodyNode.childNodes);
|
2021-07-03 00:05:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getChildNodes(node) {
|
2021-07-07 23:12:24 +02:00
|
|
|
return Array.from(node.childNodes);
|
2021-07-03 00:05:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getAttributeNames(node) {
|
2021-07-07 23:12:24 +02:00
|
|
|
return Array.from(node.getAttributeNames());
|
2021-07-03 00:05:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getAttributeValue(node, attr) {
|
|
|
|
return node.getAttribute(attr);
|
|
|
|
}
|
|
|
|
|
|
|
|
isTextNode(node) {
|
|
|
|
return node.nodeType === Node.TEXT_NODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
getNodeText(node) {
|
|
|
|
return node.nodeValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
isElementNode(node) {
|
|
|
|
return node.nodeType === Node.ELEMENT_NODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
getNodeElementName(node) {
|
|
|
|
return node.tagName;
|
|
|
|
}
|
|
|
|
}
|