mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb/IDB: Implement extract_a_key_from_a_value_using_a_key_path
This commit is contained in:
parent
84ea78eb4d
commit
eab7a2bb05
Notes:
github-actions[bot]
2025-04-23 18:38:26 +00:00
Author: https://github.com/stelar7
Commit: eab7a2bb05
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4317
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/kennethmyhra ✅
2 changed files with 15 additions and 0 deletions
|
@ -976,4 +976,18 @@ WebIDL::ExceptionOr<ErrorOr<JS::Value>> evaluate_key_path_on_a_value(JS::Realm&
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/IndexedDB/#extract-a-key-from-a-value-using-a-key-path
|
||||||
|
WebIDL::ExceptionOr<ErrorOr<GC::Ref<Key>>> extract_a_key_from_a_value_using_a_key_path(JS::Realm& realm, JS::Value value, KeyPath const& key_path, bool multi_entry)
|
||||||
|
{
|
||||||
|
// 1. Let r be the result of evaluating a key path on a value with value and keyPath. Rethrow any exceptions.
|
||||||
|
// 2. If r is failure, return failure.
|
||||||
|
auto r = TRY(TRY(evaluate_key_path_on_a_value(realm, value, key_path)));
|
||||||
|
|
||||||
|
// 3. Let key be the result of converting a value to a key with r if the multiEntry flag is false,
|
||||||
|
// and the result of converting a value to a multiEntry key with r otherwise. Rethrow any exceptions.
|
||||||
|
// 4. If key is invalid, return invalid.
|
||||||
|
// 5. Return key.
|
||||||
|
return multi_entry ? TRY(convert_a_value_to_a_multi_entry_key(realm, r)) : TRY(convert_a_value_to_a_key(realm, r));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,5 +31,6 @@ void commit_a_transaction(JS::Realm&, GC::Ref<IDBTransaction>);
|
||||||
WebIDL::ExceptionOr<JS::Value> clone_in_realm(JS::Realm&, JS::Value, GC::Ref<IDBTransaction>);
|
WebIDL::ExceptionOr<JS::Value> clone_in_realm(JS::Realm&, JS::Value, GC::Ref<IDBTransaction>);
|
||||||
WebIDL::ExceptionOr<ErrorOr<GC::Ref<Key>>> convert_a_value_to_a_multi_entry_key(JS::Realm&, JS::Value);
|
WebIDL::ExceptionOr<ErrorOr<GC::Ref<Key>>> convert_a_value_to_a_multi_entry_key(JS::Realm&, JS::Value);
|
||||||
WebIDL::ExceptionOr<ErrorOr<JS::Value>> evaluate_key_path_on_a_value(JS::Realm&, JS::Value, KeyPath const&);
|
WebIDL::ExceptionOr<ErrorOr<JS::Value>> evaluate_key_path_on_a_value(JS::Realm&, JS::Value, KeyPath const&);
|
||||||
|
WebIDL::ExceptionOr<ErrorOr<GC::Ref<Key>>> extract_a_key_from_a_value_using_a_key_path(JS::Realm&, JS::Value, KeyPath const&, bool = false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue