diff --git a/Libraries/LibWeb/HTML/DataTransferItemList.cpp b/Libraries/LibWeb/HTML/DataTransferItemList.cpp
index f375e05345a..199d1cf38d6 100644
--- a/Libraries/LibWeb/HTML/DataTransferItemList.cpp
+++ b/Libraries/LibWeb/HTML/DataTransferItemList.cpp
@@ -125,6 +125,15 @@ WebIDL::ExceptionOr DataTransferItemList::remove(WebIDL::UnsignedLong inde
return {};
}
+// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-clear
+void DataTransferItemList::clear()
+{
+ // The clear() method, if the DataTransferItemList object is in the read/write mode, must remove all the items from
+ // the drag data store. Otherwise, it must do nothing.
+ if (m_data_transfer->mode() == DragDataStore::Mode::ReadWrite)
+ m_data_transfer->clear_data();
+}
+
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-item
Optional DataTransferItemList::item_value(size_t index) const
{
diff --git a/Libraries/LibWeb/HTML/DataTransferItemList.h b/Libraries/LibWeb/HTML/DataTransferItemList.h
index 74918859102..268ce93cf5f 100644
--- a/Libraries/LibWeb/HTML/DataTransferItemList.h
+++ b/Libraries/LibWeb/HTML/DataTransferItemList.h
@@ -27,6 +27,7 @@ public:
WebIDL::ExceptionOr> add(String const& data, String const& type);
GC::Ptr add(GC::Ref);
WebIDL::ExceptionOr remove(WebIDL::UnsignedLong index);
+ void clear();
private:
DataTransferItemList(JS::Realm&, GC::Ref);
diff --git a/Libraries/LibWeb/HTML/DataTransferItemList.idl b/Libraries/LibWeb/HTML/DataTransferItemList.idl
index e59f6010844..94811638a5d 100644
--- a/Libraries/LibWeb/HTML/DataTransferItemList.idl
+++ b/Libraries/LibWeb/HTML/DataTransferItemList.idl
@@ -9,5 +9,5 @@ interface DataTransferItemList {
DataTransferItem? add(DOMString data, DOMString type);
DataTransferItem? add(File data);
undefined remove(unsigned long index);
- [FIXME] undefined clear();
+ undefined clear();
};