mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:12:44 +00:00 
			
		
		
		
	LibWeb: Reset form association when any element with an ID changes
When an element with an ID is added to or removed from the DOM, or if an ID is added, removed, or changed, then we must reset the form owner of all form-associated elements who have a form attribute. We do this in 2 steps, using the DOM document as the messenger to handle these changes: 1. All form-associated elements with a form attribute are stored on the document. If the form attribute is removed, the element is removed from that list as well. 2. When a DOM element with an ID undergoes any of the aforementioned changes, it notifies the document of the change. The document then forwards that change to the stored form-associated elements.
This commit is contained in:
		
							parent
							
								
									960dcf0e56
								
							
						
					
					
						commit
						a17074422e
					
				
					 8 changed files with 97 additions and 6 deletions
				
			
		|  | @ -63,6 +63,9 @@ | |||
| <form id="changeForFormAttribute"></form> | ||||
| <input id="changeForFormAttributeInput" type="text" name="changeForFormAttribute" /> | ||||
| 
 | ||||
| <input id="inputBeforeForm" type="text" form="formAfterInput" /> | ||||
| <form id="formAfterInput"></form> | ||||
| 
 | ||||
| <script src="../include.js"></script> | ||||
| <script> | ||||
|     test(() => { | ||||
|  | @ -138,5 +141,10 @@ | |||
| 
 | ||||
|         changeForFormAttributeInput.removeAttribute("form"); | ||||
|         println(`elements in changeForFormAttribute: ${changeForFormAttribute.elements.length}`); | ||||
| 
 | ||||
|         println("== Form element appears after a form-associated element =="); | ||||
|         let formAfterInput = document.getElementById("formAfterInput"); | ||||
|         println(`elements in formAfterInput: ${formAfterInput.elements.length}`); | ||||
|         println(`typeof formAfterInput.inputBeforeForm: ${typeof formAfterInput.inputBeforeForm}`); | ||||
|     }); | ||||
| </script> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn