mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb/HTML: Make storage broadcast take optional strings
Matching the arguments specified by the spec, needed to properly represent null values.
This commit is contained in:
parent
bbf4739c8e
commit
9a1e5e1835
Notes:
github-actions[bot]
2025-01-02 10:39:32 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/9a1e5e18357 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3070 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/konradekk
2 changed files with 6 additions and 6 deletions
|
@ -84,7 +84,7 @@ WebIDL::ExceptionOr<void> Storage::set_item(String const& key, String const& val
|
|||
auto& realm = this->realm();
|
||||
|
||||
// 1. Let oldValue be null.
|
||||
String old_value;
|
||||
Optional<String> old_value;
|
||||
|
||||
// 2. Let reorder be true.
|
||||
bool reorder = true;
|
||||
|
@ -106,7 +106,7 @@ WebIDL::ExceptionOr<void> 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<void> 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<String> const& key, Optional<String> const& old_value, Optional<String> const& new_value)
|
||||
{
|
||||
(void)key;
|
||||
(void)old_value;
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
Optional<String> key(size_t index);
|
||||
Optional<String> get_item(StringView key) const;
|
||||
WebIDL::ExceptionOr<void> 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<void> 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<String> const& key, Optional<String> const& old_value, Optional<String> const& new_value);
|
||||
|
||||
OrderedHashMap<String, String> m_map;
|
||||
Type m_type {};
|
||||
|
|
Loading…
Reference in a new issue