mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:52:46 +00:00 
			
		
		
		
	LibWeb: Pass scope in Element::matches
This commit is contained in:
		
							parent
							
								
									c8ebacb1c9
								
							
						
					
					
						commit
						d55373067d
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -532,13 +532,17 @@ JS::GCPtr<ShadowRoot> Element::shadow_root() const | |||
| // https://dom.spec.whatwg.org/#dom-element-matches
 | ||||
| WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const | ||||
| { | ||||
|     // 1. Let s be the result of parse a selector from selectors.
 | ||||
|     auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors); | ||||
| 
 | ||||
|     // 2. If s is failure, then throw a "SyntaxError" DOMException.
 | ||||
|     if (!maybe_selectors.has_value()) | ||||
|         return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"); | ||||
| 
 | ||||
|     // 3. If the result of match a selector against an element, using s, this, and scoping root this, returns success, then return true; otherwise, return false.
 | ||||
|     auto sel = maybe_selectors.value(); | ||||
|     for (auto& s : sel) { | ||||
|         if (SelectorEngine::matches(s, *this)) | ||||
|         if (SelectorEngine::matches(s, *this, {}, static_cast<ParentNode const*>(this))) | ||||
|             return true; | ||||
|     } | ||||
|     return false; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Simon Wanner
						Simon Wanner