mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
LibWeb: Implement [SameObject] behavior for HTMLTableSectionElement.rows
This commit is contained in:
parent
d7c58aa58d
commit
ad36bc72f4
2 changed files with 17 additions and 6 deletions
|
@ -22,17 +22,24 @@ HTMLTableSectionElement::HTMLTableSectionElement(DOM::Document& document, DOM::Q
|
||||||
|
|
||||||
HTMLTableSectionElement::~HTMLTableSectionElement() = default;
|
HTMLTableSectionElement::~HTMLTableSectionElement() = default;
|
||||||
|
|
||||||
|
void HTMLTableSectionElement::visit_edges(Cell::Visitor& visitor)
|
||||||
|
{
|
||||||
|
Base::visit_edges(visitor);
|
||||||
|
visitor.visit(m_rows);
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-rows
|
// https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-rows
|
||||||
JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableSectionElement::rows() const
|
JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableSectionElement::rows() const
|
||||||
{
|
{
|
||||||
// The rows attribute must return an HTMLCollection rooted at this element,
|
// The rows attribute must return an HTMLCollection rooted at this element,
|
||||||
// whose filter matches only tr elements that are children of this element.
|
// whose filter matches only tr elements that are children of this element.
|
||||||
// FIXME: This should return the same HTMLCollection object every time,
|
if (!m_rows) {
|
||||||
// but that would cause a reference cycle since HTMLCollection refs the root.
|
m_rows = DOM::HTMLCollection::create(const_cast<HTMLTableSectionElement&>(*this), [this](Element const& element) {
|
||||||
return DOM::HTMLCollection::create(const_cast<HTMLTableSectionElement&>(*this), [this](Element const& element) {
|
return element.parent() == this
|
||||||
return element.parent() == this
|
&& is<HTMLTableRowElement>(element);
|
||||||
&& is<HTMLTableRowElement>(element);
|
});
|
||||||
});
|
}
|
||||||
|
return *m_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-insertrow
|
// https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-insertrow
|
||||||
|
|
|
@ -23,6 +23,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName);
|
HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
JS::GCPtr<DOM::HTMLCollection> mutable m_rows;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue