Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose document.forms.namedItem function #1349

Closed
martialanouman opened this issue Mar 22, 2024 · 3 comments
Closed

Expose document.forms.namedItem function #1349

martialanouman opened this issue Mar 22, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@martialanouman
Copy link

martialanouman commented Mar 22, 2024

Is your feature request related to a problem? Please describe.
I am creating a Remix app that uses @conform-to/react to manage the forms.

The new v1.0.4 version is using document.forms.namedItem() function but it is not implemented by happy-dom. That does not allow me to test form interaction with happy-dom

Here is the error i got:

TypeError: document.forms.namedItem is not a function
 ❯ getFormElement node_modules/.pnpm/@conform-to+dom@1.0.4/node_modules/@conform-to/dom/form.mjs:266:27
 ❯ Object.submit node_modules/.pnpm/@conform-to+dom@1.0.4/node_modules/@conform-to/dom/form.mjs:327:24
 ❯ onSubmit node_modules/.pnpm/@conform-to+react@1.0.4_react@18.2.0/node_modules/@conform-to/react/context.mjs:205:28
 ❯ submitHandler node_modules/.pnpm/react-router-dom@6.22.3_react-dom@18.2.0_react@18.2.0/node_modules/react-router-dom/index.tsx:1264:19
 ❯ HTMLUnknownElement.callCallback node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:4164:14
 ❯ HTMLUnknownElement.dispatchEvent node_modules/.pnpm/happy-dom@14.3.1/node_modules/happy-dom/src/event/EventTarget.ts:222:42
 ❯ HTMLUnknownElement.dispatchEvent node_modules/.pnpm/happy-dom@14.3.1/node_modules/happy-dom/src/nodes/element/Element.ts:1174:29
 ❯ HTMLUnknownElement.dispatchEvent node_modules/.pnpm/happy-dom@14.3.1/node_modules/happy-dom/src/event/EventTarget.ts:131:9
 ❯ HTMLUnknownElement.dispatchEvent node_modules/.pnpm/happy-dom@14.3.1/node_modules/happy-dom/src/nodes/element/Element.ts:1174:29
 ❯ Object.invokeGuardedCallbackDev node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:4213:16

Describe the solution you'd like
That document.forms.namedItem should be a function, not undefined

Describe alternatives you've considered
I can't test it as this is how that library implements the useForm hook.

Additional context
https://developer.mozilla.org/en-US/docs/Web/API/Document/forms

@martialanouman martialanouman added the enhancement New feature or request label Mar 22, 2024
@edmundhung
Copy link

The MDN link should be this: https://developer.mozilla.org/en-US/docs/Web/API/Document/forms

@martialanouman
Copy link
Author

martialanouman commented Apr 25, 2024

hi @capricorn86 ,
any chance to check the PR ?

capricorn86 added a commit that referenced this issue May 6, 2024
…tion

fix: [#1349] Return forms as html collection
@capricorn86
Copy link
Owner

capricorn86 commented May 6, 2024

Thank you for reporting @martialanouman ! 🙂

Big thanks to @jean-leonco for contributing with a fix ⭐

https://github.com/capricorn86/happy-dom/releases/tag/v14.8.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants