mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb/IDB: Implement retrieve_a_key_from_an_object_store
This commit is contained in:
Notes:
github-actions[bot]
2025-05-12 20:29:48 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/c47ddf11ba1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4662 Reviewed-by: https://github.com/shannonbooth ✅
@@ -1855,4 +1855,18 @@ JS::Value clear_an_object_store(GC::Ref<ObjectStore> store)
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#retrieve-a-key-from-an-object-store
|
||||
JS::Value retrieve_a_key_from_an_object_store(JS::Realm& realm, GC::Ref<ObjectStore> store, GC::Ref<IDBKeyRange> range)
|
||||
{
|
||||
// 1. Let record be the first record in store’s list of records whose key is in range, if any.
|
||||
auto record = store->first_in_range(range);
|
||||
|
||||
// 2. If record was not found, return undefined.
|
||||
if (!record.has_value())
|
||||
return JS::js_undefined();
|
||||
|
||||
// 3. Return the result of converting a key to a value with record’s key.
|
||||
return convert_a_key_to_a_value(realm, record.value().key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user