2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2022-01-31 13:07:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2021 ,  Tim  Flynn  < trflynn89 @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-04 13:19:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2022 ,  Andreas  Kling  < andreas @ ladybird . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/StringBuilder.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-04-27 12:09:58 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Bindings/DOMTokenListPrototype.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/DOMTokenList.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-08-08 15:19:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Document.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/DOM/Element.h> 
  
						 
					
						
							
								
									
										
										
										
											2024-05-16 18:07:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/HTML/HTMLLinkElement.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-10-01 18:14:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Infra/CharacterTypes.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-09-25 17:28:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/WebIDL/DOMException.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								namespace  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://infra.spec.whatwg.org/#set-append
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								inline  void  append_to_ordered_set ( Vector < String > &  set ,  String  item )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! set . contains_slow ( item ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        set . append ( move ( item ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://infra.spec.whatwg.org/#list-remove
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								inline  void  remove_from_ordered_set ( Vector < String > &  set ,  StringView  item )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set . remove_first_matching ( [ & ] ( auto  const &  value )  {  return  value  = =  item ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://infra.spec.whatwg.org/#set-replace
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								inline  void  replace_in_ordered_set ( Vector < String > &  set ,  String  const &  item ,  String  replacement )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  item_index  =  set . find_first_index ( item ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( item_index . has_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  replacement_index  =  set . find_first_index ( replacement ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! replacement_index . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        set [ * item_index ]  =  move ( replacement ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  index_to_set  =  min ( * item_index ,  * replacement_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  index_to_remove  =  max ( * item_index ,  * replacement_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( index_to_set  = =  index_to_remove ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set [ index_to_set ]  =  move ( replacement ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    set . remove ( index_to_remove ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								namespace  Web : : DOM  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC_DEFINE_ALLOCATOR ( DOMTokenList ) ;  
						 
					
						
							
								
									
										
										
										
											2023-11-19 19:47:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								GC : : Ref < DOMTokenList >  DOMTokenList : : create ( Element &  associated_element ,  FlyString  associated_attribute )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-09-30 17:16:16 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  realm  =  associated_element . realm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-14 05:50:17 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  realm . create < DOMTokenList > ( associated_element ,  move ( associated_attribute ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DOMTokenList : : DOMTokenList ( Element &  associated_element ,  FlyString  associated_attribute )  
						 
					
						
							
								
									
										
										
										
											2024-01-09 16:05:03 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    :  Bindings : : PlatformObject ( associated_element . realm ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 15:19:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_associated_element ( associated_element ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_associated_attribute ( move ( associated_attribute ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-01-09 16:05:03 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_legacy_platform_object_flags  =  LegacyPlatformObjectFlags  {  . supports_indexed_properties  =  1  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-16 19:04:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    associated_attribute_changed ( associated_element . get_attribute_value ( m_associated_attribute ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 08:41:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  DOMTokenList : : initialize ( JS : : Realm &  realm )  
						 
					
						
							
								
									
										
										
										
											2023-01-10 06:56:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-03-16 13:13:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    WEB_SET_PROTOTYPE_FOR_INTERFACE ( DOMTokenList ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 16:22:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Base : : initialize ( realm ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-10 06:56:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 15:32:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  DOMTokenList : : visit_edges ( Cell : : Visitor &  visitor )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Base : : visit_edges ( visitor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    visitor . visit ( m_associated_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A1
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  DOMTokenList : : associated_attribute_changed ( StringView  value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_token_set . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( value . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-02 22:30:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  split_values  =  value . split_view_if ( Infra : : is_ascii_whitespace ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  split_value  :  split_values ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        append_to_ordered_set ( m_token_set ,  String : : from_utf8 ( split_value ) . release_value_but_fixme_should_propagate_errors ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-item
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < String >  DOMTokenList : : item ( size_t  index )  const  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 1. If index is equal to or greater than this’ ’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( index  > =  m_token_set . size ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 2. Return this’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  m_token_set [ index ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  DOMTokenList : : contains ( String  const &  token )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  m_token_set . contains_slow ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-add
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < void >  DOMTokenList : : add ( Vector < String >  const &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:05:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. For each token of tokens:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  token  :  tokens )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // a. If token is the empty string, then throw a "SyntaxError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // b. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 12:37:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        TRY ( validate_token ( token ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:05:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								        // 2. For each token of tokens, append token to this’  
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        append_to_ordered_set ( m_token_set ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Run the update steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    run_update_steps ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-remove
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < void >  DOMTokenList : : remove ( Vector < String >  const &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:05:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. For each token of tokens:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  token  :  tokens )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // a. If token is the empty string, then throw a "SyntaxError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // b. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 12:37:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        TRY ( validate_token ( token ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 12:05:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								        // 2. For each token of tokens, remove token from this’  
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_from_ordered_set ( m_token_set ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Run the update steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    run_update_steps ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < bool >  DOMTokenList : : toggle ( String  const &  token ,  Optional < bool >  force )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If token is the empty string, then throw a "SyntaxError" DOMException.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 12:37:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    TRY ( validate_token ( token ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 3. If this’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( contains ( token ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								        // a. If force is either not given or is false, then remove token from this’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! force . has_value ( )  | |  ! force . value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            remove_from_ordered_set ( m_token_set ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            run_update_steps ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // b. Return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 4. Otherwise, if force not given or is true, append token to this’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! force . has_value ( )  | |  force . value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        append_to_ordered_set ( m_token_set ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        run_update_steps ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Return false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-replace
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < bool >  DOMTokenList : : replace ( String  const &  token ,  String  const &  new_token )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If either token or newToken is the empty string, then throw a "SyntaxError" DOMException.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 13:10:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    TRY ( validate_token_not_empty ( token ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TRY ( validate_token_not_empty ( new_token ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If either token or newToken contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 13:10:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    TRY ( validate_token_not_whitespace ( token ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TRY ( validate_token_not_whitespace ( new_token ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 3. If this’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! contains ( token ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 4. Replace token in this’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    replace_in_ordered_set ( m_token_set ,  token ,  new_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Run the update steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    run_update_steps ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Return true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-supports
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#concept-domtokenlist-validation
  
						 
					
						
							
								
									
										
										
										
											2024-05-16 18:07:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < bool >  DOMTokenList : : supports ( StringView  token )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-12-06 08:57:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // https://html.spec.whatwg.org/multipage/links.html#linkTypes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-sandbox
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    static  HashMap < SupportedTokenKey ,  Vector < StringView > >  supported_tokens_map  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  {  HTML : : TagNames : : link ,  HTML : : AttributeNames : : rel  } ,  {  " modulepreload " sv ,  " preload " sv ,  " preconnect " sv ,  " dns-prefetch " sv ,  " stylesheet " sv ,  " icon " sv ,  " alternate " sv ,  " prefetch " sv ,  " prerender " sv ,  " next " sv ,  " manifest " sv ,  " apple-touch-icon " sv ,  " apple-touch-icon-precomposed " sv ,  " canonical " sv  }  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  {  HTML : : TagNames : : a ,  HTML : : AttributeNames : : rel  } ,  {  " noreferrer " sv ,  " noopener " sv ,  " opener " sv  }  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  {  HTML : : TagNames : : area ,  HTML : : AttributeNames : : rel  } ,  {  " noreferrer " sv ,  " noopener " sv ,  " opener " sv  }  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  {  HTML : : TagNames : : form ,  HTML : : AttributeNames : : rel  } ,  {  " noreferrer " sv ,  " noopener " sv ,  " opener " sv  }  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  {  HTML : : TagNames : : iframe ,  HTML : : AttributeNames : : sandbox  } ,  {  " allow-downloads " sv ,  " allow-forms " sv ,  " allow-modals " sv ,  " allow-orientation-lock " sv ,  " allow-pointer-lock " sv ,  " allow-popups " sv ,  " allow-popups-to-escape-sandbox " sv ,  " allow-presentation " sv ,  " allow-same-origin " sv ,  " allow-scripts " sv ,  " allow-top-navigation " sv ,  " allow-top-navigation-by-user-activation " sv ,  " allow-top-navigation-to-custom-protocols " sv  }  } , 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 18:07:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 1. If the associated attribute’  
							 
						 
					
						
							
								
									
										
										
										
											2024-12-06 08:57:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  supported_tokens  =  supported_tokens_map . get ( {  m_associated_element - > local_name ( ) ,  m_associated_attribute  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 18:07:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! supported_tokens . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  WebIDL : : SimpleException  {  WebIDL : : SimpleExceptionType : : TypeError ,  MUST ( String : : formatted ( " Attribute {} does not define any supported tokens " ,  m_associated_attribute ) )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let lowercase token be a copy of token, in ASCII lowercase.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 10:19:35 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  lowercase_token  =  token . to_ascii_lowercase_string ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 18:07:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If lowercase token is present in supported tokens, return true.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 18:07:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( supported_tokens - > contains_slow ( lowercase_token ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Return false.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-16 18:07:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 13:09:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#concept-ordered-set-serializer
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								String  DOMTokenList : : serialize_ordered_set ( )  const  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    builder . join ( '   ' ,  m_token_set ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  MUST ( builder . to_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 13:09:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#dom-domtokenlist-value
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								String  DOMTokenList : : value ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  m_associated_element - > get_attribute_value ( m_associated_attribute ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#ref-for-concept-element-attributes-set-value%E2%91%A2
  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void  DOMTokenList : : set_value ( String  const &  value )  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < DOM : : Element >  associated_element  =  m_associated_element . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! associated_element ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-05 12:57:54 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    MUST ( associated_element - > set_attribute ( m_associated_attribute ,  value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 17:03:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < void >  DOMTokenList : : validate_token ( StringView  token )  const  
						 
					
						
							
								
									
										
										
										
											2024-07-23 13:10:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TRY ( validate_token_not_empty ( token ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TRY ( validate_token_not_whitespace ( token ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < void >  DOMTokenList : : validate_token_not_empty ( StringView  token )  const  
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-12 20:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  WebIDL : : SyntaxError : : create ( realm ( ) ,  " Non-empty DOM tokens are not allowed " _string ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 13:10:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								WebIDL : : ExceptionOr < void >  DOMTokenList : : validate_token_not_whitespace ( StringView  token )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-10-01 18:14:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( any_of ( token ,  Infra : : is_ascii_whitespace ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-12 20:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  WebIDL : : InvalidCharacterError : : create ( realm ( ) ,  " DOM tokens containing ASCII whitespace are not allowed " _string ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://dom.spec.whatwg.org/#concept-dtl-update
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void  DOMTokenList : : run_update_steps ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GC : : Ptr < DOM : : Element >  associated_element  =  m_associated_element . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! associated_element ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If the associated element does not have an associated attribute and token set is empty, then return.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-05 12:57:54 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! associated_element - > has_attribute ( m_associated_attribute )  & &  m_token_set . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 2. Set an attribute value for the associated element using associated attribute’  
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 13:09:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    MUST ( associated_element - > set_attribute ( m_associated_attribute ,  serialize_ordered_set ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-25 18:15:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < JS : : Value >  DOMTokenList : : item_value ( size_t  index )  const  
						 
					
						
							
								
									
										
										
										
											2022-08-08 15:19:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  string  =  item ( index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! string . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-25 18:15:51 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-12 21:30:21 +12:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  JS : : PrimitiveString : : create ( vm ( ) ,  string . release_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 15:19:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-18 11:53:40 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}