LibWeb: Add methods to Document that must do nothing

This change adds the `clear()`, `captureEvents()` and `releaseEvents()`
methods to the document object. These methods are obsolete, but are
still included in the HTML specification, which says they must do
nothing.
This commit is contained in:
Tim Ledbetter 2024-04-14 07:25:49 +01:00 committed by Andreas Kling
commit 0564e06f10
Notes: sideshowbarker 2024-07-18 05:37:06 +09:00
5 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,3 @@
document.clear() returns undefined: true
document.captureEvents() returns undefined: true
document.releaseEvents() returns undefined: true

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
test(() => {
println(`document.clear() returns undefined: ${document.clear() === undefined}`);
println(`document.captureEvents() returns undefined: ${document.captureEvents() === undefined}`);
println(`document.releaseEvents() returns undefined: ${document.releaseEvents() === undefined}`);
});
</script>

View file

@ -1472,6 +1472,24 @@ JS::NonnullGCPtr<HTML::HTMLAllCollection> Document::all()
return *m_all; return *m_all;
} }
// https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-clear
void Document::clear()
{
// Do nothing
}
// https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-captureevents
void Document::capture_events()
{
// Do nothing
}
// https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-releaseevents
void Document::release_events()
{
// Do nothing
}
Color Document::link_color() const Color Document::link_color() const
{ {
if (m_link_color.has_value()) if (m_link_color.has_value())

View file

@ -243,6 +243,10 @@ public:
JS::NonnullGCPtr<HTMLCollection> scripts(); JS::NonnullGCPtr<HTMLCollection> scripts();
JS::NonnullGCPtr<HTML::HTMLAllCollection> all(); JS::NonnullGCPtr<HTML::HTMLAllCollection> all();
void clear();
void capture_events();
void release_events();
String const& source() const { return m_source; } String const& source() const { return m_source; }
void set_source(String source) { m_source = move(source); } void set_source(String source) { m_source = move(source); }

View file

@ -78,6 +78,10 @@ interface Document : Node {
readonly attribute HTMLAllCollection all; readonly attribute HTMLAllCollection all;
undefined clear();
undefined captureEvents();
undefined releaseEvents();
[CEReactions, NewObject] Element createElement(DOMString tagName, optional (DOMString or ElementCreationOptions) options = {}); [CEReactions, NewObject] Element createElement(DOMString tagName, optional (DOMString or ElementCreationOptions) options = {});
[CEReactions, NewObject] Element createElementNS([FlyString] DOMString? namespace, DOMString qualifiedName, optional (DOMString or ElementCreationOptions) options = {}); [CEReactions, NewObject] Element createElementNS([FlyString] DOMString? namespace, DOMString qualifiedName, optional (DOMString or ElementCreationOptions) options = {});
DocumentFragment createDocumentFragment(); DocumentFragment createDocumentFragment();