LibWeb/IDB: Implement retrieve_a_key_from_an_object_store

This commit is contained in:
stelar7 2025-05-08 15:27:11 +02:00 committed by Shannon Booth
parent 09c794d40d
commit c47ddf11ba
Notes: github-actions[bot] 2025-05-12 20:29:48 +00:00
2 changed files with 15 additions and 0 deletions

View file

@ -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 stores 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 records key.
return convert_a_key_to_a_value(realm, record.value().key);
}
}