diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-11 22:54:26 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-11 22:54:26 +0200 |
commit | 0398089275d8954616b7409326a6aa1a582aca90 (patch) | |
tree | 78c4ad635213336ad7c3d3e4484c91e2cfbcab4e /Userland/Libraries/LibWeb/DOM | |
parent | 935075c26ef19c7a33957f657720e98de53d32c8 (diff) | |
download | serenity-0398089275d8954616b7409326a6aa1a582aca90.zip |
LibWeb: Throw SyntaxError on bogus querySelector{,All} input selector
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/ParentNode.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/ParentNode.h | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp index 8562c151c8..a55f7631e8 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp @@ -11,11 +11,11 @@ namespace Web::DOM { -RefPtr<Element> ParentNode::query_selector(const StringView& selector_text) +ExceptionOr<RefPtr<Element>> ParentNode::query_selector(StringView selector_text) { auto maybe_selectors = parse_selector(CSS::ParsingContext(*this), selector_text); if (!maybe_selectors.has_value()) - return {}; + return DOM::SyntaxError::create("Failed to parse selector"); auto selectors = maybe_selectors.value(); @@ -36,11 +36,11 @@ RefPtr<Element> ParentNode::query_selector(const StringView& selector_text) return result; } -NonnullRefPtrVector<Element> ParentNode::query_selector_all(const StringView& selector_text) +ExceptionOr<NonnullRefPtrVector<Element>> ParentNode::query_selector_all(StringView selector_text) { auto maybe_selectors = parse_selector(CSS::ParsingContext(*this), selector_text); if (!maybe_selectors.has_value()) - return {}; + return DOM::SyntaxError::create("Failed to parse selector"); auto selectors = maybe_selectors.value(); diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.h b/Userland/Libraries/LibWeb/DOM/ParentNode.h index 856c5a4597..d977cc8f7d 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.h +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.h @@ -22,8 +22,8 @@ public: RefPtr<Element> last_element_child(); u32 child_element_count() const; - RefPtr<Element> query_selector(const StringView&); - NonnullRefPtrVector<Element> query_selector_all(const StringView&); + ExceptionOr<RefPtr<Element>> query_selector(StringView); + ExceptionOr<NonnullRefPtrVector<Element>> query_selector_all(StringView); protected: ParentNode(Document& document, NodeType type) |