mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 14:40:18 +00:00
LibWeb: Implement DataTransferItemList.remove()
This commit is contained in:
parent
8ab3549585
commit
d9341adb1e
Notes:
github-actions[bot]
2025-09-12 10:31:50 +00:00
Author: https://github.com/tcl3
Commit: d9341adb1e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6088
Reviewed-by: https://github.com/gmta
9 changed files with 84 additions and 1 deletions
|
@ -108,6 +108,23 @@ GC::Ptr<DataTransferItem> DataTransferItemList::add(GC::Ref<FileAPI::File> file)
|
|||
return item;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-remove
|
||||
WebIDL::ExceptionOr<void> DataTransferItemList::remove(WebIDL::UnsignedLong index)
|
||||
{
|
||||
// 1. If the DataTransferItemList object is not in the read/write mode, throw an "InvalidStateError" DOMException.
|
||||
if (m_data_transfer->mode() != DragDataStore::Mode::ReadWrite)
|
||||
return WebIDL::InvalidStateError::create(realm(), "DataTransferItemList is not in read/write mode"_utf16);
|
||||
|
||||
// 2. If the drag data store does not contain an indexth item, then return.
|
||||
if (index >= m_data_transfer->length())
|
||||
return {};
|
||||
|
||||
// 3. Remove the indexth item from the drag data store
|
||||
m_data_transfer->remove_item(index);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-item
|
||||
Optional<JS::Value> DataTransferItemList::item_value(size_t index) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue