mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb: Implement the DataTransferItemList indexed getter
This commit is contained in:
parent
843f8f04a5
commit
ceb9e30d42
Notes:
github-actions[bot]
2024-08-22 12:22:27 +00:00
Author: https://github.com/trflynn89
Commit: ceb9e30d42
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1158
Reviewed-by: https://github.com/shannonbooth
6 changed files with 36 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/FileAPI/File.h>
|
||||
#include <LibWeb/HTML/DataTransfer.h>
|
||||
#include <LibWeb/HTML/DataTransferItem.h>
|
||||
#include <LibWeb/HTML/DataTransferItemList.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
|
||||
|
@ -25,6 +26,7 @@ DataTransferItemList::DataTransferItemList(JS::Realm& realm, JS::NonnullGCPtr<Da
|
|||
: PlatformObject(realm)
|
||||
, m_data_transfer(data_transfer)
|
||||
{
|
||||
m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = true };
|
||||
}
|
||||
|
||||
DataTransferItemList::~DataTransferItemList() = default;
|
||||
|
@ -108,4 +110,16 @@ JS::GCPtr<DataTransferItem> DataTransferItemList::add(JS::NonnullGCPtr<FileAPI::
|
|||
return item;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransferitemlist-item
|
||||
Optional<JS::Value> DataTransferItemList::item_value(size_t index) const
|
||||
{
|
||||
// To determine the value of an indexed property i of a DataTransferItemList object, the user agent must return a
|
||||
// DataTransferItem object representing the ith item in the drag data store. The same object must be returned each
|
||||
// time a particular item is obtained from this DataTransferItemList object. The DataTransferItem object must be
|
||||
// associated with the same DataTransfer object as the DataTransferItemList object when it is first created.
|
||||
if (index < m_data_transfer->length())
|
||||
return m_data_transfer->item(index);
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue