mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 21:30:58 +00:00 
			
		
		
		
	LibWeb/IDB: Implement retrieve_a_key_from_an_object_store
This commit is contained in:
		
							parent
							
								
									09c794d40d
								
							
						
					
					
						commit
						c47ddf11ba
					
				
				
				Notes:
				
					github-actions[bot]
				
				2025-05-12 20:29:48 +00:00 
				
			
			Author: https://github.com/stelar7
Commit: c47ddf11ba
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4662
Reviewed-by: https://github.com/shannonbooth ✅
			
					 2 changed files with 15 additions and 0 deletions
				
			
		|  | @ -1855,4 +1855,18 @@ JS::Value clear_an_object_store(GC::Ref<ObjectStore> store) | ||||||
|     return JS::js_undefined(); |     return JS::js_undefined(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // https://w3c.github.io/IndexedDB/#retrieve-a-key-from-an-object-store
 | ||||||
|  | JS::Value retrieve_a_key_from_an_object_store(JS::Realm& realm, GC::Ref<ObjectStore> store, GC::Ref<IDBKeyRange> range) | ||||||
|  | { | ||||||
|  |     // 1. Let record be the first record in store’s list of records whose key is in range, if any.
 | ||||||
|  |     auto record = store->first_in_range(range); | ||||||
|  | 
 | ||||||
|  |     // 2. If record was not found, return undefined.
 | ||||||
|  |     if (!record.has_value()) | ||||||
|  |         return JS::js_undefined(); | ||||||
|  | 
 | ||||||
|  |     // 3. Return the result of converting a key to a value with record’s key.
 | ||||||
|  |     return convert_a_key_to_a_value(realm, record.value().key); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -46,5 +46,6 @@ JS::Value count_the_records_in_a_range(GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange | ||||||
| WebIDL::ExceptionOr<JS::Value> retrieve_a_value_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>); | WebIDL::ExceptionOr<JS::Value> retrieve_a_value_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>); | ||||||
| GC::Ptr<IDBCursor> iterate_a_cursor(JS::Realm&, GC::Ref<IDBCursor>, GC::Ptr<Key> = nullptr, GC::Ptr<Key> = nullptr, u64 = 1); | GC::Ptr<IDBCursor> iterate_a_cursor(JS::Realm&, GC::Ref<IDBCursor>, GC::Ptr<Key> = nullptr, GC::Ptr<Key> = nullptr, u64 = 1); | ||||||
| JS::Value clear_an_object_store(GC::Ref<ObjectStore>); | JS::Value clear_an_object_store(GC::Ref<ObjectStore>); | ||||||
|  | JS::Value retrieve_a_key_from_an_object_store(JS::Realm&, GC::Ref<ObjectStore>, GC::Ref<IDBKeyRange>); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 stelar7
						stelar7