Browse Source

move findTagNodeParent here

master
Odilitime 4 years ago
parent
commit
e95e4ad0ca
2 changed files with 16 additions and 0 deletions
  1. 15
    0
      src/html/Node.cpp
  2. 1
    0
      src/html/Node.h

+ 15
- 0
src/html/Node.cpp View File

@@ -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() {
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
- 0
src/html/Node.h View File

@@ -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