mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-13 04:21:54 +00:00
LibWeb/IDB: Implement retrieve_a_value_from_an_object_store
This commit is contained in:
parent
d5cf2cee41
commit
18a008d073
Notes:
github-actions[bot]
2025-04-29 15:07:46 +00:00
Author: https://github.com/stelar7
Commit: 18a008d073
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4505
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
4 changed files with 26 additions and 0 deletions
|
@ -1458,4 +1458,21 @@ JS::Value count_the_records_in_a_range(GC::Ref<ObjectStore> source, GC::Ref<IDBK
|
|||
return JS::Value(count);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#retrieve-a-value-from-an-object-store
|
||||
WebIDL::ExceptionOr<JS::Value> retrieve_a_value_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. Let serialized be record’s value. If an error occurs while reading the value from the underlying storage, return a newly created "NotReadableError" DOMException.
|
||||
auto serialized = record->value;
|
||||
|
||||
// 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