LibWeb/IDB: Correctly implement IDBRecord getters

This commit is contained in:
stelar7 2025-10-28 18:48:39 +01:00 committed by Tim Flynn
parent 244f086709
commit 8fcba173e0
Notes: github-actions[bot] 2025-10-28 23:26:49 +00:00
2 changed files with 17 additions and 2 deletions

View file

@ -6,6 +6,7 @@
#include <LibWeb/Bindings/IDBRecordPrototype.h>
#include <LibWeb/IndexedDB/IDBRecord.h>
#include <LibWeb/IndexedDB/Internal/Algorithms.h>
namespace Web::IndexedDB {
@ -40,4 +41,18 @@ void IDBRecord::visit_edges(Visitor& visitor)
visitor.visit(m_primary_key);
}
// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#dom-idbrecord-key
WebIDL::ExceptionOr<JS::Value> IDBRecord::key() const
{
// The key getter steps are to return the result of converting a key to a value with thiss key.
return convert_a_key_to_a_value(realm(), m_key);
}
// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#dom-idbrecord-primarykey
WebIDL::ExceptionOr<JS::Value> IDBRecord::primary_key() const
{
// The primaryKey getter steps are to return the result of converting a key to a value with thiss primary key.
return convert_a_key_to_a_value(realm(), m_primary_key);
}
}

View file

@ -36,9 +36,9 @@ public:
[[nodiscard]] static GC::Ref<IDBRecord> create(JS::Realm& realm, GC::Ref<Key> key, JS::Value value, GC::Ref<Key> primary_key);
virtual ~IDBRecord();
GC::Ref<Key> key() const { return m_key; }
GC::Ref<Key> primary_key() const { return m_primary_key; }
JS::Value value() const { return m_value; }
WebIDL::ExceptionOr<JS::Value> key() const;
WebIDL::ExceptionOr<JS::Value> primary_key() const;
protected:
explicit IDBRecord(JS::Realm&, GC::Ref<Key> key, JS::Value value, GC::Ref<Key> primary_key);