Skip to content

Commit 8fcba17

Browse files
stelar7trflynn89
authored andcommitted
LibWeb/IDB: Correctly implement IDBRecord getters
1 parent 244f086 commit 8fcba17

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Libraries/LibWeb/IndexedDB/IDBRecord.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <LibWeb/Bindings/IDBRecordPrototype.h>
88
#include <LibWeb/IndexedDB/IDBRecord.h>
9+
#include <LibWeb/IndexedDB/Internal/Algorithms.h>
910

1011
namespace Web::IndexedDB {
1112

@@ -40,4 +41,18 @@ void IDBRecord::visit_edges(Visitor& visitor)
4041
visitor.visit(m_primary_key);
4142
}
4243

44+
// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#dom-idbrecord-key
45+
WebIDL::ExceptionOr<JS::Value> IDBRecord::key() const
46+
{
47+
// The key getter steps are to return the result of converting a key to a value with this’s key.
48+
return convert_a_key_to_a_value(realm(), m_key);
49+
}
50+
51+
// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#dom-idbrecord-primarykey
52+
WebIDL::ExceptionOr<JS::Value> IDBRecord::primary_key() const
53+
{
54+
// The primaryKey getter steps are to return the result of converting a key to a value with this’s primary key.
55+
return convert_a_key_to_a_value(realm(), m_primary_key);
56+
}
57+
4358
}

Libraries/LibWeb/IndexedDB/IDBRecord.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class IDBRecord : public Bindings::PlatformObject {
3636
[[nodiscard]] static GC::Ref<IDBRecord> create(JS::Realm& realm, GC::Ref<Key> key, JS::Value value, GC::Ref<Key> primary_key);
3737
virtual ~IDBRecord();
3838

39-
GC::Ref<Key> key() const { return m_key; }
40-
GC::Ref<Key> primary_key() const { return m_primary_key; }
4139
JS::Value value() const { return m_value; }
40+
WebIDL::ExceptionOr<JS::Value> key() const;
41+
WebIDL::ExceptionOr<JS::Value> primary_key() const;
4242

4343
protected:
4444
explicit IDBRecord(JS::Realm&, GC::Ref<Key> key, JS::Value value, GC::Ref<Key> primary_key);

0 commit comments

Comments
 (0)