diff --git a/Libraries/LibWeb/HTML/Storage.cpp b/Libraries/LibWeb/HTML/Storage.cpp
index c4adf5f045a..6420edcc9ab 100644
--- a/Libraries/LibWeb/HTML/Storage.cpp
+++ b/Libraries/LibWeb/HTML/Storage.cpp
@@ -84,7 +84,7 @@ WebIDL::ExceptionOr Storage::set_item(String const& key, String const& val
auto& realm = this->realm();
// 1. Let oldValue be null.
- String old_value;
+ Optional old_value;
// 2. Let reorder be true.
bool reorder = true;
@@ -106,7 +106,7 @@ WebIDL::ExceptionOr Storage::set_item(String const& key, String const& val
}
// 4. If value cannot be stored, then throw a "QuotaExceededError" DOMException exception.
- new_size += value.bytes().size() - old_value.bytes().size();
+ new_size += value.bytes().size() - old_value.value_or(String {}).bytes().size();
if (new_size > m_quota_bytes)
return WebIDL::QuotaExceededError::create(realm, MUST(String::formatted("Unable to store more than {} bytes in storage"sv, m_quota_bytes)));
@@ -125,7 +125,7 @@ WebIDL::ExceptionOr Storage::set_item(String const& key, String const& val
}
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-removeitem
-void Storage::remove_item(StringView key)
+void Storage::remove_item(String const& key)
{
// 1. If this's map[key] does not exist, then return null.
// FIXME: Return null?
@@ -165,7 +165,7 @@ void Storage::reorder()
}
// https://html.spec.whatwg.org/multipage/webstorage.html#concept-storage-broadcast
-void Storage::broadcast(StringView key, StringView old_value, StringView new_value)
+void Storage::broadcast(Optional const& key, Optional const& old_value, Optional const& new_value)
{
(void)key;
(void)old_value;
diff --git a/Libraries/LibWeb/HTML/Storage.h b/Libraries/LibWeb/HTML/Storage.h
index d066ec90416..0e06fa0e90b 100644
--- a/Libraries/LibWeb/HTML/Storage.h
+++ b/Libraries/LibWeb/HTML/Storage.h
@@ -33,7 +33,7 @@ public:
Optional key(size_t index);
Optional get_item(StringView key) const;
WebIDL::ExceptionOr set_item(String const& key, String const& value);
- void remove_item(StringView key);
+ void remove_item(String const& key);
void clear();
auto const& map() const { return m_map; }
@@ -55,7 +55,7 @@ private:
virtual WebIDL::ExceptionOr set_value_of_named_property(String const& key, JS::Value value) override;
void reorder();
- void broadcast(StringView key, StringView old_value, StringView new_value);
+ void broadcast(Optional const& key, Optional const& old_value, Optional const& new_value);
OrderedHashMap m_map;
Type m_type {};