mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 20:04:59 +00:00
LibWeb: Implement HTMLTableElement tfoot attributes
* tFoot - Getter for the tfoot element The setter is not currently implemented * createTFoot - If necessary, creates a new tfoot element and add it to the table after any tbody elements * deleteTFoot - If a tfoot element exists in the table, delete it
This commit is contained in:
parent
b3f7ea9914
commit
d2e3e98b6b
3 changed files with 56 additions and 0 deletions
|
@ -163,6 +163,53 @@ void HTMLTableElement::delete_t_head()
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<HTMLTableSectionElement> HTMLTableElement::t_foot()
|
||||
{
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<HTMLTableSectionElement>(*child)) {
|
||||
auto table_section_element = &downcast<HTMLTableSectionElement>(*child);
|
||||
if (table_section_element->tag_name() == TagNames::tfoot)
|
||||
return table_section_element;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DOM::ExceptionOr<void> HTMLTableElement::set_t_foot(HTMLTableSectionElement& tfoot)
|
||||
{
|
||||
if (tfoot.tag_name() != TagNames::tfoot)
|
||||
return DOM::HierarchyRequestError::create("Element is not tfoot");
|
||||
|
||||
// FIXME: The spec requires deleting the current tfoot if tfoot is null
|
||||
// Currently the wrapper generator doesn't send us a nullable value
|
||||
delete_t_foot();
|
||||
|
||||
// We insert the new tfoot at the end of the table
|
||||
append_child(tfoot);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
NonnullRefPtr<HTMLTableSectionElement> HTMLTableElement::create_t_foot()
|
||||
{
|
||||
auto maybe_tfoot = t_foot();
|
||||
if (maybe_tfoot)
|
||||
return *maybe_tfoot;
|
||||
|
||||
auto tfoot = DOM::create_element(document(), TagNames::tfoot, Namespace::HTML);
|
||||
append_child(tfoot);
|
||||
return tfoot;
|
||||
}
|
||||
|
||||
void HTMLTableElement::delete_t_foot()
|
||||
{
|
||||
auto maybe_tfoot = t_foot();
|
||||
if (maybe_tfoot) {
|
||||
maybe_tfoot->remove(false);
|
||||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<DOM::HTMLCollection> HTMLTableElement::rows()
|
||||
{
|
||||
HTMLTableElement* table_node = this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue