Skip to content

Commit 133e0e0

Browse files
committed
LibWeb/IDB: Implement IDBObjectStore::put
1 parent 94183f1 commit 133e0e0

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,11 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::add(JS::Value value, Op
324324
return add_or_put(*this, value, key, true);
325325
}
326326

327+
// https://w3c.github.io/IndexedDB/#dom-idbobjectstore-put
328+
WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::put(JS::Value value, Optional<JS::Value> const& key)
329+
{
330+
// The put(value, key) method steps are to return the result of running add or put with this, value, key and the no-overwrite flag false.
331+
return add_or_put(*this, value, key, false);
332+
}
333+
327334
}

Libraries/LibWeb/IndexedDB/IDBObjectStore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class IDBObjectStore : public Bindings::PlatformObject {
4646

4747
[[nodiscard]] WebIDL::ExceptionOr<GC::Ref<IDBRequest>> add_or_put(GC::Ref<IDBObjectStore>, JS::Value, Optional<JS::Value> const&, bool);
4848
[[nodiscard]] WebIDL::ExceptionOr<GC::Ref<IDBRequest>> add(JS::Value value, Optional<JS::Value> const& key);
49+
[[nodiscard]] WebIDL::ExceptionOr<GC::Ref<IDBRequest>> put(JS::Value value, Optional<JS::Value> const& key);
4950

5051
protected:
5152
explicit IDBObjectStore(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBTransaction>);

Libraries/LibWeb/IndexedDB/IDBObjectStore.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface IDBObjectStore {
1010
[SameObject] readonly attribute IDBTransaction transaction;
1111
readonly attribute boolean autoIncrement;
1212

13-
[FIXME, NewObject] IDBRequest put(any value, optional any key);
13+
[NewObject] IDBRequest put(any value, optional any key);
1414
[NewObject] IDBRequest add(any value, optional any key);
1515
[FIXME, NewObject] IDBRequest delete(any query);
1616
[FIXME, NewObject] IDBRequest clear();

0 commit comments

Comments
 (0)