mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb/IDB: Implement IDBObjectStore::keyPath
This commit is contained in:
parent
1057c88fdd
commit
594ba28c35
Notes:
github-actions[bot]
2025-03-27 15:49:32 +00:00
Author: https://github.com/stelar7
Commit: 594ba28c35
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4077
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
3 changed files with 22 additions and 1 deletions
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibWeb/Bindings/IDBObjectStorePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
|
@ -40,4 +42,21 @@ void IDBObjectStore::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_transaction);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#dom-idbobjectstore-keypath
|
||||
JS::Value IDBObjectStore::key_path() const
|
||||
{
|
||||
if (!m_store->key_path().has_value())
|
||||
return JS::js_null();
|
||||
|
||||
return m_store->key_path().value().visit(
|
||||
[&](String const& value) -> JS::Value {
|
||||
return JS::PrimitiveString::create(realm().vm(), value);
|
||||
},
|
||||
[&](Vector<String> const& value) -> JS::Value {
|
||||
return JS::Array::create_from<String>(realm(), value.span(), [&](auto const& entry) -> JS::Value {
|
||||
return JS::PrimitiveString::create(realm().vm(), entry);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue