Skip to content

Commit

Permalink
fix: [#1349] Return forms as html collection
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-leonco committed Apr 12, 2024
1 parent c29f36c commit 44ee19d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/happy-dom/src/nodes/document/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ export default class Document extends Node {
/**
* Returns a collection of all form elements in a document.
*/
public get forms(): NodeList<HTMLFormElement> {
return this.querySelectorAll('form');
public get forms(): HTMLCollection<HTMLFormElement> {
return this.getElementsByTagName('form');
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/happy-dom/test/nodes/document/Document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe('Document', () => {

const forms = document.forms;

expect(forms).toBeInstanceOf(HTMLCollection);
expect(forms.length).toBe(2);
expect(forms[0]).toBe(form1);
expect(forms[1]).toBe(form2);
Expand Down

0 comments on commit 44ee19d

Please sign in to comment.