30 RefPtr<Element> ToElement(RefPtr<Node> node) {
31 if (!node->is_element())
33 return static_cast<Element*
>(node.get());
39 :
Node(type, document) {}
42 ContainerNode::~ContainerNode() {}
46 const std::string&
name)
const {
47 std::vector<RefPtr<Element>> ret;
51 if (elem->tag_name() ==
name) {
55 auto temp = elem->GetElementsByTagName(name);
56 ret.insert(ret.end(), temp.begin(), temp.end());
64 const std::string& query)
const {
67 for (
char c : query) {
68 if (!std::isalnum(c)) {
74 return elems.empty() ?
nullptr : elems[0];
79 AddMemberFunction(
"getElementsByTagName",
83 NotImplemented(
"children");
84 NotImplemented(
"firstElementChild");
85 NotImplemented(
"lastElementChild");
86 NotImplemented(
"childElementCount");
88 NotImplemented(
"getElementsByTagNameNS");
89 NotImplemented(
"getElementsByClassName");
91 NotImplemented(
"prepend");
92 NotImplemented(
"append");
93 NotImplemented(
"querySelectorAll");
ContainerNode(NodeType type, RefPtr< Document > document)
virtual std::vector< RefPtr< Element > > GetElementsByTagName(const std::string &name) const
ExceptionOr< RefPtr< Element > > QuerySelector(const std::string &query) const
static JsError DOMException(ExceptionCode code)
std::vector< RefPtr< Node > > child_nodes() const