mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-01 05:41:01 +00:00 
			
		
		
		
	LibWeb: Implement HTMLTableElement tbody attributes
* tBodies - returns a HTMLCollection of all tbody elements * createTBody - If necessary, creates a new tbody element and add it to the table after the last tbody element
This commit is contained in:
		
							parent
							
								
									d2e3e98b6b
								
							
						
					
					
						commit
						37685b0181
					
				
				
				Notes:
				
					sideshowbarker
				
				2024-07-18 18:25:19 +09:00 
				
			
			Author: https://github.com/ant1441
Commit: 37685b0181
Pull-request: https://github.com/SerenityOS/serenity/pull/6823
Reviewed-by: https://github.com/awesomekling
			
					 3 changed files with 38 additions and 0 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> | ||||
|  * Copyright (c) 2021, Adam Hodgen <ant1441@gmail.com> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
|  | @ -210,6 +211,37 @@ void HTMLTableElement::delete_t_foot() | |||
|     } | ||||
| } | ||||
| 
 | ||||
| NonnullRefPtr<DOM::HTMLCollection> HTMLTableElement::t_bodies() | ||||
| { | ||||
|     return DOM::HTMLCollection::create(*this, [](DOM::Element const& element) { | ||||
|         return element.tag_name() == TagNames::tbody; | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| NonnullRefPtr<HTMLTableSectionElement> HTMLTableElement::create_t_body() | ||||
| { | ||||
|     auto tbody = DOM::create_element(document(), TagNames::tbody, Namespace::HTML); | ||||
| 
 | ||||
|     // We insert the new tbody after the last <tbody> element
 | ||||
|     DOM::Node* child_to_append_after = nullptr; | ||||
|     for (auto* child = last_child(); child; child = child->previous_sibling()) { | ||||
|         if (!is<HTMLElement>(*child)) | ||||
|             continue; | ||||
|         if (is<HTMLTableSectionElement>(*child)) { | ||||
|             auto table_section_element = &downcast<HTMLTableSectionElement>(*child); | ||||
|             if (table_section_element->tag_name() == TagNames::tbody) { | ||||
|                 // We have found an element which is a <tbody> we'll insert after this
 | ||||
|                 child_to_append_after = child->next_sibling(); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pre_insert(tbody, child_to_append_after); | ||||
| 
 | ||||
|     return tbody; | ||||
| } | ||||
| 
 | ||||
| NonnullRefPtr<DOM::HTMLCollection> HTMLTableElement::rows() | ||||
| { | ||||
|     HTMLTableElement* table_node = this; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Adam Hodgen
						Adam Hodgen