| 24 | } |
| 25 | |
| 26 | void Element::deleteElement() { |
| 27 | auto parentOfElement = this->getParent(); |
| 28 | if (parentOfElement.expired()) { |
| 29 | BLOGE("%s", "element is a root elements"); |
| 30 | return; |
| 31 | } |
| 32 | auto iter = std::remove_if(parentOfElement.lock()->_children.begin(), |
| 33 | parentOfElement.lock()->_children.end(), |
| 34 | [&](const ElementPtr &elem) { return elem.get() == this; } |
| 35 | ); |
| 36 | if (iter != parentOfElement.lock()->_children.end()) { |
| 37 | parentOfElement.lock()->_childCount--; |
| 38 | parentOfElement.lock()->_children.erase(iter); |
| 39 | } |
| 40 | this->_parent.reset(); |
| 41 | } |
| 42 | |
| 43 | /// According to given xpath selector, containing text, content, classname, resource id, test if |
| 44 | /// this current element has the same property value as the given xpath selector. |