File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @clack/ui ' : minor
3+ ---
4+
5+ Add a live, same-object ` Document.forms ` collection with named lookup of HTML form elements.
Original file line number Diff line number Diff line change @@ -357,6 +357,12 @@ export class Document extends Node {
357357 declare readonly ownerDocument : null ;
358358
359359 readonly implementation : DOMImplementation ;
360+ readonly #forms = new HTMLCollection ( ( ) =>
361+ findElements (
362+ Array . from ( this . childNodes ) ,
363+ ( element ) => element . namespaceURI === HTML_NS && element . localName === 'form' ,
364+ ) ,
365+ ) ;
360366
361367 #factory: ( ...params : ConstructorParameters < typeof Element > ) => Element ;
362368
@@ -403,6 +409,10 @@ export class Document extends Node {
403409 return null ;
404410 }
405411
412+ get forms ( ) : HTMLCollection {
413+ return this . #forms;
414+ }
415+
406416 querySelector ( selector : string ) : Element | null {
407417 return querySelector ( Array . from ( this . childNodes ) , selector ) ;
408418 }
Original file line number Diff line number Diff line change @@ -229,6 +229,12 @@ const config: WPTConfig<Document> = {
229229 // Four other cases require innerHTML or outerHTML mutation.
230230 ] ,
231231 'html/dom/documents/dom-tree-accessors/Document.body.html' : [ "existing document's body" ] ,
232+ 'html/dom/documents/dom-tree-accessors/document.forms.html' : [
233+ 'document.forms' ,
234+ 'document.forms.item with string arg' ,
235+ 'document.forms with empty string' ,
236+ 'Document.forms should be a live collection' ,
237+ ] ,
232238 'dom/nodes/Document-getElementsByTagName.html' : [
233239 'Caching is allowed' ,
234240 "Shouldn't be able to set unsigned properties on a HTMLCollection (non-strict mode)" ,
You can’t perform that action at this time.
0 commit comments