LibWeb/IDB: Add ObjectStore to IDBDatabases store set

This commit is contained in:
stelar7 2025-04-02 11:14:50 +02:00
parent 4b87e81402
commit 0bdb23571a
2 changed files with 4 additions and 0 deletions

View file

@ -136,6 +136,9 @@ WebIDL::ExceptionOr<GC::Ref<IDBObjectStore>> IDBDatabase::create_object_store(St
// If keyPath is not null, set the created object store's key path to keyPath.
auto object_store = ObjectStore::create(realm, database, name, auto_increment, key_path);
// AD-HOC: Add newly created object store to this's object store set.
add_to_object_store_set(object_store);
// 10. Return a new object store handle associated with store and transaction.
return IDBObjectStore::create(realm, object_store, *transaction);
}

View file

@ -53,6 +53,7 @@ public:
[[nodiscard]] ConnectionState state() const { return m_state; }
[[nodiscard]] GC::Ref<Database> associated_database() { return m_associated_database; }
[[nodiscard]] ReadonlySpan<GC::Ref<ObjectStore>> object_store_set() { return m_object_store_set; }
void add_to_object_store_set(GC::Ref<ObjectStore> object_store) { m_object_store_set.append(object_store); }
void remove_from_object_store_set(GC::Ref<ObjectStore> object_store)
{
m_object_store_set.remove_first_matching([&](auto& entry) { return entry == object_store; });