diff --git a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp index 045fad8d10e..152b322fa12 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp +++ b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp @@ -1318,7 +1318,10 @@ JS::Value delete_records_from_an_object_store(GC::Ref store, GC::Re // 1. Remove all records, if any, from store’s list of records with key in range. store->remove_records_in_range(range); - // FIXME: 2. For each index which references store, remove every record from index’s list of records whose value is in range, if any such records exist. + // 2. For each index which references store, remove every record from index’s list of records whose value is in range, if any such records exist. + for (auto const& [name, index] : store->index_set()) { + index->remove_records_with_value_in_range(range); + } // 3. Return undefined. return JS::js_undefined(); diff --git a/Libraries/LibWeb/IndexedDB/Internal/Index.cpp b/Libraries/LibWeb/IndexedDB/Internal/Index.cpp index 70cde9ea2aa..218ffc17839 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/Index.cpp +++ b/Libraries/LibWeb/IndexedDB/Internal/Index.cpp @@ -122,4 +122,11 @@ void Index::store_a_record(IndexRecord const& record) }); } +void Index::remove_records_with_value_in_range(GC::Ref range) +{ + m_records.remove_all_matching([&](auto const& record) { + return range->is_in_range(record.value); + }); +} + } diff --git a/Libraries/LibWeb/IndexedDB/Internal/Index.h b/Libraries/LibWeb/IndexedDB/Internal/Index.h index b8632a70c45..8be499b1058 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/Index.h +++ b/Libraries/LibWeb/IndexedDB/Internal/Index.h @@ -45,6 +45,7 @@ public: GC::ConservativeVector first_n_in_range(GC::Ref range, Optional count); u64 count_records_in_range(GC::Ref range); void store_a_record(IndexRecord const& record); + void remove_records_with_value_in_range(GC::Ref range); HTML::SerializationRecord referenced_value(IndexRecord const& index_record) const;