mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-13 20:41:53 +00:00
LibWeb/IDB: Implement retrieve_a_key_from_an_object_store
This commit is contained in:
parent
09c794d40d
commit
c47ddf11ba
Notes:
github-actions[bot]
2025-05-12 20:29:48 +00:00
Author: https://github.com/stelar7
Commit: c47ddf11ba
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4662
Reviewed-by: https://github.com/shannonbooth ✅
2 changed files with 15 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue