File tree 3 files changed +24
-0
lines changed
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,13 @@ export default class Document extends Node implements IDocument {
315
315
return < IHTMLCollection < IHTMLElement > > this . querySelectorAll ( 'a[href],area[href]' ) ;
316
316
}
317
317
318
+ /**
319
+ * Returns a collection of all form elements in a document.
320
+ */
321
+ public get forms ( ) : IHTMLCollection < IHTMLElement > {
322
+ return < IHTMLCollection < IHTMLElement > > this . querySelectorAll ( 'form' ) ;
323
+ }
324
+
318
325
/**
319
326
* Last element child.
320
327
*
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export default interface IDocument extends IParentNode {
48
48
readonly visibilityState : VisibilityStateEnum ;
49
49
readonly hidden : boolean ;
50
50
readonly links : IHTMLCollection < IHTMLElement > ;
51
+ readonly forms : IHTMLCollection < IHTMLElement > ;
51
52
readonly referrer : string ;
52
53
readonly currentScript : IHTMLScriptElement ;
53
54
adoptedStyleSheets : CSSStyleSheet [ ] ;
Original file line number Diff line number Diff line change @@ -119,6 +119,22 @@ describe('Document', () => {
119
119
} ) ;
120
120
} ) ;
121
121
122
+ describe ( 'get forms()' , ( ) => {
123
+ it ( 'Returns a elements.' , ( ) => {
124
+ const form1 = document . createElement ( 'form' ) ;
125
+ const form2 = document . createElement ( 'form' ) ;
126
+
127
+ document . body . appendChild ( form1 ) ;
128
+ document . body . appendChild ( form2 ) ;
129
+
130
+ const forms = document . forms ;
131
+
132
+ expect ( forms . length ) . toBe ( 2 ) ;
133
+ expect ( forms [ 0 ] ) . toBe ( form1 ) ;
134
+ expect ( forms [ 1 ] ) . toBe ( form2 ) ;
135
+ } ) ;
136
+ } ) ;
137
+
122
138
describe ( 'get scripts()' , ( ) => {
123
139
it ( 'Returns script elements.' , ( ) => {
124
140
const div = document . createElement ( 'div' ) ;
You can’t perform that action at this time.
0 commit comments