LibWeb/IDB: Implement IDBCursor::primary_key

This commit is contained in:
stelar7 2025-05-08 09:42:58 +02:00 committed by Sam Atkins
commit 8f876e824b
Notes: github-actions[bot] 2025-05-08 13:14:51 +00:00
3 changed files with 9 additions and 1 deletions

View file

@ -162,4 +162,11 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_(JS::Value key)
}); });
} }
// https://w3c.github.io/IndexedDB/#dom-idbcursor-primarykey
JS::Value IDBCursor::primary_key() const
{
// The primaryKey getter steps are to return the result of converting a key to a value with the cursors current effective key.
return convert_a_key_to_a_value(realm(), effective_key());
}
} }

View file

@ -43,6 +43,7 @@ public:
[[nodiscard]] GC::Ref<IDBTransaction> transaction(); [[nodiscard]] GC::Ref<IDBTransaction> transaction();
[[nodiscard]] CursorSource internal_source(); [[nodiscard]] CursorSource internal_source();
[[nodiscard]] GC::Ref<Key> effective_key() const; [[nodiscard]] GC::Ref<Key> effective_key() const;
[[nodiscard]] JS::Value primary_key() const;
void set_request(GC::Ptr<IDBRequest> request) { m_request = request; } void set_request(GC::Ptr<IDBRequest> request) { m_request = request; }
void set_position(GC::Ptr<Key> position) { m_position = position; } void set_position(GC::Ptr<Key> position) { m_position = position; }

View file

@ -5,7 +5,7 @@ interface IDBCursor {
[ImplementedAs=source_handle] readonly attribute (IDBObjectStore or IDBIndex) source; [ImplementedAs=source_handle] readonly attribute (IDBObjectStore or IDBIndex) source;
readonly attribute IDBCursorDirection direction; readonly attribute IDBCursorDirection direction;
readonly attribute any key; readonly attribute any key;
[FIXME] readonly attribute any primaryKey; readonly attribute any primaryKey;
[SameObject] readonly attribute IDBRequest request; [SameObject] readonly attribute IDBRequest request;
[FIXME] undefined advance([EnforceRange] unsigned long count); [FIXME] undefined advance([EnforceRange] unsigned long count);
undefined continue(optional any key); undefined continue(optional any key);