Browse Source

move findTagNodeParent here

master
Odilitime 5 years ago
parent
commit
e95e4ad0ca
  1. 15
      src/html/Node.cpp
  2. 1
      src/html/Node.h

15
src/html/Node.cpp

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "Node.h"
#include "TagNode.h"
Node::Node(NodeType type) {
nodeType = type;
@ -19,3 +20,17 @@ std::vector<std::string> Node::getSourceList() { @@ -19,3 +20,17 @@ std::vector<std::string> Node::getSourceList() {
return returnVec;
}
std::shared_ptr<Node> Node::findTagNodeParent(std::string tag, std::shared_ptr<Node> node) {
if (!node.get()) {
// found root?
return nullptr;
}
TagNode *tagNode = dynamic_cast<TagNode*>(node.get());
if (tagNode) {
if (tagNode->tag == tag) {
return node;
}
}
return Node::findTagNodeParent(tag, node->parent);
}

1
src/html/Node.h

@ -24,6 +24,7 @@ public: @@ -24,6 +24,7 @@ public:
std::vector<std::shared_ptr<Node>> children;
std::shared_ptr<Component> component;
static std::shared_ptr<Node> findTagNodeParent(std::string tag, std::shared_ptr<Node> node);
virtual std::vector<std::string> getSourceList();
};

Loading…
Cancel
Save