mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWeb/IDB: Implement IDBObjectStore::createIndex
This commit is contained in:
parent
a235dd4300
commit
3367352991
Notes:
github-actions[bot]
2025-04-09 17:50:46 +00:00
Author: https://github.com/stelar7
Commit: 3367352991
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4178
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
7 changed files with 88 additions and 14 deletions
|
@ -71,14 +71,16 @@ WebIDL::ExceptionOr<void> IDBIndex::set_name(String const& value)
|
|||
return {};
|
||||
|
||||
// 8. If an index named name already exists in index’s object store, throw a "ConstraintError" DOMException.
|
||||
for (auto const& existing_index : m_object_store_handle->index_set()) {
|
||||
if (existing_index->name() == name)
|
||||
return WebIDL::ConstraintError::create(realm, "An index with the given name already exists"_string);
|
||||
}
|
||||
if (index->object_store()->index_set().contains(name))
|
||||
return WebIDL::ConstraintError::create(realm, "An index with the given name already exists"_string);
|
||||
|
||||
// 9. Set index’s name to name.
|
||||
index->set_name(name);
|
||||
|
||||
// NOTE: Update the key in the map so it still matches the name
|
||||
auto old_value = m_object_store_handle->index_set().take(m_name).release_value();
|
||||
m_object_store_handle->index_set().set(name, old_value);
|
||||
|
||||
// 10. Set this’s name to name.
|
||||
m_name = name;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue