mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-14 21:11:57 +00:00
LibWeb/IDB: Implement IDBIndex::get
This commit is contained in:
parent
73fa567e7a
commit
e74e571b56
Notes:
github-actions[bot]
2025-05-14 15:19:35 +00:00
Author: https://github.com/stelar7
Commit: e74e571b56
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4727
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/shannonbooth
7 changed files with 62 additions and 3 deletions
|
@ -1929,4 +1929,21 @@ GC::Ref<JS::Array> retrieve_multiple_keys_from_an_object_store(JS::Realm& realm,
|
|||
return list;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#retrieve-a-referenced-value-from-an-index
|
||||
JS::Value retrieve_a_referenced_value_from_an_index(JS::Realm& realm, GC::Ref<Index> index, GC::Ref<IDBKeyRange> range)
|
||||
{
|
||||
// 1. Let record be the first record in index’s list of records whose key is in range, if any.
|
||||
auto record = index->first_in_range(range);
|
||||
|
||||
// 2. If record was not found, return undefined.
|
||||
if (!record.has_value())
|
||||
return JS::js_undefined();
|
||||
|
||||
// 3. Let serialized be record’s referenced value.
|
||||
auto serialized = index->referenced_value(*record);
|
||||
|
||||
// 4. Return ! StructuredDeserialize(serialized, targetRealm).
|
||||
return MUST(HTML::structured_deserialize(realm.vm(), serialized, realm));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue